Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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/conflict/ConflictSearchTest.java94
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java5
2 files changed, 97 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/conflict/ConflictSearchTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/conflict/ConflictSearchTest.java
new file mode 100644
index 000000000..7e5be3e6b
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/conflict/ConflictSearchTest.java
@@ -0,0 +1,94 @@
+package org.eclipse.emf.compare.tests.conflict;
+
+import static java.util.Arrays.asList;
+import static org.eclipse.emf.compare.ConflictKind.REAL;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.compare.CompareFactory;
+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.Equivalence;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.internal.conflict.AbstractConflictSearch;
+import org.eclipse.emf.compare.internal.conflict.ComparisonIndex;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ConflictSearchTest {
+
+ private Diff diff;
+
+ private Match match;
+
+ private Comparison comparison;
+
+ private ComparisonIndex index;
+
+ private Diff other;
+
+ private Diff equivToDiff;
+
+ private Diff equivToOther;
+
+ private Equivalence equivDiff;
+
+ private Equivalence equivOther;
+
+ /**
+ * @see <a href="http://eclip.se/510704">Bug 510704</a>
+ */
+ @Test
+ public void testEquivalentDiffsAreInSameConflict() {
+ // Given
+ TestConflictSearch search = new TestConflictSearch(diff, index);
+ // When
+ search.conflict(other, REAL);
+ // then
+ assertEquals(1, comparison.getConflicts().size());
+ Conflict conflict = comparison.getConflicts().get(0);
+ assertEquals(4, conflict.getDifferences().size());
+ assertTrue(conflict.getDifferences().containsAll(asList(diff, equivToDiff, other, equivToOther)));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ comparison = CompareFactory.eINSTANCE.createComparison();
+ match = CompareFactory.eINSTANCE.createMatch();
+ comparison.getMatches().add(match);
+ diff = CompareFactory.eINSTANCE.createDiff();
+ diff.setMatch(match);
+ other = CompareFactory.eINSTANCE.createDiff();
+ other.setMatch(match);
+ equivToDiff = CompareFactory.eINSTANCE.createDiff();
+ equivToDiff.setMatch(match);
+ equivToOther = CompareFactory.eINSTANCE.createDiff();
+ equivToOther.setMatch(match);
+ equivDiff = CompareFactory.eINSTANCE.createEquivalence();
+ equivOther = CompareFactory.eINSTANCE.createEquivalence();
+ equivDiff.getDifferences().addAll(asList(diff, equivToDiff));
+ equivOther.getDifferences().addAll(asList(other, equivToOther));
+ index = ComparisonIndex.index(comparison, new BasicMonitor());
+ }
+
+ public static final class TestConflictSearch extends AbstractConflictSearch<Diff> {
+
+ public TestConflictSearch(Diff diff, ComparisonIndex index) {
+ super(diff, index, new BasicMonitor());
+ }
+
+ @Override
+ public void detectConflicts() {
+ // Nothing to do
+ }
+
+ @Override
+ public void conflict(Diff other, ConflictKind kind) {
+ super.conflict(other, kind);
+ }
+
+ }
+}
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 69b2cd077..a69af8112 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
@@ -17,6 +17,7 @@ package org.eclipse.emf.compare.tests.suite;
import org.eclipse.emf.compare.ComparePackage;
import org.eclipse.emf.compare.tests.command.CommandStackTestSuite;
import org.eclipse.emf.compare.tests.conflict.ConflictDetectionTest;
+import org.eclipse.emf.compare.tests.conflict.ConflictSearchTest;
import org.eclipse.emf.compare.tests.conflict.MultiLineAttributeConflictDetectionTest;
import org.eclipse.emf.compare.tests.conflict.PseudoConflictDetectionTest;
import org.eclipse.emf.compare.tests.conflict.data.bug484557.Bug484557ConflictTest;
@@ -106,8 +107,8 @@ import junit.textui.TestRunner;
Bug485266_MoveDeleteConflict_Test.class, ResourceAttachmentChangeBug492261.class,
RankedAdapterFactoryRegistryTest.class, ComparisonScopeAdapterTest.class,
EMFComparePredicatesTest.class, ImplicationsMergeTest.class, GraphTest.class,
- ConflictImplicationsTest_Bug484579.class, PseudoConflictDetectionTest.class,
- ComplexMergeTest.class, })
+ ConflictImplicationsTest_Bug484579.class, PseudoConflictDetectionTest.class, ComplexMergeTest.class,
+ ConflictSearchTest.class, })
public class AllTests {
/**
* Standalone launcher for all of compare's tests.

Back to the top