summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2013-07-19 10:51:33 (EDT)
committerTomasz Zarna2013-07-22 05:48:03 (EDT)
commita341c81e70472252c2b24a51642a55f5e3bb6a59 (patch)
tree054ee16c515d7fbd6bd1b12b772a3699df966e8a
parent8457b0eac5d2cc7607bb4edaec5b598db0e1ce72 (diff)
downloadorg.eclipse.mylyn.reviews-a341c81e70472252c2b24a51642a55f5e3bb6a59.zip
org.eclipse.mylyn.reviews-a341c81e70472252c2b24a51642a55f5e3bb6a59.tar.gz
org.eclipse.mylyn.reviews-a341c81e70472252c2b24a51642a55f5e3bb6a59.tar.bz2
add tests for adding reviewersrefs/changes/04/14704/2
Change-Id: Ia90d6ccda4b6a9aca50c73be8647bc72dddb1ce5 Signed-off-by: Tomasz Zarna <tomasz.zarna@tasktop.com>
-rw-r--r--org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java
index baf5043..1daf410 100644
--- a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java
+++ b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java
@@ -19,6 +19,7 @@ import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.assertThat;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
@@ -48,6 +49,7 @@ import org.eclipse.mylyn.reviews.core.spi.remote.emf.RemoteEmfConsumer;
import org.eclipse.osgi.util.NLS;
import org.junit.Test;
+import com.google.gerrit.common.data.ReviewerResult;
import com.google.gerrit.reviewdb.ApprovalCategory;
import com.google.gerrit.reviewdb.ApprovalCategoryValue;
import com.google.gerrit.reviewdb.Change.Status;
@@ -229,4 +231,56 @@ public class GerritReviewRemoteFactoryTest extends GerritRemoteTest {
"Cannot submit change {0}: needs Verified; change {0}: needs Code-Review", reviewHarness.shortId)));
}
}
+
+ @Test
+ public void testAddNullReviewers() throws Exception {
+ try {
+ reviewHarness.client.addReviewers(reviewHarness.shortId, null, new NullProgressMonitor());
+ fail("Expected to fail when trying to add null reviewers");
+ } catch (GerritException e) {
+ assertThat(e.getMessage(), is("Internal Server Error"));
+ }
+ }
+
+ @Test
+ public void testAddEmptyReviewers() throws Exception {
+ ReviewerResult reviewerResult = reviewHarness.client.addReviewers(reviewHarness.shortId,
+ Collections.<String> emptyList(), new NullProgressMonitor());
+ assertThat(reviewerResult.getErrors().isEmpty(), is(true));
+ }
+
+ @Test
+ public void testAddInvalidReviewers() throws Exception {
+ List<String> reviewers = Arrays.asList(new String[] { "foo" });
+ ReviewerResult reviewerResult = reviewHarness.client.addReviewers(reviewHarness.shortId, reviewers,
+ new NullProgressMonitor());
+ assertThat(reviewerResult.getErrors().size(), is(1));
+ assertThat(reviewerResult.getErrors().get(0).getName(), is("foo"));
+ }
+
+ @Test
+ public void testAddSomeInvalidReviewers() throws Exception {
+ List<String> reviewers = Arrays.asList(new String[] { "tests", "foo" });
+ ReviewerResult reviewerResult = reviewHarness.client.addReviewers(reviewHarness.shortId, reviewers,
+ new NullProgressMonitor());
+ assertThat(reviewerResult.getErrors().isEmpty(), is(false));
+ assertThat(reviewerResult.getErrors().size(), is(1));
+ assertThat(reviewerResult.getErrors().get(0).getName(), is("foo"));
+ }
+
+ @Test
+ public void testAddReviewers() throws Exception {
+ List<String> reviewers = Arrays.asList(new String[] { "tests" });
+ ReviewerResult reviewerResult = reviewHarness.client.addReviewers(reviewHarness.shortId, reviewers,
+ new NullProgressMonitor());
+ assertThat(reviewerResult.getErrors().isEmpty(), is(true));
+ }
+
+ @Test
+ public void testAddReviewersByEmail() throws Exception {
+ List<String> reviewers = Arrays.asList(new String[] { "tests@mylyn.eclipse.org" });
+ ReviewerResult reviewerResult = reviewHarness.client.addReviewers(reviewHarness.shortId, reviewers,
+ new NullProgressMonitor());
+ assertThat(reviewerResult.getErrors().isEmpty(), is(true));
+ }
}