use of com.jcabi.github.User in project jcabi-github by jcabi.
the class MkAssignees method iterate.
@Override
public Iterable<User> iterate() {
try {
final Set<User> assignees = new HashSet<User>();
assignees.add(new MkUser(this.storage, this.self));
final Iterable<User> collaborators = new MkIterable<User>(this.storage, String.format("%s/user", this.xpath()), new MkIterable.Mapping<User>() {
@Override
public User map(final XML xml) {
try {
return new MkUser(MkAssignees.this.storage, xml.xpath("login/text()").get(0));
} catch (final IOException ex) {
throw new IllegalStateException(ex);
}
}
});
for (final User collab : collaborators) {
assignees.add(collab);
}
return assignees;
} catch (final IOException ex) {
throw new IllegalStateException(ex);
}
}
use of com.jcabi.github.User in project jcabi-github by jcabi.
the class MkPublicMembersTest method checkPublicMembership.
/**
* MkPublicMembers can check whether a user is a public member.
* @throws Exception If some problem inside
*/
@Test
public void checkPublicMembership() throws Exception {
final MkOrganization org = organization();
final PublicMembers members = org.publicMembers();
final User user = org.github().users().get("agent99");
MatcherAssert.assertThat(members.iterate(), Matchers.emptyIterableOf(User.class));
org.addMember(user);
MatcherAssert.assertThat("The newly-added user is not a public member", !members.contains(user));
members.publicize(user);
MatcherAssert.assertThat("The user has been made a public member", members.contains(user));
MatcherAssert.assertThat(members.iterate(), Matchers.hasItem(user));
members.conceal(user);
MatcherAssert.assertThat("The concealed user is not a public member", !members.contains(user));
}
use of com.jcabi.github.User in project jcabi-github by jcabi.
the class MkPublicMembersTest method iteratesPublicMembers.
/**
* MkPublicMembers can iterate over all public members.
* @throws Exception If some problem inside
*/
@Test
public void iteratesPublicMembers() throws Exception {
final MkOrganization org = organization();
final PublicMembers members = org.publicMembers();
final User user = org.github().users().get("jasmine");
MatcherAssert.assertThat(members.iterate(), Matchers.emptyIterableOf(User.class));
org.addMember(user);
MatcherAssert.assertThat(members.iterate(), Matchers.emptyIterableOf(User.class));
members.publicize(user);
MatcherAssert.assertThat(members.iterate(), Matchers.<User>iterableWithSize(1));
MatcherAssert.assertThat(members.iterate(), Matchers.hasItem(user));
members.conceal(user);
MatcherAssert.assertThat(members.iterate(), Matchers.emptyIterableOf(User.class));
}
use of com.jcabi.github.User in project jcabi-github by jcabi.
the class MkPublicMembersTest method changesPublicityOfMembershipOfUsers.
/**
* MkPublicMembers can publicize/conceal a member's membership.
* @throws Exception If some problem inside
*/
@Test
public void changesPublicityOfMembershipOfUsers() throws Exception {
final MkOrganization org = organization();
final PublicMembers members = org.publicMembers();
final User user = org.github().users().get("johnny5");
org.addMember(user);
MatcherAssert.assertThat("Newly-added user is not a public member", !members.contains(user));
members.publicize(user);
MatcherAssert.assertThat("User has been made a public member", members.contains(user));
members.conceal(user);
MatcherAssert.assertThat("Concealed user is not a public member", !members.contains(user));
members.publicize(user);
MatcherAssert.assertThat("User has been made a public member again", members.contains(user));
}
Aggregations