diff options
| author | Christian Trutz | 2011-04-15 21:03:44 +0000 |
|---|---|---|
| committer | Christian Trutz | 2011-04-15 21:03:44 +0000 |
| commit | 5a1c8564877a0abf9480371f3b6fd9edbaac5e24 (patch) | |
| tree | 9f9c709e01f0b2670ed514c9b9b4df2778260859 | |
| parent | 74087e9a09cec9f91d2f50bc7031456a0225a37c (diff) | |
| download | egit-github-5a1c8564877a0abf9480371f3b6fd9edbaac5e24.tar.gz egit-github-5a1c8564877a0abf9480371f3b6fd9edbaac5e24.tar.xz egit-github-5a1c8564877a0abf9480371f3b6fd9edbaac5e24.zip | |
Unit tests for IssueService#createComment
Change-Id: If029714fe7d89e713228ab3516b8ec54e2e45cf9
Signed-off-by: Christian Trutz <christian.trutz@gmail.com>
| -rw-r--r-- | org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java | 3 | ||||
| -rw-r--r-- | org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java | 27 |
2 files changed, 30 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java index 8ef12472..c623c9fd 100644 --- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java +++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java @@ -246,6 +246,9 @@ public class IssueService { */ public Comment createComment(String user, String repository, String issueId, String comment) throws IOException { + Assert.isNotNull(user, "User cannot be null"); //$NON-NLS-1$ + Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$ + Assert.isNotNull(issueId, "Issue id cannot be null"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS); uri.append('/').append(user).append('/').append(repository); uri.append(IGitHubConstants.SEGMENT_ISSUES); 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 a6103216..6afeed1f 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 @@ -166,4 +166,31 @@ public class IssueServiceTest { "/repos/test_user/test_repository/issues/1.json", params, Issue.class); } + + @Test(expected = AssertionFailedException.class) + public void createComment_NullUser() throws IOException { + issueService.createComment(null, "not null", "not null", "not null"); + } + + @Test(expected = AssertionFailedException.class) + public void createComment_NullRepository() throws IOException { + issueService.createComment("not null", null, "not null", "not null"); + } + + @Test(expected = AssertionFailedException.class) + public void createComment_NullIssueId() throws IOException { + issueService.createComment("not null", "not null", null, "not null"); + } + + @Test + public void createComment_OK() throws IOException { + issueService.createComment("test_user", "test_repository", "1", + "test_comment"); + + Map<String, String> params = new HashMap<String, String>(); + params.put(IssueService.FIELD_BODY, "test_comment"); + verify(gitHubClient).post( + "/repos/test_user/test_repository/issues/1/comments.json", + params, Comment.class); + } } |
