summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-05-05 16:54:05 (EDT)
committerChristian Trutz2011-05-05 16:54:05 (EDT)
commit039ce32da4ca76c9138ec879f52c9649507a6d4e (patch)
treedc4d349b2c331f2bc76b8d10e01f2d5e5ee6ae78
parentf6cf2b0b4621e01b5909280b1b42256a0710afef (diff)
downloadegit-github-039ce32da4ca76c9138ec879f52c9649507a6d4e.zip
egit-github-039ce32da4ca76c9138ec879f52c9649507a6d4e.tar.gz
egit-github-039ce32da4ca76c9138ec879f52c9649507a6d4e.tar.bz2
PullRequestService unit tests completed.refs/changes/47/3347/1
Change-Id: I2668a1d4249b7e31af38647a51d9860576dbe928 Signed-off-by: Christian Trutz <christian.trutz@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/PullRequestService.java4
-rwxr-xr-xorg.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/PullRequestServiceTest.java25
2 files changed, 27 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/PullRequestService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/PullRequestService.java
index 37622ad..496a21f 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/PullRequestService.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/PullRequestService.java
@@ -94,9 +94,11 @@ public class PullRequestService {
throws IOException {
Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
Assert.isNotNull(state, "State cannot be null"); //$NON-NLS-1$
+ String repositoryId = repository.getId();
+ Assert.isNotNull(repositoryId, "Repository id cannot be null"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_V2_API);
uri.append(IGitHubConstants.SEGMENT_PULLS);
- uri.append('/').append(repository.getId());
+ uri.append('/').append(repositoryId);
uri.append('/').append(state);
PullRequestsWrapper wrapper = this.client.get(uri.toString(),
PullRequestsWrapper.class);
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/PullRequestServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/PullRequestServiceTest.java
index 2b0b78c..512c080 100755
--- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/PullRequestServiceTest.java
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/PullRequestServiceTest.java
@@ -16,6 +16,7 @@ import java.io.IOException;
import org.eclipse.core.runtime.AssertionFailedException;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -63,8 +64,30 @@ public class PullRequestServiceTest {
}
@Test
+ @Ignore
public void getPullRequest_OK() throws IOException {
- // the OK unit test is not possible with Mockito, but with JMOckit
+ // the OK unit test is not possible with Mockito, but with JMockit
}
+ @Test(expected = AssertionFailedException.class)
+ public void getPullRequests_NullRepository() throws IOException {
+ pullRequestService.getPullRequests(null, "not null");
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void getPullRequests_NullState() throws IOException {
+ pullRequestService.getPullRequests(repository, null);
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void getPullRequests_NullRepositoryId() throws IOException {
+ when(repository.getId()).thenReturn(null);
+ pullRequestService.getPullRequests(repository, "test_state");
+ }
+
+ @Test
+ @Ignore
+ public void getPullRequests_OK() throws IOException {
+ // the OK unit test is not possible with Mockito, but with JMockit
+ }
}