Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Delaigue2017-02-02 08:32:25 -0500
committerLaurent Delaigue2017-03-14 05:55:56 -0400
commitb1ff6cc006e1fb1160d4aeccd9bfdf49b1d39a92 (patch)
treecdf058e62107da1de5840b9392d61a3b4828b60c /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare
parentb599b8cd35475a5485b939ab0511f079484906e0 (diff)
downloadorg.eclipse.emf.compare-b1ff6cc006e1fb1160d4aeccd9bfdf49b1d39a92.tar.gz
org.eclipse.emf.compare-b1ff6cc006e1fb1160d4aeccd9bfdf49b1d39a92.tar.xz
org.eclipse.emf.compare-b1ff6cc006e1fb1160d4aeccd9bfdf49b1d39a92.zip
Improve final state and MergeData when merging
Mergers now properly set the final state of diffs according to whether they were accepted or rejected. We now install a DiffStateAdapter on the comparison and all its diffs to listen to diff state changes and update MergeData accordingly. Change-Id: Ib0945557e4a90feab82280a773ab49237e31c0ce Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/ResourceAttachmentChangeBug492261.java18
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/ConflictMergeTest.java157
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/MultipleMergeTest.java59
3 files changed, 124 insertions, 110 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/ResourceAttachmentChangeBug492261.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/ResourceAttachmentChangeBug492261.java
index 3be135c9b..fb501180b 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/ResourceAttachmentChangeBug492261.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/fragmentation/ResourceAttachmentChangeBug492261.java
@@ -178,8 +178,8 @@ public class ResourceAttachmentChangeBug492261 {
} else {
batchMerger.copyAllLeftToRight(Arrays.asList(rac), new BasicMonitor());
}
- assertEquals(DifferenceState.MERGED, rac.getState());
- assertEquals(DifferenceState.MERGED, container.getState());
+ assertEquals(DifferenceState.DISCARDED, rac.getState());
+ assertEquals(DifferenceState.DISCARDED, container.getState());
assertEquals(DifferenceState.UNRESOLVED, innerNode.getState());
if (fragmentedOnLeft) {
@@ -187,9 +187,9 @@ public class ResourceAttachmentChangeBug492261 {
} else {
batchMerger.copyAllLeftToRight(Arrays.asList(innerNode), new BasicMonitor());
}
- assertEquals(DifferenceState.MERGED, rac.getState());
- assertEquals(DifferenceState.MERGED, container.getState());
- assertEquals(DifferenceState.MERGED, innerNode.getState());
+ assertEquals(DifferenceState.DISCARDED, rac.getState());
+ assertEquals(DifferenceState.DISCARDED, container.getState());
+ assertEquals(DifferenceState.DISCARDED, innerNode.getState());
comparison = EMFCompare.builder().build().compare(scope);
assertEquals(0, comparison.getDifferences().size());
@@ -229,7 +229,7 @@ public class ResourceAttachmentChangeBug492261 {
} else {
batchMerger.copyAllLeftToRight(Arrays.asList(rac), new BasicMonitor());
}
- assertEquals(DifferenceState.MERGED, rac.getState());
+ assertEquals(DifferenceState.DISCARDED, rac.getState());
assertEquals(DifferenceState.UNRESOLVED, container.getState());
assertEquals(DifferenceState.UNRESOLVED, innerNode.getState());
@@ -238,9 +238,9 @@ public class ResourceAttachmentChangeBug492261 {
} else {
batchMerger.copyAllLeftToRight(Arrays.asList(container), new BasicMonitor());
}
- assertEquals(DifferenceState.MERGED, rac.getState());
- assertEquals(DifferenceState.MERGED, container.getState());
- assertEquals(DifferenceState.MERGED, innerNode.getState());
+ assertEquals(DifferenceState.DISCARDED, rac.getState());
+ assertEquals(DifferenceState.DISCARDED, container.getState());
+ assertEquals(DifferenceState.DISCARDED, innerNode.getState());
comparison = EMFCompare.builder().build().compare(scope);
assertEquals(0, comparison.getDifferences().size());
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/ConflictMergeTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/ConflictMergeTest.java
index 9662ce0e2..065df3985 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/ConflictMergeTest.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/ConflictMergeTest.java
@@ -12,6 +12,10 @@ package org.eclipse.emf.compare.tests.merge;
import static com.google.common.base.Predicates.and;
import static com.google.common.base.Predicates.not;
+import static org.eclipse.emf.compare.DifferenceState.DISCARDED;
+import static org.eclipse.emf.compare.DifferenceState.MERGED;
+import static org.eclipse.emf.compare.DifferenceState.UNRESOLVED;
+import static org.eclipse.emf.compare.merge.AbstractMerger.isInTerminalState;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.addedToAttribute;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.fromSide;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.hasState;
@@ -39,7 +43,6 @@ import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.DifferenceKind;
import org.eclipse.emf.compare.DifferenceSource;
-import org.eclipse.emf.compare.DifferenceState;
import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.compare.merge.BatchMerger;
import org.eclipse.emf.compare.merge.IMerger;
@@ -119,12 +122,12 @@ public class ConflictMergeTest {
final EList<Node> bContainmentRef1s = ((Node)rightNodeB).getContainmentRef1();
assertFalse(bContainmentRef1s.contains(rightNodeC));
- assertEquals(DifferenceState.MERGED, diffNodeCLeft.getState());
- assertEquals(DifferenceState.MERGED, diffNodeCRight.getState());
- assertEquals(DifferenceState.MERGED, diffNodeDLeft.getState());
- assertEquals(DifferenceState.MERGED, diffNodeDRight.getState());
- assertEquals(DifferenceState.UNRESOLVED, diffNodeELeft.getState());
- assertEquals(DifferenceState.MERGED, diffNodeFRight.getState());
+ assertEquals(MERGED, diffNodeCLeft.getState());
+ assertEquals(DISCARDED, diffNodeCRight.getState());
+ assertEquals(MERGED, diffNodeDLeft.getState());
+ assertEquals(MERGED, diffNodeDRight.getState());
+ assertEquals(UNRESOLVED, diffNodeELeft.getState());
+ assertEquals(DISCARDED, diffNodeFRight.getState());
}
@SuppressWarnings("unchecked")
@@ -182,12 +185,12 @@ public class ConflictMergeTest {
final EList<Node> bContainmentRef1s = ((Node)rightNodeB).getContainmentRef1();
assertFalse(bContainmentRef1s.contains(rightNodeC));
- assertEquals(DifferenceState.UNRESOLVED, diffNodeCLeft.getState());
- assertEquals(DifferenceState.MERGED, diffNodeCRight.getState());
- assertEquals(DifferenceState.MERGED, diffNodeDLeft.getState());
- assertEquals(DifferenceState.MERGED, diffNodeDRight.getState());
- assertEquals(DifferenceState.UNRESOLVED, diffNodeELeft.getState());
- assertEquals(DifferenceState.MERGED, diffNodeFRight.getState());
+ assertEquals(UNRESOLVED, diffNodeCLeft.getState());
+ assertEquals(MERGED, diffNodeCRight.getState());
+ assertEquals(MERGED, diffNodeDLeft.getState());
+ assertEquals(MERGED, diffNodeDRight.getState());
+ assertEquals(UNRESOLVED, diffNodeELeft.getState());
+ assertEquals(MERGED, diffNodeFRight.getState());
}
@SuppressWarnings("unchecked")
@@ -245,12 +248,12 @@ public class ConflictMergeTest {
final EList<Node> bContainmentRef1s = ((Node)leftNodeB).getContainmentRef1();
assertFalse(bContainmentRef1s.contains(leftNodeC));
- assertEquals(DifferenceState.MERGED, diffNodeCLeft.getState());
- assertEquals(DifferenceState.UNRESOLVED, diffNodeCRight.getState());
- assertEquals(DifferenceState.MERGED, diffNodeDLeft.getState());
- assertEquals(DifferenceState.MERGED, diffNodeDRight.getState());
- assertEquals(DifferenceState.MERGED, diffNodeELeft.getState());
- assertEquals(DifferenceState.UNRESOLVED, diffNodeFRight.getState());
+ assertEquals(MERGED, diffNodeCLeft.getState());
+ assertEquals(UNRESOLVED, diffNodeCRight.getState());
+ assertEquals(MERGED, diffNodeDLeft.getState());
+ assertEquals(MERGED, diffNodeDRight.getState());
+ assertEquals(MERGED, diffNodeELeft.getState());
+ assertEquals(UNRESOLVED, diffNodeFRight.getState());
}
@SuppressWarnings("unchecked")
@@ -307,12 +310,12 @@ public class ConflictMergeTest {
final EList<Node> bContainmentRef1s = ((Node)leftNodeB).getContainmentRef1();
assertTrue(bContainmentRef1s.contains(leftNodeC));
- assertEquals(DifferenceState.MERGED, diffNodeCLeft.getState());
- assertEquals(DifferenceState.MERGED, diffNodeCRight.getState());
- assertEquals(DifferenceState.MERGED, diffNodeDLeft.getState());
- assertEquals(DifferenceState.MERGED, diffNodeDRight.getState());
- assertEquals(DifferenceState.MERGED, diffNodeELeft.getState());
- assertEquals(DifferenceState.UNRESOLVED, diffNodeFRight.getState());
+ assertEquals(DISCARDED, diffNodeCLeft.getState());
+ assertEquals(MERGED, diffNodeCRight.getState());
+ assertEquals(MERGED, diffNodeDLeft.getState());
+ assertEquals(MERGED, diffNodeDRight.getState());
+ assertEquals(DISCARDED, diffNodeELeft.getState());
+ assertEquals(UNRESOLVED, diffNodeFRight.getState());
}
@Test
@@ -345,7 +348,7 @@ public class ConflictMergeTest {
final EList<EClass> eSuperTypes = ((EClass)rightEClassA).getESuperTypes();
assertTrue(eSuperTypes.contains(rightEClassB));
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -379,9 +382,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.RIGHT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -420,7 +423,7 @@ public class ConflictMergeTest {
assertTrue(featureValue instanceof Collection<?>);
assertTrue(((Collection<?>)featureValue).containsAll(Lists.newArrayList(NodeEnum.A, NodeEnum.B)));
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -442,7 +445,7 @@ public class ConflictMergeTest {
final EObject rightElement = getNodeNamed(left, "origin");
assertNull(rightElement);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -476,9 +479,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.LEFT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -513,7 +516,7 @@ public class ConflictMergeTest {
final EList<EClass> eSuperTypes = ((EClass)leftEClassA).getESuperTypes();
assertTrue(eSuperTypes.isEmpty());
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -546,7 +549,7 @@ public class ConflictMergeTest {
final EList<EClass> eSuperTypes = ((EClass)rightEClassA).getESuperTypes();
assertTrue(eSuperTypes.isEmpty());
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -580,9 +583,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.RIGHT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -618,9 +621,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.LEFT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -655,7 +658,7 @@ public class ConflictMergeTest {
final EList<EClass> eSuperTypes = ((EClass)leftEClassA).getESuperTypes();
assertTrue(eSuperTypes.contains(leftEClassB));
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -682,7 +685,7 @@ public class ConflictMergeTest {
final EObject rightEClassA = getNodeNamed(right, "A");
assertNull(rightEClassA);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -722,9 +725,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.RIGHT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -757,9 +760,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.LEFT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -799,7 +802,7 @@ public class ConflictMergeTest {
assertTrue(((EClass)leftEClassA).isAbstract());
assertTrue(((EClass)leftEClassA).isInterface());
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -837,7 +840,7 @@ public class ConflictMergeTest {
assertTrue(((EClass)rightEClassA).isAbstract());
assertTrue(((EClass)rightEClassA).isInterface());
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -868,9 +871,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.RIGHT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -912,9 +915,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.LEFT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -943,7 +946,7 @@ public class ConflictMergeTest {
final EObject leftEClassA = getNodeNamed(left, "A");
assertNull(leftEClassA);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -976,7 +979,7 @@ public class ConflictMergeTest {
assertNotNull(eType);
assertEquals(eType.getName(), "EBoolean");
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -1011,9 +1014,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.RIGHT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -1050,9 +1053,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.LEFT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -1086,7 +1089,7 @@ public class ConflictMergeTest {
final EClassifier eType = ((EAttribute)leftEAttributeName).getEType();
assertNull(eType);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -1118,7 +1121,7 @@ public class ConflictMergeTest {
final EClassifier eType = ((EAttribute)rightEAttributeName).getEType();
assertNull(eType);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -1153,9 +1156,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.RIGHT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -1192,9 +1195,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.LEFT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -1229,7 +1232,7 @@ public class ConflictMergeTest {
assertNotNull(eType);
assertEquals(eType.getName(), "EBoolean");
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -1256,7 +1259,7 @@ public class ConflictMergeTest {
final EObject rightEClassB = getNodeNamed(right, "B");
assertNull(rightEClassB);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -1299,9 +1302,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.RIGHT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -1346,9 +1349,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.LEFT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -1390,7 +1393,7 @@ public class ConflictMergeTest {
.getEStructuralFeature("name");
assertNull(eStructuralFeatureNameA);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -1436,7 +1439,7 @@ public class ConflictMergeTest {
.getEStructuralFeature("name");
assertNotNull(eStructuralFeatureNameB);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -1484,9 +1487,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.RIGHT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -1536,9 +1539,9 @@ public class ConflictMergeTest {
for (Diff currentDiff : differences) {
if (currentDiff.getSource() == DifferenceSource.LEFT) {
- assertTrue(currentDiff.getState() == DifferenceState.MERGED);
+ assertTrue(isInTerminalState(currentDiff));
} else {
- assertTrue(currentDiff.getState() == DifferenceState.UNRESOLVED);
+ assertTrue(currentDiff.getState() == UNRESOLVED);
}
}
}
@@ -1581,7 +1584,7 @@ public class ConflictMergeTest {
.getEStructuralFeature("name");
assertNull(eStructuralFeatureNameA);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -1615,7 +1618,7 @@ public class ConflictMergeTest {
final Object leftValue = leftNode.eGet(feature);
assertEquals(NodeEnum.B, leftValue);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
@Test
@@ -1649,7 +1652,7 @@ public class ConflictMergeTest {
final Object leftValue = leftNode.eGet(feature);
assertEquals(NodeEnum.C, leftValue);
- assertFalse(Iterators.any(differences.iterator(), not(hasState(DifferenceState.MERGED))));
+ assertFalse(Iterators.any(differences.iterator(), not(hasState(MERGED, DISCARDED))));
}
private EObject getNodeNamed(Resource res, String name) {
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/MultipleMergeTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/MultipleMergeTest.java
index fe9e57c90..5fd092574 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/MultipleMergeTest.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/MultipleMergeTest.java
@@ -441,17 +441,17 @@ public class MultipleMergeTest {
batchMerger.copyAllRightToLeft(Arrays.asList(diff1), new BasicMonitor());
// Check that diff1 got properly merged (we're unsetting values)
- assertMerged(comparison, diff1, true, true);
+ assertDiscarded(comparison, diff1, true, true);
// And validate that diff2 got merged as an equivalent diff
- assertMerged(comparison, diff2, true, true);
+ assertDiscarded(comparison, diff2, true, true);
batchMerger.copyAllRightToLeft(Arrays.asList(diff3), new BasicMonitor());
- assertMerged(comparison, diff3, true, true);
- assertMerged(comparison, diff4, true, true);
+ assertDiscarded(comparison, diff3, true, true);
+ assertDiscarded(comparison, diff4, true, true);
batchMerger.copyAllRightToLeft(Arrays.asList(diff5), new BasicMonitor());
- assertMerged(comparison, diff5, true, true);
- assertMerged(comparison, diff6, true, true);
+ assertDiscarded(comparison, diff5, true, true);
+ assertDiscarded(comparison, diff6, true, true);
comparison = EMFCompare.builder().build().compare(scope);
assertEquals(0, comparison.getDifferences().size());
@@ -520,12 +520,12 @@ public class MultipleMergeTest {
addedToReference("Requirements.A", "source", "Requirements.B"));
batchMerger.copyAllRightToLeft(Arrays.asList(diff1), new BasicMonitor());
- assertMerged(comparison, diff1, true, true);
- assertMerged(comparison, diff2, true, true);
+ assertDiscarded(comparison, diff1, true, true);
+ assertDiscarded(comparison, diff2, true, true);
batchMerger.copyAllRightToLeft(Arrays.asList(diff3), new BasicMonitor());
- assertMerged(comparison, diff3, true, true);
- assertMerged(comparison, diff4, true, true);
+ assertDiscarded(comparison, diff3, true, true);
+ assertDiscarded(comparison, diff4, true, true);
comparison = EMFCompare.builder().build().compare(scope);
assertEquals(0, comparison.getDifferences().size());
@@ -650,20 +650,20 @@ public class MultipleMergeTest {
// Removing the link between A and B does not necessarily means removing A and B
// The "required" diffs will ne be merged
batchMerger.copyAllRightToLeft(Arrays.asList(diff1), new BasicMonitor());
- assertMerged(comparison, diff1, true, true);
- assertMerged(comparison, diff2, true, true);
+ assertDiscarded(comparison, diff1, true, true);
+ assertDiscarded(comparison, diff2, true, true);
assertSame(DifferenceState.UNRESOLVED, diff7.getState());
assertSame(DifferenceState.UNRESOLVED, diff8.getState());
batchMerger.copyAllRightToLeft(Arrays.asList(diff3), new BasicMonitor());
- assertMerged(comparison, diff3, true, true);
- assertMerged(comparison, diff4, true, true);
+ assertDiscarded(comparison, diff3, true, true);
+ assertDiscarded(comparison, diff4, true, true);
assertSame(DifferenceState.UNRESOLVED, diff9.getState());
assertSame(DifferenceState.UNRESOLVED, diff10.getState());
batchMerger.copyAllRightToLeft(Arrays.asList(diff5), new BasicMonitor());
- assertMerged(comparison, diff5, true, true);
- assertMerged(comparison, diff6, true, true);
+ assertDiscarded(comparison, diff5, true, true);
+ assertDiscarded(comparison, diff6, true, true);
assertSame(DifferenceState.UNRESOLVED, diff11.getState());
assertSame(DifferenceState.UNRESOLVED, diff12.getState());
@@ -790,8 +790,8 @@ public class MultipleMergeTest {
batchMerger.copyAllRightToLeft(Arrays.asList(diff2), new BasicMonitor());
assertSame(DifferenceState.UNRESOLVED, diff1.getState());
- assertMerged(comparison, diff3, false, true);
- assertMerged(comparison, diff4, true, true);
+ assertDiscarded(comparison, diff3, false, true);
+ assertDiscarded(comparison, diff4, true, true);
/*
* Diff 2 is a little more complicated than the usual. We are on a mono-valued refrence, and the merge
* operation is actually resetting the value to its original state. We will need to check that.
@@ -898,18 +898,18 @@ public class MultipleMergeTest {
// 1 is required by 3, which is required by 2 and equivalent to 4 and 5.
// Resetting 1 should thus reset all other diffs.
batchMerger.copyAllRightToLeft(Arrays.asList(diff1), new BasicMonitor());
- assertMerged(comparison, diff1, true, true);
- assertMerged(comparison, diff2, false, true);
+ assertDiscarded(comparison, diff1, true, true);
+ assertDiscarded(comparison, diff2, false, true);
// C has been removed, thus the value match of diff3 has neither left nor right.
- assertSame(DifferenceState.MERGED, diff3.getState());
+ assertSame(DifferenceState.DISCARDED, diff3.getState());
final EObject nodeA = diff3.getMatch().getLeft();
final EObject nodeB = diff4.getMatch().getLeft();
assertSame(nodeB, nodeA.eGet(diff3.getReference()));
- assertMerged(comparison, diff4, false, true);
+ assertDiscarded(comparison, diff4, false, true);
- assertSame(DifferenceState.MERGED, diff5.getState());
+ assertSame(DifferenceState.DISCARDED, diff5.getState());
assertNull(diff5.getMatch().getLeft());
assertNull(diff5.getMatch().getRight());
@@ -1139,7 +1139,7 @@ public class MultipleMergeTest {
batchMerger.copyAllRightToLeft(Arrays.asList(setCSourceDiff), new BasicMonitor());
// Check if the non-equivalent diff is marked as merged
- assertEquals(DifferenceState.MERGED, setDSourceDiff.getState());
+ assertEquals(DifferenceState.DISCARDED, setDSourceDiff.getState());
// Check if no differences between models are left
comparison = EMFCompare.builder().build().compare(scope);
@@ -1345,7 +1345,18 @@ public class MultipleMergeTest {
private static void assertMerged(Comparison comparison, ReferenceChange referenceChange, boolean unset,
boolean rightToLeft) {
assertSame(referenceChange.getState(), DifferenceState.MERGED);
+ checkFinalState(comparison, referenceChange, unset, rightToLeft);
+ }
+ /* NOTE : not meant for containment changes */
+ private static void assertDiscarded(Comparison comparison, ReferenceChange referenceChange, boolean unset,
+ boolean rightToLeft) {
+ assertSame(referenceChange.getState(), DifferenceState.DISCARDED);
+ checkFinalState(comparison, referenceChange, unset, rightToLeft);
+ }
+
+ private static void checkFinalState(Comparison comparison, ReferenceChange referenceChange, boolean unset,
+ boolean rightToLeft) {
final EObject container;
if (rightToLeft) {
container = referenceChange.getMatch().getLeft();

Back to the top