diff options
author | Kevin Sawicki | 2012-09-21 17:19:29 +0000 |
---|---|---|
committer | Kevin Sawicki | 2012-09-21 17:19:29 +0000 |
commit | dd6352a5ac8d828940d936d11eb994bb22a26141 (patch) | |
tree | 483c65b089df5e70c43bef64c46afc55a4b07e69 /org.eclipse.egit.github.core.tests/src/org | |
parent | 31db368a6df1960fe9f27abfe1454460de4c030e (diff) | |
download | egit-github-dd6352a5ac8d828940d936d11eb994bb22a26141.tar.gz egit-github-dd6352a5ac8d828940d936d11eb994bb22a26141.tar.xz egit-github-dd6352a5ac8d828940d936d11eb994bb22a26141.zip |
Add service support for commit status API
Change-Id: I12ca471ab6b482248eed3eeb8d20f5dd1e85dea9
Diffstat (limited to 'org.eclipse.egit.github.core.tests/src/org')
-rw-r--r-- | org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitServiceTest.java | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitServiceTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitServiceTest.java index c7b83675..13e0116a 100644 --- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitServiceTest.java +++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitServiceTest.java @@ -18,8 +18,11 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import org.eclipse.egit.github.core.CommitComment; +import org.eclipse.egit.github.core.CommitStatus; import org.eclipse.egit.github.core.RepositoryCommit; import org.eclipse.egit.github.core.RepositoryId; import org.eclipse.egit.github.core.client.GitHubClient; @@ -312,4 +315,121 @@ public class CommitServiceTest { request.setUri("/repos/o/n/compare/v1...HEAD"); verify(client).get(request); } + + /** + * Get statuses + * + * @throws IOException + */ + @Test(expected = IllegalArgumentException.class) + public void getStatusesNullRepository() throws IOException { + service.getStatuses(null, "123"); + } + + /** + * Get statuses + * + * @throws IOException + */ + @Test(expected = IllegalArgumentException.class) + public void getStatusesNullSha() throws IOException { + service.getStatuses(new RepositoryId("o", "n"), null); + } + + /** + * Get statuses + * + * @throws IOException + */ + @Test(expected = IllegalArgumentException.class) + public void getStatusesEmptySha() throws IOException { + service.getStatuses(new RepositoryId("o", "n"), ""); + } + + /** + * Get statuses + * + * @throws IOException + */ + @Test + public void getStatuses() throws IOException { + RepositoryId repo = new RepositoryId("o", "n"); + service.getStatuses(repo, "123"); + GitHubRequest request = new GitHubRequest(); + request.setUri(Utils.page("/repos/o/n/statuses/123")); + verify(client).get(request); + } + + /** + * Create status + * + * @throws IOException + */ + @Test + public void createStatus() throws IOException { + RepositoryId repo = new RepositoryId("o", "n"); + CommitStatus status = new CommitStatus(); + status.setDescription("description"); + status.setTargetUrl("http://target/url"); + status.setState("success"); + service.createStatus(repo, "123", status); + Map<String, String> params = new HashMap<String, String>(); + params.put("description", status.getDescription()); + params.put("target_url", status.getTargetUrl()); + params.put("state", status.getState()); + verify(client).post("/repos/o/n/statuses/123", params, + CommitStatus.class); + } + + /** + * Create status + * + * @throws IOException + */ + @Test(expected = IllegalArgumentException.class) + public void createStatusNullRepository() throws IOException { + CommitStatus status = new CommitStatus(); + status.setDescription("description"); + status.setTargetUrl("http://target/url"); + status.setState("success"); + service.createStatus(null, "123", status); + } + + /** + * Create status + * + * @throws IOException + */ + @Test(expected = IllegalArgumentException.class) + public void createStatusNullSha() throws IOException { + CommitStatus status = new CommitStatus(); + status.setDescription("description"); + status.setTargetUrl("http://target/url"); + status.setState("success"); + service.createStatus(new RepositoryId("o", "n"), null, status); + } + + /** + * Create status + * + * @throws IOException + */ + @Test(expected = IllegalArgumentException.class) + public void createStatusEmptySha() throws IOException { + CommitStatus status = new CommitStatus(); + status.setDescription("description"); + status.setTargetUrl("http://target/url"); + status.setState("success"); + service.createStatus(new RepositoryId("o", "n"), "", status); + } + + /** + * Create status + * + * @throws IOException + */ + @Test(expected = IllegalArgumentException.class) + public void createStatusNullStatus() throws IOException { + service.createStatus(new RepositoryId("o", "n"), "123", null); + } } |