Search in sources :

Example 1 with User

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);
    }
}
Also used : User(com.jcabi.github.User) XML(com.jcabi.xml.XML) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 2 with User

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));
}
Also used : User(com.jcabi.github.User) PublicMembers(com.jcabi.github.PublicMembers) Test(org.junit.Test)

Example 3 with 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));
}
Also used : User(com.jcabi.github.User) PublicMembers(com.jcabi.github.PublicMembers) Test(org.junit.Test)

Example 4 with User

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));
}
Also used : User(com.jcabi.github.User) PublicMembers(com.jcabi.github.PublicMembers) Test(org.junit.Test)

Aggregations

User (com.jcabi.github.User)4 PublicMembers (com.jcabi.github.PublicMembers)3 Test (org.junit.Test)3 XML (com.jcabi.xml.XML)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1