Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langer2016-12-05 18:12:24 +0000
committerPhilip Langer2017-01-13 15:21:23 +0000
commitda4e46807e9aa5bc102dbc5fc073a162137b6405 (patch)
treecf650d9b60e5c948e0a21a2c225a7610124d6c0b /plugins/org.eclipse.emf.compare.tests/src/org
parent8729a641e78b15269342124f3b375084c8afbea7 (diff)
downloadorg.eclipse.emf.compare-da4e46807e9aa5bc102dbc5fc073a162137b6405.tar.gz
org.eclipse.emf.compare-da4e46807e9aa5bc102dbc5fc073a162137b6405.tar.xz
org.eclipse.emf.compare-da4e46807e9aa5bc102dbc5fc073a162137b6405.zip
[508665] Delete EnumerationLiteral classifier changes from comparison
EnumerationLiteral.classifier is essentially a derived feature. In fact, the classifier of an EnumerationLiteral is always its containing Enumeration. However, this feature is not declared as such in the metamodel, as it is inherited from InstanceSpecification.classifier, which is not derived. In the UML implementation, EnumerationLiteral.classifier, therefore, overwrites InstanceSpecification.classifier to return an unmodifiable collection always containing the Enumeration instead of a writable collection. Thus, we have to avoid merging changes of EnumerationLiteral.classifier changes and can ignore changes of this feature altogether. Changes of this feature on EnumerationLiterals will therefore be deleted, just as if it would have been the case if the feature would really be declared as derived feature. Bug: 508665 Change-Id: I685e5ab6ef29c3c452845e4f9deae087a9b3b40b Signed-off-by: Philip Langer <planger@eclipsesource.com>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/internal/utils/ComparisonUtilDeleteTest.java131
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java5
2 files changed, 134 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/internal/utils/ComparisonUtilDeleteTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/internal/utils/ComparisonUtilDeleteTest.java
new file mode 100644
index 000000000..4aa66e4d4
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/internal/utils/ComparisonUtilDeleteTest.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2017 EclipseSource Services GmbH and others.
+ * 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:
+ * Philip Langer - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.internal.utils;
+
+import static org.eclipse.emf.compare.DifferenceSource.LEFT;
+import static org.eclipse.emf.compare.DifferenceSource.RIGHT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+
+import org.eclipse.emf.compare.CompareFactory;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Conflict;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceSource;
+import org.eclipse.emf.compare.Equivalence;
+import org.eclipse.emf.compare.Match;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ComparisonUtilDeleteTest {
+
+ private static final CompareFactory COMPARE_FACTORY = CompareFactory.eINSTANCE;
+
+ private Match match;
+
+ private Diff diffToDelete;
+
+ @Before
+ public void setUp() {
+ match = createMatch(COMPARE_FACTORY.createComparison());
+ diffToDelete = createDiff(LEFT);
+ }
+
+ private Match createMatch(Comparison comparison) {
+ Match newMatch = COMPARE_FACTORY.createMatch();
+ comparison.getMatches().add(newMatch);
+ return newMatch;
+ }
+
+ private Diff createDiff(DifferenceSource side) {
+ Diff newDiff = COMPARE_FACTORY.createDiff();
+ match.getDifferences().add(newDiff);
+ newDiff.setSource(side);
+ return newDiff;
+ }
+
+ private Conflict createConflict(Diff... diffs) {
+ Conflict newConflict = COMPARE_FACTORY.createConflict();
+ newConflict.getDifferences().addAll(Arrays.asList(diffs));
+ match.getComparison().getConflicts().add(newConflict);
+ return newConflict;
+ }
+
+ private Equivalence createEquivalence(Diff... diffs) {
+ Equivalence newEquivalence = COMPARE_FACTORY.createEquivalence();
+ newEquivalence.getDifferences().addAll(Arrays.asList(diffs));
+ match.getComparison().getEquivalences().add(newEquivalence);
+ return newEquivalence;
+ }
+
+ @Test
+ public void testDeleteDiff() {
+ ComparisonUtil.delete(diffToDelete);
+ assertFalse(match.getDifferences().contains(diffToDelete));
+ }
+
+ @Test
+ public void testDeleteDiff_WithConflictsToDelete() {
+ final Diff conflictingDiff = createDiff(RIGHT);
+ Conflict conflictToDelete = createConflict(diffToDelete, conflictingDiff);
+ Conflict otherConflict = createConflict(createDiff(LEFT), createDiff(RIGHT));
+ ComparisonUtil.delete(diffToDelete);
+
+ assertFalse(match.getDifferences().contains(diffToDelete));
+ assertNull(conflictingDiff.getConflict());
+ assertFalse(match.getComparison().getConflicts().contains(conflictToDelete));
+ assertTrue(match.getComparison().getConflicts().contains(otherConflict));
+ assertEquals(2, otherConflict.getDifferences().size());
+ }
+
+ @Test
+ public void testDeleteDiff_WithConflictToKeep() {
+ Conflict conflictToKeep = createConflict(diffToDelete, createDiff(LEFT), createDiff(RIGHT));
+ ComparisonUtil.delete(diffToDelete);
+
+ assertFalse(match.getDifferences().contains(diffToDelete));
+ assertFalse(conflictToKeep.getDifferences().contains(diffToDelete));
+
+ assertTrue(match.getComparison().getConflicts().contains(conflictToKeep));
+ assertEquals(1, conflictToKeep.getLeftDifferences().size());
+ assertEquals(1, conflictToKeep.getRightDifferences().size());
+ }
+
+ @Test
+ public void testDeleteDiff_WithEquivalencesToDelete() {
+ Diff equivalentDiff = createDiff(RIGHT);
+ Equivalence equivalenceToDelete = createEquivalence(diffToDelete, equivalentDiff);
+ Equivalence otherEquivalence = createEquivalence(createDiff(LEFT), createDiff(RIGHT));
+ ComparisonUtil.delete(diffToDelete);
+
+ assertFalse(match.getDifferences().contains(diffToDelete));
+ assertNull(equivalentDiff.getEquivalence());
+ assertFalse(match.getComparison().getEquivalences().contains(equivalenceToDelete));
+ assertTrue(match.getComparison().getEquivalences().contains(otherEquivalence));
+ assertEquals(2, otherEquivalence.getDifferences().size());
+ }
+
+ @Test
+ public void testDeleteDiff_WithEquivalenceToKeep() {
+ Equivalence equivalenceToKeep = createEquivalence(diffToDelete, createDiff(LEFT), createDiff(RIGHT));
+ ComparisonUtil.delete(diffToDelete);
+
+ assertFalse(match.getDifferences().contains(diffToDelete));
+ assertFalse(equivalenceToKeep.getDifferences().contains(diffToDelete));
+
+ assertTrue(match.getComparison().getEquivalences().contains(equivalenceToKeep));
+ assertEquals(2, equivalenceToKeep.getDifferences().size());
+ }
+}
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 8e093a4b3..606545ac6 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2016 Obeo and others.
+ * Copyright (c) 2012, 2017 Obeo and others.
* 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
@@ -98,7 +98,8 @@ import junit.textui.TestRunner;
MultiLineAttributeMergeTest.class, MonitorCancelTest.class, IdentifierEObjectMatcherTest.class,
MatchUtilFeatureContainsTest.class, RefineMergeTest.class, Bug484557ConflictTest.class,
Bug485266_MoveDeleteConflict_Test.class, ResourceAttachmentChangeBug492261.class,
- ComparisonScopeAdapterTest.class, EMFComparePredicatesTest.class, RankedAdapterFactoryRegistryTest.class })
+ ComparisonScopeAdapterTest.class, EMFComparePredicatesTest.class,
+ RankedAdapterFactoryRegistryTest.class, ComparisonUtilTest.class, })
public class AllTests {
/**
* Standalone launcher for all of compare's tests.

Back to the top