Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Aniszczyk2011-05-10 20:07:33 +0000
committerCode Review2011-05-10 20:07:33 +0000
commit6e1c81318c09779b3e924a8b74a0d064df767615 (patch)
treecba676fdadc15ad9b9242afa73154382d3024b2c /org.eclipse.mylyn.github.tests
parent6d072766314c5371500062459ab41d844e2f86dd (diff)
parent0a52dc80a7f0263d43a7ac2f0a5d4803e7e963a0 (diff)
downloadegit-github-6e1c81318c09779b3e924a8b74a0d064df767615.tar.gz
egit-github-6e1c81318c09779b3e924a8b74a0d064df767615.tar.xz
egit-github-6e1c81318c09779b3e924a8b74a0d064df767615.zip
Merge "Migrate services to support pagination"
Diffstat (limited to 'org.eclipse.mylyn.github.tests')
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java21
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java27
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/LabelServiceTest.java16
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/MilestoneServiceTest.java22
4 files changed, 42 insertions, 44 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 e751ab59..f7715205 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.mylyn.github.internal;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
import java.io.IOException;
@@ -36,10 +38,14 @@ public class GistServiceTest {
@Mock
private GitHubClient gitHubClient;
+ @Mock
+ private GitHubResponse response;
+
private GistService gistService;
@Before
- public void before() {
+ public void before() throws IOException {
+ doReturn(response).when(gitHubClient).get(any(GitHubRequest.class));
gistService = new GistService(gitHubClient);
}
@@ -56,7 +62,7 @@ public class GistServiceTest {
@Test
public void getGist_OK() throws IOException {
gistService.getGist("1");
- verify(gitHubClient).get("/gists/1.json", Gist.class);
+ verify(gitHubClient).get(any(GitHubRequest.class));
}
@Test(expected = AssertionFailedException.class)
@@ -67,10 +73,7 @@ public class GistServiceTest {
@Test
public void getGists_OK() throws IOException {
gistService.getGists("test_user");
- TypeToken<List<Gist>> gistsToken = new TypeToken<List<Gist>>() {
- };
- verify(gitHubClient).get("/users/test_user/gists.json",
- gistsToken.getType());
+ verify(gitHubClient).get(any(GitHubRequest.class));
}
@Test(expected = AssertionFailedException.class)
@@ -123,8 +126,7 @@ public class GistServiceTest {
Gist gist = new Gist();
gist.setId("123");
gistService.updateGist(gist);
- verify(gitHubClient).put("/gists/123.json", gist,
- Gist.class);
+ verify(gitHubClient).put("/gists/123.json", gist, Gist.class);
}
@Test(expected = AssertionFailedException.class)
@@ -158,7 +160,6 @@ public class GistServiceTest {
TypeToken<List<Comment>> commentsToken = new TypeToken<List<Comment>>() {
};
- verify(gitHubClient).get("/gists/1/comments.json",
- commentsToken.getType());
+ verify(gitHubClient).get(any(GitHubRequest.class));
}
}
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 20e1dde2..203183ea 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,11 +10,12 @@
*******************************************************************************/
package org.eclipse.mylyn.github.internal;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
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;
@@ -24,8 +25,6 @@ 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}
*/
@@ -36,10 +35,14 @@ public class IssueServiceTest {
@Mock
private GitHubClient gitHubClient;
+ @Mock
+ private GitHubResponse response;
+
private IssueService issueService;
@Before
- public void before() {
+ public void before() throws IOException {
+ doReturn(response).when(gitHubClient).get(any(GitHubRequest.class));
issueService = new IssueService(gitHubClient);
}
@@ -66,9 +69,7 @@ public class IssueServiceTest {
@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);
+ verify(gitHubClient).get(any(GitHubRequest.class));
}
@Test(expected = AssertionFailedException.class)
@@ -89,11 +90,7 @@ public class IssueServiceTest {
@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());
+ verify(gitHubClient).get(any(GitHubRequest.class));
}
@Test(expected = AssertionFailedException.class)
@@ -109,11 +106,7 @@ public class IssueServiceTest {
@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());
+ verify(gitHubClient).get(any(GitHubRequest.class));
}
@Test(expected = AssertionFailedException.class)
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/LabelServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/LabelServiceTest.java
index 04224bbb..d15fb336 100644
--- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/LabelServiceTest.java
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/LabelServiceTest.java
@@ -10,8 +10,12 @@
*******************************************************************************/
package org.eclipse.mylyn.github.internal;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
+import com.google.gson.reflect.TypeToken;
+
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
@@ -23,8 +27,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
-import com.google.gson.reflect.TypeToken;
-
/**
* Unit tests for {@link LabelService}.
*/
@@ -35,10 +37,14 @@ public class LabelServiceTest {
@Mock
private GitHubClient gitHubClient;
+ @Mock
+ private GitHubResponse response;
+
private LabelService labelService;
@Before
- public void before() {
+ public void before() throws IOException {
+ doReturn(response).when(gitHubClient).get(any(GitHubRequest.class));
labelService = new LabelService(gitHubClient);
}
@@ -62,9 +68,7 @@ public class LabelServiceTest {
labelService.getLabels("test_user", "test_repository");
TypeToken<List<Label>> labelsToken = new TypeToken<List<Label>>() {
};
- verify(gitHubClient).get(
- "/repos/test_user/test_repository/labels.json",
- labelsToken.getType());
+ verify(gitHubClient).get(any(GitHubRequest.class));
}
@Test(expected = AssertionFailedException.class)
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/MilestoneServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/MilestoneServiceTest.java
index d959a8ee..d80475a2 100644
--- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/MilestoneServiceTest.java
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/MilestoneServiceTest.java
@@ -10,10 +10,13 @@
*******************************************************************************/
package org.eclipse.mylyn.github.internal;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
+import com.google.gson.reflect.TypeToken;
+
import java.io.IOException;
-import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.AssertionFailedException;
@@ -23,8 +26,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
-import com.google.gson.reflect.TypeToken;
-
/**
* Unit tests for {@link MilestoneService}
*/
@@ -35,10 +36,14 @@ public class MilestoneServiceTest {
@Mock
private GitHubClient gitHubClient;
+ @Mock
+ private GitHubResponse response;
+
private MilestoneService milestoneService;
@Before
- public void before() {
+ public void before() throws IOException {
+ doReturn(response).when(gitHubClient).get(any(GitHubRequest.class));
milestoneService = new MilestoneService(gitHubClient);
}
@@ -62,9 +67,7 @@ public class MilestoneServiceTest {
milestoneService.getMilestones("test_user", "test_repository", null);
TypeToken<List<Milestone>> milestonesToken = new TypeToken<List<Milestone>>() {
};
- verify(gitHubClient).get(
- "/repos/test_user/test_repository/milestones.json", null,
- milestonesToken.getType());
+ verify(gitHubClient).get(any(GitHubRequest.class));
}
@Test
@@ -73,10 +76,7 @@ public class MilestoneServiceTest {
"test_state");
TypeToken<List<Milestone>> milestonesToken = new TypeToken<List<Milestone>>() {
};
- verify(gitHubClient).get(
- "/repos/test_user/test_repository/milestones.json",
- Collections.singletonMap(IssueService.FILTER_STATE,
- "test_state"), milestonesToken.getType());
+ verify(gitHubClient).get(any(GitHubRequest.class));
}
}

Back to the top