Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-04-26 21:47:03 +0000
committerChristian Trutz2011-04-26 21:51:52 +0000
commita3944c5d1c10a0f178ced3aa5bd3ec95f6ffd7fc (patch)
tree35ca06ed0a023684b30ce92ce0c041b005628a28 /org.eclipse.mylyn.github.tests/src
parent9e2b2c9b75ddec007dedbc5c5885be3628e3dd6b (diff)
downloadegit-github-a3944c5d1c10a0f178ced3aa5bd3ec95f6ffd7fc.tar.gz
egit-github-a3944c5d1c10a0f178ced3aa5bd3ec95f6ffd7fc.tar.xz
egit-github-a3944c5d1c10a0f178ced3aa5bd3ec95f6ffd7fc.zip
Unit tests for GistService completed
Change-Id: Id12bb29f606a98b21285920ffe7fa90ce93989ec Signed-off-by: Christian Trutz <christian.trutz@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/GistServiceTest.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java
index ed2cc7d7..0d95bae3 100644
--- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java
@@ -13,7 +13,9 @@ package org.eclipse.mylyn.github.internal;
import static org.mockito.Mockito.verify;
import java.io.IOException;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.AssertionFailedException;
import org.junit.Before;
@@ -103,4 +105,60 @@ public class GistServiceTest {
gist.setUser(user);
gistService.createGist(gist);
}
+
+ @Test(expected = AssertionFailedException.class)
+ public void updateGist_NullGist() throws IOException {
+ gistService.updateGist(null);
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void updateGist_NullRepository() throws IOException {
+ Gist gist = new Gist();
+ gist.setRepo(null);
+ gistService.updateGist(gist);
+ }
+
+ @Test
+ public void updateGist_OK() throws IOException {
+ Gist gist = new Gist();
+ gist.setRepo("test_repository");
+ gistService.updateGist(gist);
+ verify(gitHubClient).put("/gists/test_repository.json", gist,
+ Gist.class);
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void createComment_NullGistId() throws IOException {
+ gistService.createComment(null, "not null");
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void createComment_NullComment() throws IOException {
+ gistService.createComment("not null", null);
+ }
+
+ @Test
+ public void createComment_OK() throws IOException {
+ gistService.createComment("1", "test_comment");
+
+ Map<String, String> params = new HashMap<String, String>(1, 1);
+ params.put(IssueService.FIELD_BODY, "test_comment");
+ verify(gitHubClient).post("/gists/1/comments.json", params,
+ Comment.class);
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void getComments_NullGistId() throws IOException {
+ gistService.getComments(null);
+ }
+
+ @Test
+ public void getComments_OK() throws IOException {
+ gistService.getComments("1");
+
+ TypeToken<List<Comment>> commentsToken = new TypeToken<List<Comment>>() {
+ };
+ verify(gitHubClient).get("/gists/1/comments.json",
+ commentsToken.getType());
+ }
}

Back to the top