Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2019-07-17 08:51:07 +0000
committerlgoubet2019-07-17 09:28:03 +0000
commit1998e64ba331e977271a01a57e1e12dbb5a99148 (patch)
tree05981c5d7cb1ef0b1a1d01e50d9a7ad079e78726 /plugins/org.eclipse.emf.compare.tests/src
parentc6921d7e119909e179b5920e97739a3666110b07 (diff)
downloadorg.eclipse.emf.compare-1998e64ba331e977271a01a57e1e12dbb5a99148.tar.gz
org.eclipse.emf.compare-1998e64ba331e977271a01a57e1e12dbb5a99148.tar.xz
org.eclipse.emf.compare-1998e64ba331e977271a01a57e1e12dbb5a99148.zip
Fix detection of pseudo conflicts on single-valued attribute changes
Pseudo-conflicts on single-valued attribute changes was populated with the origin as the changed value even if the left/right side was non-null. Change-Id: Id225da76bb381a476715c9af9581cd0bc2b9e47a
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/FeatureMapMoveDiffTest.java2
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/SingleValuedAttributePseudoConflictTest.java77
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/FeatureMapMoveDiffInputData.java (renamed from plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/FeatureMapMoveDiffInputData.java)6
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/SingleValuedAttributePseudoConflictInputData.java31
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/left.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/origin.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/right.nodes4
7 files changed, 124 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/FeatureMapMoveDiffTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/FeatureMapMoveDiffTest.java
index 08b428a29..81a219ac6 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/FeatureMapMoveDiffTest.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/FeatureMapMoveDiffTest.java
@@ -26,7 +26,7 @@ import org.eclipse.emf.compare.FeatureMapChange;
import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.scope.DefaultComparisonScope;
import org.eclipse.emf.compare.scope.IComparisonScope;
-import org.eclipse.emf.compare.tests.diff.data.FeatureMapMoveDiffInputData;
+import org.eclipse.emf.compare.tests.diff.data.featuremapmove.FeatureMapMoveDiffInputData;
import org.eclipse.emf.ecore.resource.Resource;
import org.junit.Test;
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/SingleValuedAttributePseudoConflictTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/SingleValuedAttributePseudoConflictTest.java
new file mode 100644
index 000000000..20b610c8e
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/SingleValuedAttributePseudoConflictTest.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Obeo.
+ * 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:
+ * Laurent Goubet - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.diff;
+
+import static org.eclipse.emf.compare.utils.ReferenceUtil.safeEGet;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.emf.compare.AttributeChange;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Conflict;
+import org.eclipse.emf.compare.ConflictKind;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceKind;
+import org.eclipse.emf.compare.DifferenceSource;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.scope.DefaultComparisonScope;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+import org.eclipse.emf.compare.tests.diff.data.pseudoconflict.SingleValuedAttributePseudoConflictInputData;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.junit.Test;
+
+public class SingleValuedAttributePseudoConflictTest {
+ private SingleValuedAttributePseudoConflictInputData input = new SingleValuedAttributePseudoConflictInputData();
+
+ @Test
+ public void testSingleValuedAttributePseudoConflict() throws IOException {
+ Resource left = input.getSingleValueAttributePseudoConflictLeft();
+ Resource right = input.getSingleValueAttributePseudoConflictRight();
+ Resource origin = input.getSingleValueAttributePseudoConflictOrigin();
+
+ IComparisonScope scope = new DefaultComparisonScope(right, left, origin);
+ Comparison comparison = EMFCompare.builder().build().compare(scope);
+
+ // There are only two differences
+ List<Diff> differences = comparison.getDifferences();
+ assertEquals(2, differences.size());
+ Diff diff1 = differences.get(0);
+ Diff diff2 = differences.get(1);
+
+ // They constitute a single pseudo conflict
+ assertNotNull(diff1.getConflict());
+ assertEquals(diff1.getConflict(), diff2.getConflict());
+ Conflict conflict = diff1.getConflict();
+ assertEquals(ConflictKind.PSEUDO, conflict.getKind());
+
+ // They are both a CHANGE AttributeChange on opposite sides
+ assertTrue(diff1 instanceof AttributeChange);
+ assertEquals(DifferenceKind.CHANGE, diff1.getKind());
+ assertEquals(DifferenceSource.LEFT, diff1.getSource());
+ assertTrue(diff2 instanceof AttributeChange);
+ assertEquals(DifferenceKind.CHANGE, diff2.getKind());
+ assertEquals(DifferenceSource.RIGHT, diff2.getSource());
+
+ // And they have their own side as the changed value (not the origin side)
+ Match container = diff1.getMatch();
+ Object leftValue = safeEGet(container.getLeft(), ((AttributeChange)diff1).getAttribute());
+ Object rightValue = safeEGet(container.getRight(), ((AttributeChange)diff2).getAttribute());
+ assertNotNull(leftValue);
+ assertEquals(leftValue, rightValue);
+ assertEquals(leftValue, ((AttributeChange)diff1).getValue());
+ assertEquals(rightValue, ((AttributeChange)diff2).getValue());
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/FeatureMapMoveDiffInputData.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/FeatureMapMoveDiffInputData.java
index 6f88c9521..d664d8d0f 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/FeatureMapMoveDiffInputData.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/FeatureMapMoveDiffInputData.java
@@ -8,7 +8,7 @@
* Contributors:
* Stefan Dirix - initial API and implementation
*******************************************************************************/
-package org.eclipse.emf.compare.tests.diff.data;
+package org.eclipse.emf.compare.tests.diff.data.featuremapmove;
import java.io.IOException;
@@ -18,10 +18,10 @@ import org.eclipse.emf.ecore.resource.Resource;
@SuppressWarnings("nls")
public class FeatureMapMoveDiffInputData extends AbstractInputData {
public Resource getFeatureMapMoveLeft() throws IOException {
- return loadFromClassLoader("featuremapmove/left.nodes");
+ return loadFromClassLoader("left.nodes");
}
public Resource getFeatureMapMoveRight() throws IOException {
- return loadFromClassLoader("featuremapmove/right.nodes");
+ return loadFromClassLoader("right.nodes");
}
}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/SingleValuedAttributePseudoConflictInputData.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/SingleValuedAttributePseudoConflictInputData.java
new file mode 100644
index 000000000..4cdadcfb1
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/SingleValuedAttributePseudoConflictInputData.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Obeo.
+ * 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:
+ * Laurent Goubet - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.diff.data.pseudoconflict;
+
+import java.io.IOException;
+
+import org.eclipse.emf.compare.tests.framework.AbstractInputData;
+import org.eclipse.emf.ecore.resource.Resource;
+
+@SuppressWarnings("nls")
+public class SingleValuedAttributePseudoConflictInputData extends AbstractInputData {
+ public Resource getSingleValueAttributePseudoConflictLeft() throws IOException {
+ return loadFromClassLoader("left.nodes");
+ }
+
+ public Resource getSingleValueAttributePseudoConflictRight() throws IOException {
+ return loadFromClassLoader("right.nodes");
+ }
+
+ public Resource getSingleValueAttributePseudoConflictOrigin() throws IOException {
+ return loadFromClassLoader("origin.nodes");
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/left.nodes
new file mode 100644
index 000000000..27d2691d0
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/left.nodes
@@ -0,0 +1,4 @@
+<?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="_wZM5IKhyEemotbw2fRcn-w" name="model">
+ <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_yCMQMKhyEemotbw2fRcn-w" name="conflict_container" singleValuedAttribute="changedValue"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/origin.nodes
new file mode 100644
index 000000000..c58414932
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/origin.nodes
@@ -0,0 +1,4 @@
+<?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="_wZM5IKhyEemotbw2fRcn-w" name="model">
+ <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_yCMQMKhyEemotbw2fRcn-w" name="conflict_container" singleValuedAttribute="originValue"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/right.nodes
new file mode 100644
index 000000000..27d2691d0
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/right.nodes
@@ -0,0 +1,4 @@
+<?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="_wZM5IKhyEemotbw2fRcn-w" name="model">
+ <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_yCMQMKhyEemotbw2fRcn-w" name="conflict_container" singleValuedAttribute="changedValue"/>
+</nodes:Node>

Back to the top