diff options
author | Christian Trutz | 2011-04-12 21:55:10 +0000 |
---|---|---|
committer | Chris Aniszczyk | 2011-04-15 15:17:22 +0000 |
commit | 2a0c5f8949b0493b77369e4fa9d1244519982333 (patch) | |
tree | 7e9fe50f6d2b4e80281c12b2b5ec29b433e24924 /org.eclipse.mylyn.github.tests/src | |
parent | 06efd7f9b306a4ed3b99057498faae21b12f1893 (diff) | |
download | egit-github-2a0c5f8949b0493b77369e4fa9d1244519982333.tar.gz egit-github-2a0c5f8949b0493b77369e4fa9d1244519982333.tar.xz egit-github-2a0c5f8949b0493b77369e4fa9d1244519982333.zip |
More unit tests for IssueService
Change-Id: Id74b4433756fe103ac7f368b66c2887e15f0d132
Signed-off-by: Christian Trutz <christian.trutz@gmail.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.mylyn.github.tests/src')
-rw-r--r-- | org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java | 81 |
1 files changed, 78 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java index 2e76bd4e..3d765ee2 100644 --- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java +++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java @@ -10,7 +10,10 @@ *******************************************************************************/ package org.eclipse.mylyn.github.internal; +import static org.mockito.Mockito.verify; + import java.io.IOException; +import java.util.List; import org.eclipse.core.runtime.AssertionFailedException; import org.junit.Before; @@ -19,6 +22,8 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import com.google.gson.reflect.TypeToken; + /** * Unit tests for {@link IssueService} */ @@ -42,18 +47,88 @@ public class IssueServiceTest { } @Test(expected = AssertionFailedException.class) - public void getIssue_NullUser() throws IOException{ + public void getIssue_NullUser() throws IOException { issueService.getIssue(null, "not null", "not null"); } @Test(expected = AssertionFailedException.class) - public void getIssue_NullRepository() throws IOException{ + public void getIssue_NullRepository() throws IOException { issueService.getIssue("not null", null, "not null"); } @Test(expected = AssertionFailedException.class) - public void getIssue_NullId() throws IOException{ + public void getIssue_NullId() throws IOException { issueService.getIssue("not null", "not null", null); } + @Test + public void getIssue_OK() throws IOException { + issueService.getIssue("test_user", "test_repository", "test_id"); + verify(gitHubClient).get( + "/repos/test_user/test_repository/issues/test_id.json", + Issue.class); + } + + @Test(expected = AssertionFailedException.class) + public void getComments_NullUser() throws IOException { + issueService.getComments(null, "not null", "not null"); + } + + @Test(expected = AssertionFailedException.class) + public void getComments_NullRepository() throws IOException { + issueService.getComments("not null", null, "not null"); + } + + @Test(expected = AssertionFailedException.class) + public void getComments_NullId() throws IOException { + issueService.getComments("not null", "not null", null); + } + + @Test + public void getComments_OK() throws IOException { + issueService.getComments("test_user", "test_repository", "test_id"); + TypeToken<List<Comment>> commentToken = new TypeToken<List<Comment>>() { + }; + verify(gitHubClient) + .get("/repos/test_user/test_repository/issues/test_id/comments.json", + commentToken.getType()); + } + + @Test(expected = AssertionFailedException.class) + public void getIssues_NullUser() throws IOException { + issueService.getIssues(null, "not null", null); + } + + @Test(expected = AssertionFailedException.class) + public void getIssues_NullRepository() throws IOException { + issueService.getIssues("not null", null, null); + } + + @Test + public void getIssues_OK() throws IOException { + issueService.getIssues("test_user", "test_repository", null); + TypeToken<List<Issue>> issuesToken = new TypeToken<List<Issue>>() { + }; + verify(gitHubClient).get( + "/repos/test_user/test_repository/issues.json", null, + issuesToken.getType()); + } + + @Test(expected = AssertionFailedException.class) + public void createIssue_NullUser() throws IOException { + issueService.createIssue(null, "not null", null); + } + + @Test(expected = AssertionFailedException.class) + public void createIssue_NullRepository() throws IOException { + issueService.createIssue("not null", null, null); + } + + @Test + public void createIssue_NullIssue() throws IOException { + issueService.createIssue("test_user", "test_repository", null); + verify(gitHubClient).post( + "/repos/test_user/test_repository/issues.json", null, + Issue.class); + } } |