Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Goubet2014-10-01 06:01:33 -0400
committerLaurent Goubet2014-10-10 03:47:11 -0400
commit0986e2ac6e2ba95b0299e6a7822bf1df8689f74c (patch)
treed6ddf688c97a3890090b474740d40a71b569a39b /plugins/org.eclipse.emf.compare.uml2.tests
parente39698b4f20d73041f6cf17af49f633c5094d835 (diff)
downloadorg.eclipse.emf.compare-0986e2ac6e2ba95b0299e6a7822bf1df8689f74c.tar.gz
org.eclipse.emf.compare-0986e2ac6e2ba95b0299e6a7822bf1df8689f74c.tar.xz
org.eclipse.emf.compare-0986e2ac6e2ba95b0299e6a7822bf1df8689f74c.zip
Modify merge to handle implications properly
This introduces an overhaul of the merging process as a whole in order to properly handle implications (a diff implied by another does not need merging in itself, we only need to merge the implying), most notably for the UML comparison support. The same algorithm is now used to merge differences in a batch (or to simply merge implications, results and equivalences) and to display the impact analysis of a merge in the user interface (what will be merged and what will be rejected when I merge such or such difference). Change-Id: I39f69c05f94b5f18cb3a3c3b1f7089700f138282
Diffstat (limited to 'plugins/org.eclipse.emf.compare.uml2.tests')
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/AbstractUMLTest.java4
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsAssociationTest.java22
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsInterfaceRealizationTest.java18
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsTransitionTest.java14
4 files changed, 42 insertions, 16 deletions
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/AbstractUMLTest.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/AbstractUMLTest.java
index 38f732b5a..f125fffa0 100644
--- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/AbstractUMLTest.java
+++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/AbstractUMLTest.java
@@ -48,6 +48,7 @@ import org.eclipse.emf.compare.tests.postprocess.data.TestPostProcessor;
import org.eclipse.emf.compare.uml2.internal.StereotypedElementChange;
import org.eclipse.emf.compare.uml2.internal.UMLDiff;
import org.eclipse.emf.compare.uml2.internal.merge.UMLMerger;
+import org.eclipse.emf.compare.uml2.internal.merge.UMLReferenceChangeMerger;
import org.eclipse.emf.compare.uml2.internal.postprocessor.UMLPostProcessor;
import org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.UML2CompareTestProfilePackage;
import org.eclipse.emf.compare.utils.ReferenceUtil;
@@ -111,8 +112,11 @@ public abstract class AbstractUMLTest {
builder.setPostProcessorRegistry(postProcessorRegistry);
mergerRegistry = IMerger.RegistryImpl.createStandaloneInstance();
final IMerger umlMerger = new UMLMerger();
+ final IMerger umlReferenceChangeMerger = new UMLReferenceChangeMerger();
umlMerger.setRanking(11);
+ umlReferenceChangeMerger.setRanking(25);
mergerRegistry.add(umlMerger);
+ mergerRegistry.add(umlReferenceChangeMerger);
emfCompare = builder.build();
}
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsAssociationTest.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsAssociationTest.java
index d8071d1a5..48c7b64b7 100644
--- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsAssociationTest.java
+++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsAssociationTest.java
@@ -243,8 +243,14 @@ public class ImplicationsAssociationTest extends AbstractUMLTest {
}
private void checkMergeDeleteNavigableOwnedEnd(Comparison comparison, DiffsOfInterest diffs) {
- assertEquals(NB_DIFFS - 1, comparison.getDifferences().size());
+ assertEquals(NB_DIFFS - 7, comparison.getDifferences().size());
assertNull(diffs.addNavigableOwnedEndClass1InAssociation);
+ assertNull(diffs.addOwnedEndClass1InAssociation);
+ assertNull(diffs.addMemberEndClass1InAssociation);
+ assertNull(diffs.addRefAssociationInPropertyClass1);
+ assertNull(diffs.addLiteralIntegerInClass1);
+ assertNull(diffs.addUnlimitedNaturalInClass1);
+ assertNull(diffs.addRefTypeInPropertyClass1);
}
@Test
@@ -267,9 +273,10 @@ public class ImplicationsAssociationTest extends AbstractUMLTest {
}
private void checkMergeAddOwnedEnd(Comparison comparison, DiffsOfInterest diffs) {
- assertEquals(NB_DIFFS - 5, comparison.getDifferences().size());
+ assertEquals(NB_DIFFS - 6, comparison.getDifferences().size());
assertNull(diffs.addOwnedEndClass1InAssociation);
assertNull(diffs.addMemberEndClass1InAssociation);
+ assertNull(diffs.addNavigableOwnedEndClass1InAssociation);
assertNull(diffs.addRefAssociationInPropertyClass1);
assertNull(diffs.addAssociation);
assertNull(diffs.addUMLAssociation);
@@ -344,10 +351,11 @@ public class ImplicationsAssociationTest extends AbstractUMLTest {
}
private void checkMergeAddMemberEnd(Comparison comparison, DiffsOfInterest diffs) {
- assertEquals(NB_DIFFS - 5, comparison.getDifferences().size());
+ assertEquals(NB_DIFFS - 6, comparison.getDifferences().size());
assertNull(diffs.addMemberEndClass1InAssociation);
assertNull(diffs.addRefAssociationInPropertyClass1);
assertNull(diffs.addOwnedEndClass1InAssociation);
+ assertNull(diffs.addNavigableOwnedEndClass1InAssociation);
assertNull(diffs.addAssociation);
assertNull(diffs.addUMLAssociation);
}
@@ -949,9 +957,11 @@ public class ImplicationsAssociationTest extends AbstractUMLTest {
assertEquals(1, diffs.addOwnedEndClass1InAssociation.getImplies().size());
assertTrue(diffs.addOwnedEndClass1InAssociation.getImplies().contains(
diffs.addNavigableOwnedEndClass1InAssociation));
- assertEquals(1, diffs.addOwnedEndClass1InAssociation.getImpliedBy().size());
+ assertEquals(2, diffs.addOwnedEndClass1InAssociation.getImpliedBy().size());
assertTrue(diffs.addOwnedEndClass1InAssociation.getImpliedBy().contains(
diffs.addMemberEndClass1InAssociation));
+ assertTrue(diffs.addOwnedEndClass1InAssociation.getImpliedBy().contains(
+ diffs.addRefAssociationInPropertyClass1));
assertEquals(1, diffs.addMemberEndClass1InAssociation.getImplies().size());
assertTrue(diffs.addMemberEndClass1InAssociation.getImplies().contains(
@@ -963,9 +973,11 @@ public class ImplicationsAssociationTest extends AbstractUMLTest {
diffs.addOwnedEndClass1InAssociation));
assertEquals(0, diffs.addNavigableOwnedEndClass1InAssociation.getImpliedBy().size());
- assertEquals(1, diffs.addOwnedEndClass1InAssociation.getImplies().size());
+ assertEquals(2, diffs.addOwnedEndClass1InAssociation.getImplies().size());
assertTrue(diffs.addOwnedEndClass1InAssociation.getImplies().contains(
diffs.addMemberEndClass1InAssociation));
+ assertTrue(diffs.addOwnedEndClass1InAssociation.getImplies().contains(
+ diffs.addRefAssociationInPropertyClass1));
assertEquals(1, diffs.addOwnedEndClass1InAssociation.getImpliedBy().size());
assertTrue(diffs.addOwnedEndClass1InAssociation.getImpliedBy().contains(
diffs.addNavigableOwnedEndClass1InAssociation));
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsInterfaceRealizationTest.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsInterfaceRealizationTest.java
index 0a808a474..5d6d6b89b 100644
--- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsInterfaceRealizationTest.java
+++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsInterfaceRealizationTest.java
@@ -7,6 +7,7 @@ import static org.eclipse.emf.compare.utils.EMFComparePredicates.changedReferenc
import static org.eclipse.emf.compare.utils.EMFComparePredicates.removedFromReference;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterators;
@@ -654,15 +655,18 @@ public class ImplicationsInterfaceRealizationTest extends AbstractUMLTest {
DiffsOfInterest diffs = getDiffs(comparison, kind);
if (kind.equals(TestKind.DELETE)) {
- // there were tests for UML4, no longer valid for 5.0 with clientDependency being
- // marked as derived.
+ assertEquals(1, diffs.addInterfaceRealization.getImpliedBy().size());
+ assertTrue(diffs.addInterfaceRealization.getImpliedBy().contains(
+ diffs.addClientInInterfaceRealization));
+ assertEquals(1, diffs.addSubstitution.getImpliedBy().size());
+ assertTrue(diffs.addSubstitution.getImpliedBy().contains(diffs.addClientInSubstitution));
} else {
- assertEquals(0, diffs.addInterfaceRealization.getImplies().size());
- assertEquals(0, diffs.addSubstitution.getImplies().size());
+ assertEquals(1, diffs.addInterfaceRealization.getImplies().size());
+ assertTrue(diffs.addInterfaceRealization.getImplies().contains(
+ diffs.addClientInInterfaceRealization));
+ assertEquals(1, diffs.addSubstitution.getImplies().size());
+ assertTrue(diffs.addSubstitution.getImplies().contains(diffs.addClientInSubstitution));
}
- assertEquals(0, diffs.addClientInInterfaceRealization.getImplies().size());
- assertEquals(0, diffs.addClientInSubstitution.getImplies().size());
-
}
@Override
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsTransitionTest.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsTransitionTest.java
index 27e3b2af6..6ebac78ab 100644
--- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsTransitionTest.java
+++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/implications/ImplicationsTransitionTest.java
@@ -160,8 +160,10 @@ public class ImplicationsTransitionTest extends AbstractUMLTest {
}
private void checkMergeDeletePrecondition(Comparison comparison, DiffsOfInterest diffs) {
- assertEquals(NB_DIFFS - 1, comparison.getDifferences().size());
+ assertEquals(NB_DIFFS - 3, comparison.getDifferences().size());
assertNull(diffs.addPrecondition);
+ assertNull(diffs.addGuard);
+ assertNull(diffs.addOwnedRule);
}
@Test
@@ -184,9 +186,10 @@ public class ImplicationsTransitionTest extends AbstractUMLTest {
}
private void checkMergeAddGuard(Comparison comparison, DiffsOfInterest diffs) {
- assertEquals(NB_DIFFS - 3, comparison.getDifferences().size());
+ assertEquals(NB_DIFFS - 4, comparison.getDifferences().size());
assertNull(diffs.addGuard);
assertNull(diffs.addOwnedRule);
+ assertNull(diffs.addPrecondition);
assertNull(diffs.addTransition);
}
@@ -229,9 +232,10 @@ public class ImplicationsTransitionTest extends AbstractUMLTest {
}
private void checkMergeDeleteGuard(Comparison comparison, DiffsOfInterest diffs) {
- assertEquals(NB_DIFFS - 2, comparison.getDifferences().size());
+ assertEquals(NB_DIFFS - 3, comparison.getDifferences().size());
assertNull(diffs.addGuard);
assertNull(diffs.addPrecondition);
+ assertNull(diffs.addOwnedRule);
}
@Test
@@ -254,9 +258,11 @@ public class ImplicationsTransitionTest extends AbstractUMLTest {
}
private void checkMergeAddOwnedRule(Comparison comparison, DiffsOfInterest diffs) {
- assertEquals(NB_DIFFS - 2, comparison.getDifferences().size());
+ assertEquals(NB_DIFFS - 4, comparison.getDifferences().size());
assertNull(diffs.addOwnedRule);
+ assertNull(diffs.addGuard);
assertNull(diffs.addTransition);
+ assertNull(diffs.addPrecondition);
}
@Test

Back to the top