Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Cartaud2016-04-27 03:48:45 -0400
committerMathieu Cartaud2016-04-27 11:01:22 -0400
commit851f823d7d66c3d6bcd22f88430e9db4da94a3a1 (patch)
treea50309a414566c46244839cd524e49364d1b3d9e /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req
parent31aa7916d75a14e46f074bfc3d8dfbd303502b27 (diff)
downloadorg.eclipse.emf.compare-851f823d7d66c3d6bcd22f88430e9db4da94a3a1.tar.gz
org.eclipse.emf.compare-851f823d7d66c3d6bcd22f88430e9db4da94a3a1.tar.xz
org.eclipse.emf.compare-851f823d7d66c3d6bcd22f88430e9db4da94a3a1.zip
[492341] Res Att Change correctly implies diffs3.2.0M7
Bug: 492341 Change-Id: I44c972aa1aff0d093f9aa5d2a7c7e2967187ce68 Signed-off-by: Mathieu Cartaud <mathieu.cartaud@obeo.fr>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/ReqComputingTest.java111
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/ReqInputData.java25
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/ancestor/fragment.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/ancestor/origin.nodes10
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/left/origin.nodes7
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/right/fragment.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/right/origin.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/ancestor/origin.nodes7
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/left/fragment.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/left/origin.nodes10
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/right/origin.nodes7
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/useCases6
12 files changed, 198 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/ReqComputingTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/ReqComputingTest.java
index 787378115..a316870b0 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/ReqComputingTest.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/ReqComputingTest.java
@@ -23,9 +23,12 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Collections2;
import com.google.common.collect.Iterators;
import java.io.IOException;
+import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.util.EList;
@@ -33,10 +36,13 @@ import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.compare.ReferenceChange;
+import org.eclipse.emf.compare.ResourceAttachmentChange;
import org.eclipse.emf.compare.scope.DefaultComparisonScope;
import org.eclipse.emf.compare.scope.IComparisonScope;
import org.eclipse.emf.compare.tests.req.data.ReqInputData;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.junit.Test;
@SuppressWarnings("nls")
@@ -648,6 +654,111 @@ public class ReqComputingTest {
assertTrue(singleChange.getRequires().contains(added2));
}
+ @Test
+ public void testH1UseCase() throws IOException {
+ final Resource left = input.getH1Left();
+ final Resource origin = input.getH1Ancestor();
+ final Resource right = input.getH1Right();
+
+ final ResourceSet leftSet = left.getResourceSet();
+ final ResourceSet originSet = origin.getResourceSet();
+ final ResourceSet rightSet = right.getResourceSet();
+
+ assertNotNull(leftSet);
+ assertNotNull(originSet);
+ assertNotNull(rightSet);
+
+ EcoreUtil.resolveAll(leftSet);
+ EcoreUtil.resolveAll(originSet);
+ EcoreUtil.resolveAll(rightSet);
+
+ assertEquals(1, leftSet.getResources().size());
+ assertEquals(2, originSet.getResources().size());
+ assertEquals(2, rightSet.getResources().size());
+
+ IComparisonScope scope = new DefaultComparisonScope(leftSet, rightSet, originSet);
+ Comparison comparison = EMFCompare.builder().build().compare(scope);
+ testH(TestKind.DELETE, comparison);
+
+ scope = new DefaultComparisonScope(rightSet, leftSet, originSet);
+ comparison = EMFCompare.builder().build().compare(scope);
+ testH(TestKind.DELETE, comparison);
+ }
+
+ @Test
+ public void testH2UseCase() throws IOException {
+ final Resource left = input.getH2Left();
+ final Resource origin = input.getH2Ancestor();
+ final Resource right = input.getH2Right();
+
+ final ResourceSet leftSet = left.getResourceSet();
+ final ResourceSet originSet = origin.getResourceSet();
+ final ResourceSet rightSet = right.getResourceSet();
+
+ assertNotNull(leftSet);
+ assertNotNull(originSet);
+ assertNotNull(rightSet);
+
+ EcoreUtil.resolveAll(leftSet);
+ EcoreUtil.resolveAll(originSet);
+ EcoreUtil.resolveAll(rightSet);
+
+ assertEquals(2, leftSet.getResources().size());
+ assertEquals(1, originSet.getResources().size());
+ assertEquals(1, rightSet.getResources().size());
+
+ IComparisonScope scope = new DefaultComparisonScope(leftSet, rightSet, originSet);
+ Comparison comparison = EMFCompare.builder().build().compare(scope);
+ testH(TestKind.ADD, comparison);
+
+ scope = new DefaultComparisonScope(rightSet, leftSet, originSet);
+ comparison = EMFCompare.builder().build().compare(scope);
+ testH(TestKind.ADD, comparison);
+ }
+
+ private void testH(TestKind testKind, Comparison comparison) {
+
+ EList<Diff> differences = comparison.getDifferences();
+ Collection<Diff> racs = Collections2.filter(differences, Predicates
+ .instanceOf(ResourceAttachmentChange.class));
+ assertEquals(1, racs.size());
+ Diff rac = racs.iterator().next();
+
+ Predicate<? super Diff> deleteFragmentedDiffDescription = null;
+ Predicate<? super Diff> deleteInnerNodeDiffDescription = null;
+
+ if (testKind == TestKind.DELETE) {
+ deleteFragmentedDiffDescription = removed("root.fragmented"); //$NON-NLS-1$
+ deleteInnerNodeDiffDescription = removed("root.fragmented.innerNode"); //$NON-NLS-1$
+ } else {
+ deleteFragmentedDiffDescription = added("root.fragmented"); //$NON-NLS-1$
+ deleteInnerNodeDiffDescription = added("root.fragmented.innerNode"); //$NON-NLS-1$
+ }
+
+ final Diff deleteFragmentedDiff = Iterators.find(differences.iterator(),
+ deleteFragmentedDiffDescription);
+ final Diff deleteInnerNodeDiff = Iterators.find(differences.iterator(),
+ deleteInnerNodeDiffDescription);
+
+ if (testKind == TestKind.DELETE) {
+ assertEquals(1, rac.getRequiredBy().size());
+ assertEquals(deleteFragmentedDiff, rac.getRequiredBy().get(0));
+ assertEquals(0, rac.getRequires().size());
+
+ assertEquals(1, deleteInnerNodeDiff.getRequiredBy().size());
+ assertEquals(deleteFragmentedDiff, deleteInnerNodeDiff.getRequiredBy().get(0));
+ assertEquals(0, deleteInnerNodeDiff.getRequires().size());
+ } else {
+ assertEquals(1, rac.getRequires().size());
+ assertEquals(deleteFragmentedDiff, rac.getRequires().get(0));
+ assertEquals(0, rac.getRequiredBy().size());
+
+ assertEquals(1, deleteInnerNodeDiff.getRequires().size());
+ assertEquals(deleteFragmentedDiff, deleteInnerNodeDiff.getRequires().get(0));
+ assertEquals(0, deleteInnerNodeDiff.getRequiredBy().size());
+ }
+ }
+
private void testAB1(TestKind kind, final Comparison comparison) {
final List<Diff> differences = comparison.getDifferences();
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/ReqInputData.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/ReqInputData.java
index eff074820..90d1348d7 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/ReqInputData.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/ReqInputData.java
@@ -14,6 +14,7 @@ import java.io.IOException;
import org.eclipse.emf.compare.tests.framework.AbstractInputData;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
public class ReqInputData extends AbstractInputData {
public Resource getA1Left() throws IOException {
@@ -415,4 +416,28 @@ public class ReqInputData extends AbstractInputData {
public Resource getG1Right() throws IOException {
return loadFromClassLoader("g1/right.nodes"); //$NON-NLS-1$
}
+
+ public Resource getH1Left() throws IOException {
+ return loadFromClassLoader("h1/left/origin.nodes", new ResourceSetImpl()); //$NON-NLS-1$
+ }
+
+ public Resource getH1Right() throws IOException {
+ return loadFromClassLoader("h1/right/origin.nodes", new ResourceSetImpl()); //$NON-NLS-1$
+ }
+
+ public Resource getH1Ancestor() throws IOException {
+ return loadFromClassLoader("h1/ancestor/origin.nodes", new ResourceSetImpl()); //$NON-NLS-1$
+ }
+
+ public Resource getH2Left() throws IOException {
+ return loadFromClassLoader("h2/left/origin.nodes", new ResourceSetImpl()); //$NON-NLS-1$
+ }
+
+ public Resource getH2Right() throws IOException {
+ return loadFromClassLoader("h2/right/origin.nodes", new ResourceSetImpl()); //$NON-NLS-1$
+ }
+
+ public Resource getH2Ancestor() throws IOException {
+ return loadFromClassLoader("h2/ancestor/origin.nodes", new ResourceSetImpl()); //$NON-NLS-1$
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/ancestor/fragment.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/ancestor/fragment.nodes
new file mode 100644
index 000000000..0eba84fee
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/ancestor/fragment.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:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_QE6YYAcQEeKTxJtDIb3mMw" name="fragmented">
+ <containmentRef1 xmi:id="_gUHAUArkEeaHsdquODvaLA" name="innerNode"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/ancestor/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/ancestor/origin.nodes
new file mode 100644
index 000000000..7192229e8
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/ancestor/origin.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:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_ORexoLlNEeGmS9ESxeCLvg"
+ name="root">
+ <containmentRef1
+ href="fragment.nodes#_QE6YYAcQEeKTxJtDIb3mMw"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/left/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/left/origin.nodes
new file mode 100644
index 000000000..6d8762bae
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/left/origin.nodes
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_ORexoLlNEeGmS9ESxeCLvg"
+ name="root"/>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/right/fragment.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/right/fragment.nodes
new file mode 100644
index 000000000..0eba84fee
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/right/fragment.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:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_QE6YYAcQEeKTxJtDIb3mMw" name="fragmented">
+ <containmentRef1 xmi:id="_gUHAUArkEeaHsdquODvaLA" name="innerNode"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/right/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/right/origin.nodes
new file mode 100644
index 000000000..b75ab1666
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h1/right/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:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_ORexoLlNEeGmS9ESxeCLvg" name="root">
+ <containmentRef1 href="fragment.nodes#_QE6YYAcQEeKTxJtDIb3mMw"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/ancestor/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/ancestor/origin.nodes
new file mode 100644
index 000000000..6d8762bae
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/ancestor/origin.nodes
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_ORexoLlNEeGmS9ESxeCLvg"
+ name="root"/>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/left/fragment.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/left/fragment.nodes
new file mode 100644
index 000000000..0eba84fee
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/left/fragment.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:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_QE6YYAcQEeKTxJtDIb3mMw" name="fragmented">
+ <containmentRef1 xmi:id="_gUHAUArkEeaHsdquODvaLA" name="innerNode"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/left/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/left/origin.nodes
new file mode 100644
index 000000000..7192229e8
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/left/origin.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:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_ORexoLlNEeGmS9ESxeCLvg"
+ name="root">
+ <containmentRef1
+ href="fragment.nodes#_QE6YYAcQEeKTxJtDIb3mMw"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/right/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/right/origin.nodes
new file mode 100644
index 000000000..6d8762bae
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/h2/right/origin.nodes
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes"
+ xmi:id="_ORexoLlNEeGmS9ESxeCLvg"
+ name="root"/>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/useCases b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/useCases
index 1c2a52035..e1c970d46 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/useCases
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/req/data/useCases
@@ -33,4 +33,8 @@ d - many business model object dependency - right changes
e - 3-way tests - left changes
-f - 3 way tests - right changes \ No newline at end of file
+f - 3 way tests - right changes
+
+h - resource attachment change tests
+ h1 - resource attachment change on a deleted object
+ h2 - resource attachment change on a added object \ No newline at end of file

Back to the top