mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-10 08:21:21 +00:00
Issue #309: Added user listing
This commit is contained in:
@@ -392,6 +392,23 @@ public class GitHub {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all users.
|
||||
*/
|
||||
public PagedIterable<GHUser> listUsers() throws IOException {
|
||||
return new PagedIterable<GHUser>() {
|
||||
public PagedIterator<GHUser> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHUser>(retrieve().asIterator("/users", GHUser[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHUser[] page) {
|
||||
for (GHUser u : page)
|
||||
u.wrapUp(GitHub.this);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full details for a license
|
||||
*
|
||||
|
||||
@@ -7,6 +7,8 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
@@ -145,4 +147,13 @@ public class GitHubTest {
|
||||
assertTrue(ioe.getMessage().contains("private mode enabled"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listUsers() throws IOException {
|
||||
GitHub hub = GitHub.connect();
|
||||
for (GHUser u : Iterables.limit(hub.listUsers(),10)) {
|
||||
assert u.getName()!=null;
|
||||
System.out.println(u.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user