Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2017-06-19 16:29:49 +0000
committerTomasz Zarna2017-06-20 05:47:55 +0000
commit951682dd471b6cb737b2b9b9fb7aaa4851926d5a (patch)
tree1f541b857703fc423c6c09e8da2d06671002e269
parentc8df13624f98ba54b2b5e1d98648dbd236d052ad (diff)
downloadorg.eclipse.mylyn.reviews-951682dd471b6cb737b2b9b9fb7aaa4851926d5a.tar.gz
org.eclipse.mylyn.reviews-951682dd471b6cb737b2b9b9fb7aaa4851926d5a.tar.xz
org.eclipse.mylyn.reviews-951682dd471b6cb737b2b9b9fb7aaa4851926d5a.zip
500541: Opening and synchronizing review always causes patch set
contents to be retrieved Change-Id: Ib6c3df3618ae364d548d6a4ff7f6b34fcb3d4997 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=500541
-rw-r--r--org.eclipse.mylyn.gerrit.core.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java65
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactory.java17
2 files changed, 73 insertions, 9 deletions
diff --git a/org.eclipse.mylyn.gerrit.core.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java b/org.eclipse.mylyn.gerrit.core.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java
new file mode 100644
index 000000000..2a0032fc5
--- /dev/null
+++ b/org.eclipse.mylyn.gerrit.core.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.gerrit.core.remote;
+
+import static java.util.Collections.emptyList;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.mylyn.reviews.core.model.IChange;
+import org.junit.Test;
+
+import com.google.gerrit.common.data.ChangeInfo;
+import com.google.gerrit.reviewdb.Change.Id;
+
+@SuppressWarnings("restriction")
+public class GerritReviewRemoteFactoryTest {
+ @Test
+ public void isDependenciesDifferent() throws Exception {
+ GerritReviewRemoteFactory factory = new GerritReviewRemoteFactory(mock(GerritRemoteFactoryProvider.class));
+
+ assertFalse(factory.isDependenciesDifferent(emptyList(), emptyList()));
+ assertFalse(factory.isDependenciesDifferent(changes(1), changeInfos(1)));
+ assertFalse(factory.isDependenciesDifferent(changes(1, 2, 3), changeInfos(3, 1, 2)));
+
+ assertTrue(factory.isDependenciesDifferent(changes(1), emptyList()));
+ assertTrue(factory.isDependenciesDifferent(emptyList(), changeInfos(1)));
+ assertTrue(factory.isDependenciesDifferent(changes(1), changeInfos(2)));
+ assertTrue(factory.isDependenciesDifferent(changes(1), changeInfos(2, 3)));
+ assertTrue(factory.isDependenciesDifferent(changes(1, 2), changeInfos(2, 3)));
+ }
+
+ private static List<IChange> changes(int... ids) {
+ List<IChange> result = new ArrayList<>(ids.length);
+ for (int id : ids) {
+ IChange change = mock(IChange.class);
+ when(change.getId()).thenReturn(Integer.toString(id));
+ result.add(change);
+ }
+ return result;
+ }
+
+ private static List<ChangeInfo> changeInfos(int... ids) {
+ List<ChangeInfo> result = new ArrayList<>(ids.length);
+ for (int id : ids) {
+ ChangeInfo changeInfo = mock(ChangeInfo.class);
+ when(changeInfo.getId()).thenReturn(new Id(id));
+ result.add(changeInfo);
+ }
+ return result;
+ }
+}
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactory.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactory.java
index 675d98376..0820d1e60 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactory.java
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactory.java
@@ -67,7 +67,7 @@ import com.google.gerrit.reviewdb.UserIdentity;
/**
* Manages retrieval of Review information from Gerrit API. Also creates, adds, and updates contents of review sets for
* each patch set, but does not retrieve the patch set details or contents.
- *
+ *
* @author Miles Parker
* @author Steffen Pingel
*/
@@ -137,9 +137,8 @@ public class GerritReviewRemoteFactory extends ReviewRemoteFactory<GerritChange,
pull(parent, detail, detail.getNeededBy(), monitor);
return gerritChange;
} catch (GerritException e) {
- throw GerritCorePlugin.getDefault()
- .getConnector()
- .toCoreException(parent.getTaskRepository(), "Problem while retrieving Gerrit review.", e); //$NON-NLS-1$
+ throw GerritCorePlugin.getDefault().getConnector().toCoreException(parent.getTaskRepository(),
+ "Problem while retrieving Gerrit review.", e); //$NON-NLS-1$
}
}
@@ -194,7 +193,7 @@ public class GerritReviewRemoteFactory extends ReviewRemoteFactory<GerritChange,
for (ChangeInfo depend : remoteDependencies) {
remoteIds.add(depend.getId().toString());
}
- return !localIds.equals(remoteDependencies);
+ return !localIds.equals(remoteIds);
}
@Override
@@ -289,8 +288,8 @@ public class GerritReviewRemoteFactory extends ReviewRemoteFactory<GerritChange,
int patchIndex = 0;
PatchSetDetailRemoteFactory itemSetFactory = getGerritProvider().getReviewItemSetFactory();
for (PatchSetDetail patchSetDetail : gerritChange.getPatchSetDetails()) {
- RemoteEmfConsumer<IReview, IReviewItemSet, String, PatchSetDetail, PatchSetDetail, String> consumer = itemSetFactory.getConsumerForRemoteObject(
- review, patchSetDetail);
+ RemoteEmfConsumer<IReview, IReviewItemSet, String, PatchSetDetail, PatchSetDetail, String> consumer = itemSetFactory
+ .getConsumerForRemoteObject(review, patchSetDetail);
try {
//We force a pull here, which is safe because there isn't any actual client API invocation
consumer.pull(true, new NullProgressMonitor());
@@ -388,8 +387,8 @@ public class GerritReviewRemoteFactory extends ReviewRemoteFactory<GerritChange,
reviewerEntry = IReviewsFactory.INSTANCE.createReviewerEntry();
review.getReviewerApprovals().put(reviewer, reviewerEntry);
}
- for (Entry<com.google.gerrit.reviewdb.ApprovalCategory.Id, PatchSetApproval> remoteMap : remoteApproval.getApprovalMap()
- .entrySet()) {
+ for (Entry<com.google.gerrit.reviewdb.ApprovalCategory.Id, PatchSetApproval> remoteMap : remoteApproval
+ .getApprovalMap().entrySet()) {
String remoteType = remoteMap.getValue().getCategoryId().get();
IApprovalType approvalType = typeForKey.get(remoteType);
if (approvalType == null) {

Back to the top