summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-04-15 17:03:44 (EDT)
committerChristian Trutz2011-04-15 17:03:44 (EDT)
commit5a1c8564877a0abf9480371f3b6fd9edbaac5e24 (patch)
tree9f9c709e01f0b2670ed514c9b9b4df2778260859
parent74087e9a09cec9f91d2f50bc7031456a0225a37c (diff)
downloadegit-github-5a1c8564877a0abf9480371f3b6fd9edbaac5e24.zip
egit-github-5a1c8564877a0abf9480371f3b6fd9edbaac5e24.tar.gz
egit-github-5a1c8564877a0abf9480371f3b6fd9edbaac5e24.tar.bz2
Unit tests for IssueService#createCommentrefs/changes/44/3144/1
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.java3
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java27
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 8ef1247..c623c9f 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 a610321..6afeed1 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);
+ }
}