summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2013-07-30 15:22:03 (EDT)
committerTomasz Zarna2013-07-30 15:22:03 (EDT)
commit5766380b634ae09b958ad9aa206cc26f1c9e61fe (patch)
treecd2af3d88ea69900d241b3e89c7460ab3d929b62
parent604edce1d17845034a9f10dcd19a698d772bde30 (diff)
downloadorg.eclipse.mylyn.reviews-5766380b634ae09b958ad9aa206cc26f1c9e61fe.zip
org.eclipse.mylyn.reviews-5766380b634ae09b958ad9aa206cc26f1c9e61fe.tar.gz
org.eclipse.mylyn.reviews-5766380b634ae09b958ad9aa206cc26f1c9e61fe.tar.bz2
395059: fix GerritReviewRemoteFactoryTest.testRestoreNewChange on 2.4.4refs/changes/89/14989/1
Bug: 395059 Change-Id: Idfcf1a982e6df90743d00cd67b30af09521fdbea Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=395059 Signed-off-by: Tomasz Zarna <tomasz.zarna@tasktop.com>
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritVersion.java8
-rw-r--r--org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritVersionTest.java17
-rw-r--r--org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java20
3 files changed, 39 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritVersion.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritVersion.java
index aa4c144..1a63ed6 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritVersion.java
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritVersion.java
@@ -21,6 +21,10 @@ import org.osgi.framework.Version;
public class GerritVersion extends Version {
+ private static final Version VERSION_2_4_0 = new Version(2, 4, 0);
+
+ private static final Version VERSION_2_5_0 = new Version(2, 5, 0);
+
private static final Version VERSION_2_6_0 = new Version(2, 6, 0);
private static final Version VERSION_2_7_0 = new Version(2, 7, 0);
@@ -65,4 +69,8 @@ public class GerritVersion extends Version {
public static boolean isVersion27OrLater(Version version) {
return version.compareTo(VERSION_2_7_0) >= 0;
}
+
+ public static boolean isVersion24x(Version version) {
+ return version.compareTo(VERSION_2_4_0) >= 0 && version.compareTo(VERSION_2_5_0) < 0;
+ }
}
diff --git a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritVersionTest.java b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritVersionTest.java
index 1316592..71c62f3 100644
--- a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritVersionTest.java
+++ b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritVersionTest.java
@@ -11,6 +11,7 @@
package org.eclipse.mylyn.gerrit.tests.core.client;
+import static org.eclipse.mylyn.internal.gerrit.core.client.GerritVersion.isVersion24x;
import static org.eclipse.mylyn.internal.gerrit.core.client.GerritVersion.isVersion26OrLater;
import static org.eclipse.mylyn.internal.gerrit.core.client.GerritVersion.parseGerritVersion;
import junit.framework.TestCase;
@@ -106,4 +107,20 @@ public class GerritVersionTest extends TestCase {
assertTrue(isVersion26OrLater(parseGerritVersion("2.6.1")));
assertTrue(isVersion26OrLater(parseGerritVersion("2.6.1-q")));
}
+
+ @Test
+ public void testIsVersion24x() throws Exception {
+ assertFalse(isVersion24x(parseGerritVersion("2.3.9")));
+ assertFalse(isVersion24x(parseGerritVersion("2.3.9-q")));
+ assertTrue(isVersion24x(parseGerritVersion("2.4")));
+ assertTrue(isVersion24x(parseGerritVersion("2.4-q")));
+ assertTrue(isVersion24x(parseGerritVersion("2.4.0")));
+ assertTrue(isVersion24x(parseGerritVersion("2.4.0-q")));
+ assertTrue(isVersion24x(parseGerritVersion("2.4.1")));
+ assertTrue(isVersion24x(parseGerritVersion("2.4.1-q")));
+ assertFalse(isVersion24x(parseGerritVersion("2.5")));
+ assertFalse(isVersion24x(parseGerritVersion("2.5-q")));
+ assertFalse(isVersion24x(parseGerritVersion("2.5.0")));
+ assertFalse(isVersion24x(parseGerritVersion("2.5.0-q")));
+ }
}
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 59f52a9..e864535 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
@@ -136,7 +136,7 @@ public class GerritReviewRemoteFactoryTest extends GerritRemoteTest {
@Test
public void testApprovals() throws Exception {
- int approvals = isVersion26rLater() ? 1 : 2;
+ int approvals = isVersion26OrLater() ? 1 : 2;
assertThat(reviewHarness.getRepository().getApprovalTypes().size(), is(approvals));
IApprovalType codeReviewApproval = reviewHarness.getRepository().getApprovalTypes().get(approvals - 1);
assertThat(codeReviewApproval.getKey(), is(CRVW.getCategory().getId().get()));
@@ -162,7 +162,7 @@ public class GerritReviewRemoteFactoryTest extends GerritRemoteTest {
assertThat(codeReviewEntry, notNullValue());
assertThat(codeReviewEntry.getBy(), nullValue());
assertThat(codeReviewEntry.getStatus(), is(RequirementStatus.NOT_SATISFIED));
- if (!isVersion26rLater()) {
+ if (!isVersion26OrLater()) {
IApprovalType verifyApproval = reviewHarness.getRepository().getApprovalTypes().get(0);
assertThat(verifyApproval.getKey(), is(VRIF.getCategory().getId().get()));
assertThat(verifyApproval.getName(), is(VRIF.getCategory().getName()));
@@ -266,7 +266,11 @@ public class GerritReviewRemoteFactoryTest extends GerritRemoteTest {
reviewHarness.client.restore(reviewHarness.shortId, 1, message1, new NullProgressMonitor());
fail("Expected to fail when restoring a new change");
} catch (GerritException e) {
- assertThat(e.getMessage(), is("Not Found"));
+ if (isVersion24x()) {
+ assertThat(e.getMessage(), is("Change is not abandoned or patchset is not latest"));
+ } else {
+ assertThat(e.getMessage(), is("Not Found"));
+ }
}
}
@@ -420,7 +424,7 @@ public class GerritReviewRemoteFactoryTest extends GerritRemoteTest {
@Test
public void testGetChangeInfo() throws Exception {
- if (!isVersion26rLater()) {
+ if (!isVersion26OrLater()) {
return; // testing Gerrit REST API, available in 2.6 and later
}
int reviewId = Integer.parseInt(reviewHarness.shortId);
@@ -442,7 +446,7 @@ public class GerritReviewRemoteFactoryTest extends GerritRemoteTest {
.getId())), new NullProgressMonitor());
fail("Expected to fail when trying to vote +2 when it's not permitted");
} catch (GerritException e) {
- if (isVersion26rLater()) {
+ if (isVersion26OrLater()) {
assertEquals("Applying label \"Code-Review\": 2 is restricted", e.getMessage());
} else {
assertEquals("Code-Review=2 not permitted", e.getMessage());
@@ -451,7 +455,11 @@ public class GerritReviewRemoteFactoryTest extends GerritRemoteTest {
}
}
- private boolean isVersion26rLater() throws GerritException {
+ private boolean isVersion26OrLater() throws GerritException {
return GerritVersion.isVersion26OrLater(reviewHarness.client.getVersion(new NullProgressMonitor()));
}
+
+ private boolean isVersion24x() throws GerritException {
+ return GerritVersion.isVersion24x(reviewHarness.client.getVersion(new NullProgressMonitor()));
+ }
}