Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2015-06-03 09:23:35 -0400
committerAxel RICHARD2015-06-10 05:53:00 -0400
commitebabf7d84960a3f18cfb2c9e8e806444f5c49da3 (patch)
tree75cd6e140b5f28d9712a899a3a025c0686105474 /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare
parent7bdc3d62a8b80947f0476326998330809dabea14 (diff)
downloadorg.eclipse.emf.compare-ebabf7d84960a3f18cfb2c9e8e806444f5c49da3.tar.gz
org.eclipse.emf.compare-ebabf7d84960a3f18cfb2c9e8e806444f5c49da3.tar.xz
org.eclipse.emf.compare-ebabf7d84960a3f18cfb2c9e8e806444f5c49da3.zip
[469237] Merge Refining diffs if all refined diffs have been merged
If a diff refines another, we have to check if the "macro" diff has to be merged with it. Also add test case. Bug: 469237 Change-Id: Ieb6cf681c7f6e0255eb061da9b69605a513aa655 Signed-off-by: Axel Richard <axel.richard@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/merge/RefineMergeTest.java87
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java3
2 files changed, 89 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/RefineMergeTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/RefineMergeTest.java
new file mode 100644
index 000000000..8a21ac2a2
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/merge/RefineMergeTest.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.merge;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceState;
+import org.eclipse.emf.compare.internal.spec.DiffSpec;
+import org.eclipse.emf.compare.merge.AbstractMerger;
+import org.junit.Test;
+
+public class RefineMergeTest {
+
+ private final AbstractMerger merger = new AbstractMerger() {
+ public boolean isMergerFor(Diff target) {
+ return true;
+ }
+ };
+
+ /**
+ * If a diff refines another, we have to check if the "macro" diff has to be merged with it.
+ */
+ @Test
+ public void testRefineOnGetDirectResultingMerges() {
+
+ // Create diffs
+ Diff diff1 = new DiffSpec();
+ Diff diff2 = new DiffSpec();
+
+ Diff diff3 = new DiffSpec();
+ diff3.getRefinedBy().add(diff1);
+ diff3.getRefinedBy().add(diff2);
+
+ // First call : diff3 must not to be in the merge dependencies, cause diff2 is not merged.
+ Set<Diff> dependencies = merger.getDirectResultingMerges(diff1, true);
+ assertTrue(dependencies.isEmpty());
+ // Merge diff2
+ diff2.setState(DifferenceState.MERGED);
+ // Second call : diff3 must be in the merge dependencies, cause diff2 has been merged.
+ dependencies = merger.getDirectResultingMerges(diff1, true);
+ assertEquals(1, dependencies.size());
+ assertTrue(dependencies.contains(diff3));
+
+ }
+
+ @Test
+ public void testRefineOnGetDirectResultingMerges_2() {
+
+ // Create diffs
+ Diff diff1 = new DiffSpec();
+ Diff diff2 = new DiffSpec();
+ Diff diff3 = new DiffSpec();
+
+ Diff diff4 = new DiffSpec();
+ diff4.getRefinedBy().add(diff1);
+ diff4.getRefinedBy().add(diff2);
+ diff4.getRefinedBy().add(diff3);
+
+ // First call : diff4 must not to be in the merge dependencies, cause diff2 & diff3 are not merged.
+ Set<Diff> dependencies = merger.getDirectResultingMerges(diff1, true);
+ assertTrue(dependencies.isEmpty());
+ // Merge diff2
+ diff2.setState(DifferenceState.MERGED);
+ // Second call : diff4 must not to be in the merge dependencies, cause diff3 is not merged.
+ dependencies = merger.getDirectResultingMerges(diff1, true);
+ assertTrue(dependencies.isEmpty());
+ // Merge diff3
+ diff3.setState(DifferenceState.MERGED);
+ // Third call : diff4 must be in the merge dependencies, cause diff2 & diff3 have been merged.
+ dependencies = merger.getDirectResultingMerges(diff1, true);
+ assertEquals(1, dependencies.size());
+ assertTrue(dependencies.contains(diff4));
+
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
index 5ea30df1d..ed7d9e2c5 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
@@ -51,6 +51,7 @@ import org.eclipse.emf.compare.tests.merge.IndividualMergeTest;
import org.eclipse.emf.compare.tests.merge.MultiLineAttributeMergeTest;
import org.eclipse.emf.compare.tests.merge.MultipleMergeTest;
import org.eclipse.emf.compare.tests.merge.PseudoConflictMergeTest;
+import org.eclipse.emf.compare.tests.merge.RefineMergeTest;
import org.eclipse.emf.compare.tests.merge.ThreeWayBatchMergingTest;
import org.eclipse.emf.compare.tests.merge.TwoWayBatchMergingTest;
import org.eclipse.emf.compare.tests.monitor.MonitorCancelTest;
@@ -89,7 +90,7 @@ import org.junit.runners.Suite.SuiteClasses;
FeatureFilterTest.class, ThreeWayBatchMergingTest.class,
MultiLineAttributeConflictDetectionTest.class, ThreeWayTextDiffTest.class,
MultiLineAttributeMergeTest.class, MonitorCancelTest.class, IdentifierEObjectMatcherTest.class,
- MatchUtilFeatureContainsTest.class })
+ MatchUtilFeatureContainsTest.class, RefineMergeTest.class })
public class AllTests {
/**
* Standalone launcher for all of compare's tests.

Back to the top