*
* @throws Exception If a problem occurs
*/
@Test
public void canIterateOrganizationsForUnauthUser() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
Json.createArrayBuilder()
.add(org(Tv.THREE, "org11"))
.add(org(Tv.FOUR, "org12"))
.add(org(Tv.FIVE, "org13"))
.build().toString()
)
).start();
try {
final Organizations orgs = new RtOrganizations(
new MkGithub(),
new ApacheRequest(container.home()),
Mockito.mock(User.class)
);
final String username = "octopus";
MatcherAssert.assertThat(
orgs.iterate(username),
Matchers.<Organization>iterableWithSize(Tv.THREE)
);
MatcherAssert.assertThat(
container.take().uri().toString(),
Matchers.endsWith(String.format("/users/%s/orgs", username))
);
} finally {
container.stop();
}
}