Permalink
Browse files

Add service support for getting all repositories

Change-Id: Ifda3068d4dba3b24e4c53cf53afba5a5329a90d1
  • Loading branch information...
1 parent 06b147e commit eeadbeb7b82ac37f3231eff79c3ffdcb827592b6 @kevinsawicki kevinsawicki committed Dec 9, 2012
@@ -285,6 +285,32 @@ public void getRepositories() throws IOException {
}
/**
+ * Page all repositories
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pageAllRepositories() throws IOException {
+ service.pageAllRepositories().next();
+ GitHubRequest request = new GitHubRequest();
+ request.setUri(Utils.page("/repositories"));
+ verify(client).get(request);
+ }
+
+ /**
+ * Page all repositories
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pageAllRepositoriesSince() throws IOException {
+ service.pageAllRepositories(1234).next();
+ GitHubRequest request = new GitHubRequest();
+ request.setUri(Utils.page("/repositories?since=1234"));
+ verify(client).get(request);
+ }
+
+ /**
* Get repositories with null user
*
* @throws IOException
@@ -21,6 +21,7 @@
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_LEGACY;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_ORGS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOS;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOSITORIES;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_SEARCH;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_TAGS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_TEST;
@@ -232,6 +233,32 @@ public RepositoryService(GitHubClient client) {
}
/**
+ * Page all repositories
+ *
+ * @return iterator over pages of repositories
+ */
+ public PageIterator<Repository> pageAllRepositories() {
+ return pageAllRepositories(-1);
+ }
+
+ /**
+ * Page all repositories
+ *
+ * @param since
+ * @return iterator over pages of repositories
+ */
+ public PageIterator<Repository> pageAllRepositories(final long since) {
+ PagedRequest<Repository> request = createPagedRequest();
+ request.setUri(SEGMENT_REPOSITORIES);
+ if (since > 0)
+ request.setParams(Collections.singletonMap("since",
+ Long.toString(since)));
+ request.setType(new TypeToken<List<Repository>>() {
+ }.getType());
+ return createPageIterator(request);
+ }
+
+ /**
* Get repositories for the given user
*
* @param user

0 comments on commit eeadbeb

Please sign in to comment.