Skip to content
Permalink
Browse files

Remove the need for a get closed issues method

  • Loading branch information...
nWidart committed May 16, 2019
1 parent 0d8cdec commit 2e68edd25f74ea82f092b95872b73f1cb83f6cea
@@ -32,15 +32,6 @@
*/
Page<Issue> getIssues(String organization, String repository);

/**
* Returns the closed issues in the {@code repository} owned by the given
* {@code organization}.
* @param organization the name of the organization
* @param repository the name of the repository
* @return the issues
*/
Page<Issue> getClosedIssues(String organization, String repository);

/**
* Returns the comments that have been made on the given {@code issue}.
* @param issue the issue
@@ -113,13 +113,6 @@ public void handleError(ClientHttpResponse response) throws IOException {
return getPage(url, Issue[].class);
}

@Override
public Page<Issue> getClosedIssues(String organization, String repository) {
String url = "https://api.github.com/repos/" + organization + "/" + repository
+ "/issues?state=closed";
return getPage(url, Issue[].class);
}

@Override
public Page<Comment> getComments(Issue issue) {
return getPage(issue.getCommentsUrl(), Comment[].class);
@@ -80,16 +80,6 @@ public void singlePageOfIssues() {
assertThat(issues.next()).isNull();
}

@Test
public void singlePageOfClosedIssue() {
this.server.expect(requestTo("https://api.github.com/repos/org/repo/issues?state=closed"))
.andExpect(method(HttpMethod.GET)).andExpect(basicAuth())
.andRespond(withResource("issues-page-one.json"));
Page<Issue> issues = this.gitHub.getClosedIssues("org", "repo");
assertThat(issues.getContent()).hasSize(15);
assertThat(issues.next()).isNull();
}

@Test
public void multiplePagesOfIssues() {
HttpHeaders headers = new HttpHeaders();
@@ -107,23 +97,6 @@ public void multiplePagesOfIssues() {
assertThat(pageTwo.getContent()).hasSize(15);
}

@Test
public void multiplePagesOfClosedIssues() {
HttpHeaders headers = new HttpHeaders();
headers.set("Link", "<page-two>; rel=\"next\"");
this.server.expect(requestTo("https://api.github.com/repos/org/repo/issues?state=closed"))
.andExpect(method(HttpMethod.GET)).andExpect(basicAuth())
.andRespond(withResource("issues-page-one.json",
"Link:<page-two>; rel=\"next\""));
this.server.expect(requestTo("/page-two")).andExpect(method(HttpMethod.GET))
.andExpect(basicAuth()).andRespond(withResource("issues-page-two.json"));
Page<Issue> pageOne = this.gitHub.getClosedIssues("org", "repo");
assertThat(pageOne.getContent()).hasSize(15);
Page<Issue> pageTwo = pageOne.next();
assertThat(pageTwo).isNotNull();
assertThat(pageTwo.getContent()).hasSize(15);
}

@Test
public void rateLimited() {
long reset = System.currentTimeMillis();

0 comments on commit 2e68edd

Please sign in to comment.
You can’t perform that action at this time.