Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Dirix2014-11-03 10:02:02 +0000
committerAxel RICHARD2014-11-18 10:39:42 +0000
commit55535eef16b426b522941e3c1be7bd72d14d61cb (patch)
tree8bb2c3c02e72e581d186f355a7836a4bf9d94ab3 /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests
parentf85ecd1378cfd6152682cff6b5d5e7a0ee825dd6 (diff)
downloadorg.eclipse.emf.compare-55535eef16b426b522941e3c1be7bd72d14d61cb.tar.gz
org.eclipse.emf.compare-55535eef16b426b522941e3c1be7bd72d14d61cb.tar.xz
org.eclipse.emf.compare-55535eef16b426b522941e3c1be7bd72d14d61cb.zip
[441172] Extend findMasterEquivalence to not only check eOpposites
Currently the findMasterEquivalence method only considers equivalences whose reference is the eOpposite of the given diff. But sometimes the equivalence's reference is the same as the one given by the diff. The findMasterEquivalence method is extended to handle these cases too. Includes testcases for this issue. Bug: 441172 Signed-off-by: Stefan Dirix <sdirix@eclipsesource.com> Also-by: Laurent Goubet <laurent.goubet@obeo.fr> Change-Id: Ic3678939c0798c9993c41d329f6c0d4e4d098c27
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/EquiInputData.java8
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/left.nodes11
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/right.nodes10
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/MultipleMergeTest.java70
4 files changed, 97 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/EquiInputData.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/EquiInputData.java
index 593f669ae..1d8a3a0c5 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/EquiInputData.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/EquiInputData.java
@@ -105,6 +105,14 @@ public class EquiInputData extends AbstractInputData {
return loadFromClassLoader("c6/right.nodes"); //$NON-NLS-1$
}
+ public Resource getC7Left() throws IOException {
+ return loadFromClassLoader("c7/left.nodes"); //$NON-NLS-1$
+ }
+
+ public Resource getC7Right() throws IOException {
+ return loadFromClassLoader("c7/right.nodes"); //$NON-NLS-1$
+ }
+
public Resource getD1Left() throws IOException {
return loadFromClassLoader("d1/left.nodes"); //$NON-NLS-1$
}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/left.nodes
new file mode 100644
index 000000000..518c8a03a
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/left.nodes
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_root"
+ name="Root">
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToMany" name="a" source="b"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToMany" name="b" destination="a"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/right.nodes
new file mode 100644
index 000000000..6bef905e6
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/equi/data/c7/right.nodes
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_root"
+ name="Root">
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToMany" name="a" source="a" destination="a"/>
+</nodes:Node>
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 b168b18fe..8fb7477bb 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
@@ -1123,7 +1123,7 @@ public class MultipleMergeTest {
*/
mergerRegistry.getHighestRankingMerger(unsetDiff).copyLeftToRight(unsetDiff, new BasicMonitor());
- // merge the remaining diffsS
+ // merge the remaining differences
for (Diff diff : differences) {
if (diff != unsetDiff) {
mergerRegistry.getHighestRankingMerger(diff).copyLeftToRight(diff, new BasicMonitor());
@@ -1157,7 +1157,7 @@ public class MultipleMergeTest {
*/
mergerRegistry.getHighestRankingMerger(unsetDiff).copyRightToLeft(unsetDiff, new BasicMonitor());
- // merge the remaining diffsS
+ // merge the remaining differences
for (Diff diff : differences) {
if (diff != unsetDiff) {
mergerRegistry.getHighestRankingMerger(diff).copyRightToLeft(diff, new BasicMonitor());
@@ -1170,6 +1170,72 @@ public class MultipleMergeTest {
}
@Test
+ public void testEquivalenceC7LtoR() throws IOException {
+ final Resource left = equivalenceInput.getC7Left();
+ final Resource right = equivalenceInput.getC7Right();
+
+ final IComparisonScope scope = new DefaultComparisonScope(left, right, null);
+ Comparison comparison = EMFCompare.builder().build().compare(scope);
+
+ final List<Diff> differences = comparison.getDifferences();
+ assertEquals(4, differences.size());
+
+ final ReferenceChange deleteDiff = (ReferenceChange)Iterators.find(differences.iterator(),
+ removedFromReference("Root.a", "destination", "Root.a"));
+
+ /*
+ * Merge the deleteDiff first. If the merger blindly merges the deleteDiff without proper looking at
+ * its equivalences, the equivalences will also be set to status "merged" although the reference to be
+ * added is still missing.
+ */
+ mergerRegistry.getHighestRankingMerger(deleteDiff).copyLeftToRight(deleteDiff, new BasicMonitor());
+
+ // merge the remaining differences
+ for (Diff diff : differences) {
+ if (diff != deleteDiff) {
+ mergerRegistry.getHighestRankingMerger(diff).copyLeftToRight(diff, new BasicMonitor());
+ }
+ }
+
+ // check if no differences between models are left
+ comparison = EMFCompare.builder().build().compare(scope);
+ assertEquals(0, comparison.getDifferences().size());
+ }
+
+ @Test
+ public void testEquivalenceC7RtoL() throws IOException {
+ final Resource left = equivalenceInput.getC7Left();
+ final Resource right = equivalenceInput.getC7Right();
+
+ final IComparisonScope scope = new DefaultComparisonScope(left, right, null);
+ Comparison comparison = EMFCompare.builder().build().compare(scope);
+
+ final List<Diff> differences = comparison.getDifferences();
+ assertEquals(4, differences.size());
+
+ final ReferenceChange deleteDiff = (ReferenceChange)Iterators.find(differences.iterator(),
+ addedToReference("Root.b", "destination", "Root.a"));
+
+ /*
+ * Merge the diff resulting in a delete first. If the merger blindly merges the deleteDiff without
+ * proper looking at its equivalences, the equivalences will also be set to status "merged" although
+ * the reference to be added is still missing.
+ */
+ mergerRegistry.getHighestRankingMerger(deleteDiff).copyRightToLeft(deleteDiff, new BasicMonitor());
+
+ // merge the remaining differences
+ for (Diff diff : differences) {
+ if (diff != deleteDiff) {
+ mergerRegistry.getHighestRankingMerger(diff).copyRightToLeft(diff, new BasicMonitor());
+ }
+ }
+
+ // check if no differences between models are left
+ comparison = EMFCompare.builder().build().compare(scope);
+ assertEquals(0, comparison.getDifferences().size());
+ }
+
+ @Test
public void testMergeAllDiffsTwice() throws IOException {
final IdentifierMatchInputData inputData = new IdentifierMatchInputData();
final Resource left = inputData.getExtlibraryLeft();

Back to the top