Skip to content

Commit ce6f013

Browse files
committed
* added integration tests for reopen method
1 parent 2c3a2d5 commit ce6f013

1 file changed

Lines changed: 63 additions & 3 deletions

File tree

src/test/java/de/linsin/github/rest/service/IssueBrowserIntegrationTest.java

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
import de.linsin.github.rest.domain.Issue;
2121
import de.linsin.github.rest.domain.Repository;
22+
import static org.junit.Assert.*;
2223
import org.junit.Before;
2324
import org.junit.Test;
24-
import static org.junit.Assert.*;
2525
import org.springframework.web.client.HttpClientErrorException;
2626

2727
/**
@@ -241,9 +241,58 @@ public void close_issue_invalid_repo() {
241241
public void close_issue_invalid_number() {
242242
Repository repo = setupTestRepo();
243243
Issue issue = setUpTestIssue(repo);
244-
issue.setNumber(99999L);
244+
Issue newIssue = new Issue();
245+
newIssue.setNumber(99999L);
245246
try {
246-
classUnderTest.close(repo, issue);
247+
classUnderTest.close(repo, newIssue);
248+
fail("expected exception");
249+
} catch (HttpClientErrorException e) {
250+
assertTrue(classUnderTest.browseOpen(repo).contains(issue));
251+
}
252+
}
253+
254+
@Test
255+
public void reopen_issue() {
256+
Repository repo = setupTestRepo();
257+
Issue issue = setUpClosedTestIssue(repo);
258+
issue = classUnderTest.reopen(repo, issue);
259+
assertTrue(classUnderTest.browseOpen(repo).contains(issue));
260+
}
261+
262+
@Test
263+
public void reopen_issue_invalid_user() {
264+
Repository repo = setupTestRepo();
265+
Issue issue = setUpClosedTestIssue(repo);
266+
repo.setOwner(invalidUsername);
267+
try {
268+
classUnderTest.reopen(repo, issue);
269+
fail("expected exception");
270+
} catch (HttpClientErrorException e) {
271+
assertTrue(classUnderTest.browseClosed(repo).contains(issue));
272+
}
273+
}
274+
275+
@Test
276+
public void reopen_issue_invalid_repo() {
277+
Repository repo = setupTestRepo();
278+
Issue issue = setUpClosedTestIssue(repo);
279+
repo.setName(noGoodRepoName);
280+
try {
281+
classUnderTest.reopen(repo, issue);
282+
fail("expected exception");
283+
} catch (HttpClientErrorException e) {
284+
assertTrue(classUnderTest.browseClosed(repo).contains(issue));
285+
}
286+
}
287+
288+
@Test
289+
public void reopen_issue_invalid_number() {
290+
Repository repo = setupTestRepo();
291+
Issue issue = setUpClosedTestIssue(repo);
292+
Issue newIssue = new Issue();
293+
newIssue.setNumber(99999L);
294+
try {
295+
classUnderTest.close(repo, newIssue);
247296
fail("expected exception");
248297
} catch (HttpClientErrorException e) {
249298
assertTrue(classUnderTest.browseOpen(repo).contains(issue));
@@ -258,4 +307,15 @@ private Issue setUpTestIssue(Repository argRepo) {
258307
newIssue.setBody(body);
259308
return classUnderTest.open(argRepo, newIssue);
260309
}
310+
311+
private Issue setUpClosedTestIssue(Repository argRepo) {
312+
Issue newIssue = new Issue();
313+
String title = "Issue " + System.currentTimeMillis();
314+
newIssue.setTitle(title);
315+
String body = "my test issue";
316+
newIssue.setBody(body);
317+
newIssue = classUnderTest.open(argRepo, newIssue);
318+
classUnderTest.close(argRepo, newIssue);
319+
return newIssue;
320+
}
261321
}

0 commit comments

Comments
 (0)