diff options
Diffstat (limited to 'plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf')
17 files changed, 1875 insertions, 13 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 17d9a53ca..e9402401b 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 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2012, 2013 Obeo. + * Copyright (c) 2012, 2014 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 @@ -10,6 +10,8 @@ */ package org.eclipse.emf.compare.uml2.tests; +import static com.google.common.base.Predicates.instanceOf; +import static com.google.common.base.Predicates.not; import static com.google.common.collect.Iterators.all; import static org.eclipse.emf.compare.utils.EMFComparePredicates.hasConflict; import static org.junit.Assert.assertFalse; @@ -43,6 +45,7 @@ import org.eclipse.emf.compare.postprocessor.PostProcessorDescriptorRegistryImpl import org.eclipse.emf.compare.scope.DefaultComparisonScope; import org.eclipse.emf.compare.scope.IComparisonScope; 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.postprocessor.UMLPostProcessor; @@ -104,10 +107,7 @@ public abstract class AbstractUMLTest { // post-processor and merger registry is not filled in runtime (org.eclipse.emf.compare.rcp not // loaded) final IPostProcessor.Descriptor.Registry<String> postProcessorRegistry = new PostProcessorDescriptorRegistryImpl<String>(); - postProcessorRegistry.put(UMLPostProcessor.class.getName(), - new TestPostProcessor.TestPostProcessorDescriptor(Pattern - .compile("http://www.eclipse.org/uml2/\\d\\.0\\.0/UML"), null, - new UMLPostProcessor(), 20)); + registerPostProcessors(postProcessorRegistry); builder.setPostProcessorRegistry(postProcessorRegistry); mergerRegistry = IMerger.RegistryImpl.createStandaloneInstance(); final IMerger umlMerger = new UMLMerger(); @@ -116,6 +116,19 @@ public abstract class AbstractUMLTest { emfCompare = builder.build(); } + /** + * Used to register new post processors. + * + * @param postProcessorRegistry + */ + protected void registerPostProcessors( + final IPostProcessor.Descriptor.Registry<String> postProcessorRegistry) { + postProcessorRegistry.put(UMLPostProcessor.class.getName(), + new TestPostProcessor.TestPostProcessorDescriptor(Pattern + .compile("http://www.eclipse.org/uml2/\\d\\.0\\.0/UML"), null, + new UMLPostProcessor(), 20)); + } + @After public void cleanup() { for (ResourceSet set : getInput().getSets()) { @@ -246,11 +259,16 @@ public abstract class AbstractUMLTest { } protected void testIntersections(Comparison comparison) { - assertFalse(Iterables.any(comparison.getDifferences(), new Predicate<Diff>() { - public boolean apply(Diff input) { - return input.getRefines().size() > 1; - } - })); - } + for (Diff diff : comparison.getDifferences()) { + int realRefinesSize = Iterables.size(Iterables.filter(diff.getRefines(), + not(instanceOf(StereotypedElementChange.class)))); + assertFalse("Wrong number of refines (without StereotypedElementChange) on" + diff, + realRefinesSize > 1); + int stereotypedElementChangeRefines = Iterables.size(Iterables.filter(diff.getRefines(), + instanceOf(StereotypedElementChange.class))); + assertFalse("Wrong number of refines (of type StereotypedElementChange) on " + diff, + stereotypedElementChangeRefines > 1); + } + } } diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/AbstractStereotypedElementChangeTests.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/AbstractStereotypedElementChangeTests.java new file mode 100644 index 000000000..a458fd36c --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/AbstractStereotypedElementChangeTests.java @@ -0,0 +1,1305 @@ +/******************************************************************************* + * Copyright (c) 2014 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.uml2.tests.stereotypes; + +import static com.google.common.base.Predicates.and; +import static com.google.common.base.Predicates.instanceOf; +import static org.eclipse.emf.compare.utils.EMFComparePredicates.added; +import static org.eclipse.emf.compare.utils.EMFComparePredicates.ofKind; +import static org.eclipse.emf.compare.utils.EMFComparePredicates.removed; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.regex.Pattern; + +import org.eclipse.emf.common.util.BasicMonitor; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.compare.AttributeChange; +import org.eclipse.emf.compare.Comparison; +import org.eclipse.emf.compare.Conflict; +import org.eclipse.emf.compare.Diff; +import org.eclipse.emf.compare.DifferenceKind; +import org.eclipse.emf.compare.DifferenceState; +import org.eclipse.emf.compare.ReferenceChange; +import org.eclipse.emf.compare.merge.BatchMerger; +import org.eclipse.emf.compare.tests.postprocess.data.TestPostProcessor; +import org.eclipse.emf.compare.uml2.internal.StereotypedElementChange; +import org.eclipse.emf.compare.uml2.internal.postprocessor.StereotypedElementChangePostProcessor; +import org.eclipse.emf.compare.uml2.tests.AbstractUMLProfileTest; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.util.UMLUtil; + +/** + * Abstract class used to test the merge of {@link StereotypedElementChange}. + * + * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> + */ +@SuppressWarnings("restriction") +public abstract class AbstractStereotypedElementChangeTests extends AbstractUMLProfileTest { + + @Override + protected void registerPostProcessors( + org.eclipse.emf.compare.postprocessor.IPostProcessor.Descriptor.Registry<String> postProcessorRegistry) { + super.registerPostProcessors(postProcessorRegistry); + postProcessorRegistry.put(StereotypedElementChangePostProcessor.class.getName(), + new TestPostProcessor.TestPostProcessorDescriptor(Pattern + .compile("http://www.eclipse.org/uml2/\\d\\.0\\.0/UML"), null, //$NON-NLS-1$ + new StereotypedElementChangePostProcessor(), 25)); + } + + /** + * Tests that no {@link StereotypedElementChange} is created when applying a stereotype on an existing + * element. + * <p> + * <h3>Inputs</h4> + * </p> + * <h3>Left model</h3> + * + * <pre> + * <Model> aModel + * `-- <<ACliche>> <Class> Test + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * <b>ACliche [base <<ACliche>> <Class> Test]</b> + * </pre> + * + * <h3>Right model</h3> + * + * <pre> + * <Model> aModel + * `-- <Class> Test + * </pre> + * + * @throws IOException + */ + protected void testApplyStereotypeOnExistingElement(Resource left, Resource right) throws IOException { + + final Comparison comparison = compare(left, right); + + EList<Diff> differences = comparison.getDifferences(); + Iterable<StereotypedElementChange> stereotypesChanges = getStereotypedElementChanges(differences, + DifferenceKind.ADD); + assertEquals(0, Iterables.size(stereotypesChanges)); + + } + + /** + * Tests that no {@link StereotypedElementChange} is created when unapplying a stereotype. + * <p> + * <h3>Inputs</h4> + * </p> + * <h3>Left model</h3> + * + * <pre> + * <Model> aModel + * `-- <Class> Test + * </pre> + * + * <h3>Right model</h3> + * + * <pre> + * <Model> aModel + * `-- <<ACliche>> <Class> Test + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * <b>ACliche [base <<ACliche>> <Class> Test]</b> + * </pre> + * + * @throws IOException + */ + protected void testRemoveStereotypeOnExistingElement(Resource left, Resource right) throws IOException { + + final Comparison comparison = compare(left, right); + + EList<Diff> differences = comparison.getDifferences(); + Iterable<StereotypedElementChange> stereotypesChanges = getStereotypedElementChanges(differences, + DifferenceKind.DELETE); + assertEquals(0, Iterables.size(stereotypesChanges)); + + } + + /** + * Tests basic use case: + * <ol> + * <li>Creates a {@link StereotypedElementChange} of kind {@link DifferenceKind#ADD}</li> + * <li>Merges it from left to right</li> + * </ol> + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * `-- <b><<ACliche>> <Class> Class0</b> + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * <b>ACliche [base <<ACliche>> <Class> Class0]</b> + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * <h4>Expected right model after merging</h4> + * + * <pre> + * <Model> model + * `-- <<ACliche>> <Class> Class0 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche>> <Class> Class0] + * </pre> + * + * </p> + * + * @throws IOException + */ + protected void testAddStereotypedElementMergeLToR(Resource left, Resource right) throws IOException { + + final Comparison comparison = compare(left, right); + + // Checks comparison model + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.ADD, 2); + + assertAddedBaseElementDiff(differences, "model.Class0", stereotypedElementChange); //$NON-NLS-1$ + + // Merges + mergeLeftToRight(stereotypedElementChange); + + // Checks comparison model state + for (Diff diff : differences) { + assertSame(DifferenceState.MERGED, diff.getState()); + } + + // Checks right model content after merging + assertEqualsM1(right); + + // Checks left model content after merging + assertEqualsM1(left); + + } + + /** + * Tests basic use case: + * <ol> + * <li>Creates a {@link StereotypedElementChange} of kind {@link DifferenceKind#DELETE}</li> + * <li>Merges it from left to right</li> + * </ol> + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * `--<b> <<ACliche>> <Class> Class0</b> + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * <b>ACliche [base <<ACliche>> <Class> Class0]</b> + * </pre> + * + * <h4>Expected right model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * </p> + * + * @throws IOException + */ + protected void testDelStereotypedElementMergeLToR(Resource left, Resource right) throws IOException { + + final Comparison comparison = compare(left, right); + + // Checks comparison model + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.DELETE, 2); + + assertDeletedBaseElementDiff(differences, "model.Class0", stereotypedElementChange); //$NON-NLS-1$ + + // Merges + mergeLeftToRight(stereotypedElementChange); + + // Checks comparison model + for (Diff diff : differences) { + assertSame(DifferenceState.MERGED, diff.getState()); + } + + // Checks right model content after merging + assertEqualsM2(right); + + // Checks left model content after merging + assertEqualsM2(left); + } + + /** + * Tests basic use case: + * <ol> + * <li>Creates a {@link StereotypedElementChange} of kind {@link DifferenceKind#ADD}</li> + * <li>Merges it from right to left</li> + * </ol> + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * `-- <b><<ACliche>> <Class> Class0</b> + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * <b>ACliche [base <<ACliche>> <Class> Class0]</b> + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * <h4>Expected left model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * </p> + * + * @throws IOException + */ + protected void testAddStereotypedElementMergeRToL(Resource left, Resource right) throws IOException { + + final Comparison comparison = compare(left, right); + + // Checks comparison model + EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.ADD, 2); + assertAddedBaseElementDiff(differences, "model.Class0", stereotypedElementChange); //$NON-NLS-1$ + + // Merges + mergeRightToLeft(stereotypedElementChange); + + // Checks comparison model after merging + for (Diff diff : differences) { + assertSame(DifferenceState.MERGED, diff.getState()); + } + + // Checks right model content after merging + assertEqualsM2(right); + + // Checks left model content after merging + assertEqualsM2(left); + } + + /** + * Tests basic use case: + * <ol> + * <li>Creates a {@link StereotypedElementChange} of kind {@link DifferenceKind#DELETE}</li> + * <li>Merges it from right to left</li> + * </ol> + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * `-- <b><<ACliche>> <Class> Class0</b> + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * <b>ACliche [base <<ACliche>> <Class> Class0]</b> + * </pre> + * + * <h4>Expected left model</h4> + * + * <pre> + * <Model> model + * `-- <<ACliche>> <Class> Class0 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche>> <Class> Class0] + * </pre> + * + * </p> + * + * @throws IOException + */ + protected void testDelStereotypedElementMergeRToL(Resource left, Resource right) throws IOException { + + final Comparison comparison = compare(left, right); + + // Checks model structure + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.DELETE, 2); + + assertDeletedBaseElementDiff(differences, "model.Class0", stereotypedElementChange); //$NON-NLS-1$ + + // Merges + mergeRightToLeft(stereotypedElementChange); + for (Diff diff : differences) { + assertSame(DifferenceState.MERGED, diff.getState()); + } + + // Checks right model content after merging + assertEqualsM1(right); + + // Checks left model content after merging + assertEqualsM1(left); + } + + /** + * Tests advanced use case: + * <ol> + * <li>Creates a {@link StereotypedElementChange} of kind {@link DifferenceKind#ADD} with dependencies + * (requires creation of parent + profile application)</li> + * <li>Merges it from left to right</li> + * </ol> + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * `-- <b><Model> MyNiceModel + * `-- <<ACliche>> <Class> Class1 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche>> <Class> Class1]</b> + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * </pre> + * + * <h4>Expected right model</h4> + * + * <pre> + * <Model> model + * `-- <Model> MyNiceModel + * `-- <<ACliche>> <Class> Class1 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche>> <Class> Class1] + * </pre> + * + * </p> + * + * @throws IOException + */ + protected void testAddStereotypedElementLToR2(Resource left, Resource right) throws IOException { + + final Comparison comparison = compare(left, right); + + // Checks model structure + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.ADD, 2); + + assertAddedBaseElementDiff(differences, "model.MyNiceModel.Class1", stereotypedElementChange); //$NON-NLS-1$ + + // Merge + mergeLeftToRight(stereotypedElementChange); + + // Checks comparison model + for (Diff diff : differences) { + assertSame(DifferenceState.MERGED, diff.getState()); + } + + // Checks right model content after merging + assertEqualsM3(right); + + // Checks left model content after merging + assertEqualsM3(left); + + } + + /** + * Tests advanced use case: + * <ol> + * <li>Creates a {@link StereotypedElementChange} of kind {@link DifferenceKind#DELETE} with dependencies + * (requires creation of parent + profile application)</li> + * <li>Merges it from left to right</li> + * </ol> + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * `-- <Model> MyNiceModel + * `-- <<ACliche>> <Class> Class1 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche>> <Class> Class1] + * </pre> + * + * <h4>Expected right model</h4> + * + * <pre> + * <Model> model + * `-- <Model> MyNiceModel + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * </p> + * + * @throws IOException + */ + protected void testDelStereotypedElementLToR2(Resource left, Resource right) throws IOException { + + final Comparison comparison = compare(left, right); + + // Checks differences + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.DELETE, 2); + + assertDeletedBaseElementDiff(differences, "model.MyNiceModel.Class1", stereotypedElementChange); //$NON-NLS-1$ + + // Merges + mergeLeftToRight(stereotypedElementChange); + + // Checks comparison model + Set<Diff> expectedMergeDifferences = getRefinedByClosure(stereotypedElementChange); + for (Diff diff : differences) { + final DifferenceState expectedDiffState; + if (expectedMergeDifferences.contains(diff) || stereotypedElementChange.equals(diff)) { + expectedDiffState = DifferenceState.MERGED; + } else { + expectedDiffState = DifferenceState.UNRESOLVED; + } + assertSame(expectedDiffState, diff.getState()); + } + + // Checks the content of the right model after merging + // @formatter:off + EList<EObject> contents = right.getContents(); + assertEquals(1, contents.size()); + Model model = (Model)contents.get(0); + assertEquals(1, model.getPackagedElements().size()); + Model subModel = (Model)model.getPackagedElements().get(0); + assertEquals(0, subModel.getPackagedElements().size()); + assertEquals(1,subModel.getAppliedProfiles().size()); + // @formatter:on + + // Checks the content of the left model after merging + assertEqualsM6(left); + } + + /** + * Tests advanced use case: + * <ol> + * <li>Creates a {@link StereotypedElementChange} of kind {@link DifferenceKind#ADD} with dependencies + * (requires creation of parent + profile application)</li> + * <li>Merges it from right to left</li> + * </ol> + * <p> + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * `--<b> <Model> MyNiceModel + * `-- <<ACliche>> <Class> Class1 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche>> <Class> Class1]</b> + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * </pre> + * + * <h4>Expected left model</h4> + * + * <pre> + * <Model> model + * `--<b> <Model> MyNiceModel + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * </p> + * + * @throws IOException + */ + protected void testAddStereotypedElementRToL2(Resource left, Resource right) throws IOException { + + final Comparison comparison = compare(left, right); + + // Checks differences + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.ADD, 2); + + assertAddedBaseElementDiff(differences, "model.MyNiceModel.Class1", stereotypedElementChange); //$NON-NLS-1$ + + // Merges + mergeRightToLeft(stereotypedElementChange); + + // Checks comparison model after merging + Set<Diff> expectedMergeDifferences = getRefinedByClosure(stereotypedElementChange); + for (Diff diff : differences) { + final DifferenceState expectedDiffState; + if (expectedMergeDifferences.contains(diff) || stereotypedElementChange.equals(diff)) { + expectedDiffState = DifferenceState.MERGED; + } else { + expectedDiffState = DifferenceState.UNRESOLVED; + } + assertSame(expectedDiffState, diff.getState()); + } + + // Checks left model content after merging + // @formatter:off + EList<EObject> contents = left.getContents(); + assertEquals(1, contents.size()); + Model model = (Model)contents.get(0); + assertEquals(1, model.getPackagedElements().size()); + Model subModel = (Model)model.getPackagedElements().get(0); + assertEquals(0, subModel.getPackagedElements().size()); + assertEquals(1,subModel.getAppliedProfiles().size()); + // @formatter:on + + // Checks right model content after merging + assertEqualsM6(right); + } + + /** + * Tests advanced use case: + * <ol> + * <li>Creates a {@link StereotypedElementChange} of kind {@link DifferenceKind#DELL} with dependencies</li> + * <li>Merges it from right to left</li> + * </ol> + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * `--<b> <Model> MyNiceModel + * `-- <<ACliche>> <Class> Class1 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche>> <Class> Class1]</b> + * </pre> + * + * <h4>Expected left model</h4> + * + * <pre> + * <Model> model + * `-- <Model> MyNiceModel + * `-- <<ACliche>> <Class> Class1 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche>> <Class> Class1] + * </pre> + * + * </p> + * + * @throws IOException + */ + protected void testDelStereotypedElementRToL2(Resource left, Resource right) throws IOException { + + final Comparison comparison = compare(left, right); + + // Checks model structure + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.DELETE, 2); + + assertDeletedBaseElementDiff(differences, "model.MyNiceModel.Class1", stereotypedElementChange); //$NON-NLS-1$ + // Merges + mergeRightToLeft(stereotypedElementChange); + + // Check comparison model + // Everything should be merged + for (Diff diff : differences) { + assertSame(DifferenceState.MERGED, diff.getState()); + } + + // Checks left model content after merging + assertEqualsM3(left); + + // Checks right model content after merging + assertEqualsM3(right); + + } + + /** + * Tests to merge a {@link StereotypedElementChange} of kind ADD with 2 stereotypes being applied from + * left to right. + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * `--<b> <<ACliche, ACliche3>> <Class> Class0</b> + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * <b>ACliche [base <<ACliche, ACliche3>> <Class> Class0]</b> + * <b>ACliche3 [base <<ACliche, ACliche3>> <Class> Class0]</b> + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * <h4>Expected right model</h4> + * + * <pre> + * <Model> model + * `-- <<ACliche, ACliche3>> <Class> Class0 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche, ACliche3>> <Class> Class0] + * ACliche3 [base <<ACliche, ACliche3>> <Class> Class0] + * </pre> + * + * </p> + * + * @param left + * @param right + */ + protected void testAddMultipleStereotypesLToR(Resource left, Resource right) { + final Comparison comparison = compare(left, right); + + // Checks differences + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.ADD, 3); + + assertAddedBaseElementDiff(differences, "model.Class0", stereotypedElementChange); //$NON-NLS-1$ + + // Merges + mergeLeftToRight(stereotypedElementChange); + + // Checks comparison model after merging + for (Diff diff : differences) { + assertSame(DifferenceState.MERGED, diff.getState()); + } + + // Checks right model content after merging + assertEqualsM7(right); + + // Checks left model content after merging + assertEqualsM7(left); + + } + + /** + * Tests to merge of a {@link StereotypedElementChange} of kind ADD with 2 stereotypes being applied from + * right to left. + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * `-- <b><<ACliche, ACliche3>> <Class> Class0</b> + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * <b>ACliche [base <<ACliche, ACliche3>> <Class> Class0]</b> + * <b>ACliche3 [base <<ACliche, ACliche3>> <Class> Class0]</b> + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * <h4>Expected left model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * @param left + * @param right + */ + protected void testAddMultipleStereotypesRToL(Resource left, Resource right) { + final Comparison comparison = compare(left, right); + + // Checks differences + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.ADD, 3); + + assertAddedBaseElementDiff(differences, "model.Class0", stereotypedElementChange); //$NON-NLS-1$ + + // Merges + mergeRightToLeft(stereotypedElementChange); + + // Check comparison model + for (Diff diff : differences) { + assertSame(DifferenceState.MERGED, diff.getState()); + } + + // Checks left model content after merging + assertEqualsM2(left); + + // Checks right model content after merging + assertEqualsM2(right); + + } + + /** + * Tests to merge a {@link StereotypedElementChange} of kind DELETE in conflict with another diff from + * right to left. + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * `-- <b><<ACliche, ACliche3>> <Class> Class0_newName</b> + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * <b>ACliche [base <<ACliche, ACliche3>> <Class> Class0_newName]</b> + * <b>ACliche3 [base <<ACliche, ACliche3>> <Class> Class0_newName]</b> + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * <h4>Ancestor model</h4> + * + * <pre> + * <Model> model + * `-- <<ACliche, ACliche3>> <Class> Class0 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche, ACliche3>> <Class> Class0] + * ACliche3 [base <<ACliche, ACliche3>> <Class> Class0] + * </pre> + * + * <h4>Expected left model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * </p> + * + * @param left + * @param right + * @param origin + */ + protected void testDelConflictRToL(Resource left, Resource right, Resource origin) { + final Comparison comparison = compare(left, right, origin); + + // Checks differences + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.DELETE, 3); + + final ReferenceChange baseDiff = assertDeletedBaseElementDiff(differences, + "model.Class0", stereotypedElementChange); //$NON-NLS-1$ + + final Conflict conflict = stereotypedElementChange.getConflict(); + assertNotNull(conflict); + assertEquals(3, conflict.getDifferences().size()); + + final EList<Diff> leftDifferences = conflict.getLeftDifferences(); + assertEquals(1, leftDifferences.size()); + + final Diff leftDiff = leftDifferences.get(0); + assertTrue(leftDiff instanceof AttributeChange); + assertEquals(2, conflict.getRightDifferences().size()); + assertTrue(conflict.getRightDifferences().contains(baseDiff)); + + // Merges + mergeRightToLeft(stereotypedElementChange); + + for (Diff diff : differences) { + assertSame(DifferenceState.MERGED, diff.getState()); + } + // Checks left model content after merging + assertEqualsM2(left); + + // Checks right model content after merging + assertEqualsM2(right); + + } + + /** + * Tests to merge a {@link StereotypedElementChange} of kind DELETE in conflict with another diff from + * left to right. + * <p> + * <h3>Inputs</h3> + * <h4>Left model</h4> + * + * <pre> + * <Model> model + * `-- <b><<ACliche, ACliche3>> <Class> Class0_newName</b> + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * <b>ACliche [base <<ACliche, ACliche3>> <Class> Class0_newName]</b> + * <b>ACliche3 [base <<ACliche, ACliche3>> <Class> Class0_newName]</b> + * </pre> + * + * <h4>Right model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * <h4>Ancestor model</h4> + * + * <pre> + * <Model> model + * `-- <<ACliche, ACliche3>> <Class> Class0 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche, ACliche3>> <Class> Class0] + * ACliche3 [base <<ACliche, ACliche3>> <Class> Class0] + * </pre> + * + * <h4>Expected right model</h4> + * + * <pre> + * <Model> model + * `-- <<ACliche, ACliche3>> <Class> Class0_newName + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche, ACliche3>> <Class> Class0_newName] + * ACliche3 [base <<ACliche, ACliche3>> <Class> Class0_newName] + * </pre> + * + * </p> + * + * @param left + * @param right + * @param origin + */ + protected void testAbstractDelConflictLToR(Resource left, Resource right, Resource origin) { + final Comparison comparison = compare(left, right, origin); + + // Checks model structure + final EList<Diff> differences = comparison.getDifferences(); + final StereotypedElementChange stereotypedElementChange = getStereotypedElementChange(differences, + DifferenceKind.DELETE, 3); + + final ReferenceChange baseDiff = assertDeletedBaseElementDiff(differences, + "model.Class0", stereotypedElementChange); //$NON-NLS-1$ + + final Conflict conflict = stereotypedElementChange.getConflict(); + assertNotNull(conflict); + assertEquals(3, conflict.getDifferences().size()); + + final EList<Diff> leftDifferences = conflict.getLeftDifferences(); + assertEquals(1, leftDifferences.size()); + + final Diff leftConflictDiff = leftDifferences.get(0); + + assertTrue(leftConflictDiff instanceof AttributeChange); + assertEquals(2, conflict.getRightDifferences().size()); + assertTrue(conflict.getRightDifferences().contains(baseDiff)); + // Merges + mergeLeftToRight(stereotypedElementChange); + + for (Diff diff : differences) { + if (leftConflictDiff.equals(diff)) { + assertSame(DifferenceState.UNRESOLVED, diff.getState()); + } else { + assertSame(DifferenceState.MERGED, diff.getState()); + } + } + + // Checks right model content after merging + assertEqualsM4(right); + + // Checks left model content after merging + assertEqualsM5(left); + + } + + /** + * Checks that the input has the same structure than described bellow: + * <p> + * <h4>Expected model</h4> + * + * <pre> + * <Model> model + * `-- <<ACliche>> <Class> Class0 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche>> <Class> Class0] + * </pre> + * + * </p> + * + * @param input + */ + private void assertEqualsM1(final Resource input) { + // @formatter:off + EList<EObject> contents = input.getContents(); + assertEquals(2, contents.size()); + Model model = (Model)contents.get(0); + assertEquals(1, model.getPackagedElements().size()); + Class clazz = (Class)model.getPackagedElements().get(0); + assertEquals(1, clazz.getAppliedStereotypes().size()); + assertEquals(1,model.getAppliedProfiles().size()); + EObject stereotypeApplication = contents.get(1); + assertSame(clazz, UMLUtil.getBaseElement(stereotypeApplication)); + // @formatter:on + } + + /** + * Checks that the input has the same structure than described bellow: + * <p> + * <h4>Expected model</h4> + * + * <pre> + * <Model> model + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * </pre> + * + * </p> + * + * @param input + */ + private void assertEqualsM2(final Resource input) { + // @formatter:off + EList<EObject> contents = input.getContents(); + assertEquals(1, contents.size()); + Model model = (Model)contents.get(0); + assertEquals(0, model.getPackagedElements().size()); + assertEquals(1,model.getAppliedProfiles().size()); + // @formatter:on + } + + /** + * Checks that the input has the same structure than described bellow: + * <p> + * <h4>Expected model</h4> + * + * <pre> + * <Model> model + * `-- <Model> MyNiceModel + * `-- <<ACliche>> <Class> Class1 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche>> <Class> Class1] + * </pre> + * + * </p> + * + * @param input + */ + private void assertEqualsM3(Resource input) { + // @formatter:off + EList<EObject> contents = input.getContents(); + assertEquals(2, contents.size()); + Model model = (Model)contents.get(0); + assertEquals(1, model.getPackagedElements().size()); + Model subModel = (Model)model.getPackagedElements().get(0); + assertEquals(1, subModel.getPackagedElements().size()); + Class clazz = (Class)subModel.getPackagedElements().get(0); + assertEquals(1, clazz.getAppliedStereotypes().size()); + assertEquals(1,subModel.getAppliedProfiles().size()); + EObject stereotypeApplication = contents.get(1); + assertSame(clazz, UMLUtil.getBaseElement(stereotypeApplication)); + // @formatter:on + } + + /** + * Checks that the input has the same structure than described bellow: + * <p> + * <h4>Expected model</h4> + * + * <pre> + * <Model> model + * `-- <<ACliche, ACliche3>> <Class> Class0_newName + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche, ACliche3>> <Class> Class0_newName] + * ACliche3 [base <<ACliche, ACliche3>> <Class> Class0_newName] + * </pre> + * + * </p> + * + * @param input + */ + private void assertEqualsM4(Resource right) { + //@formatter:off + EList<EObject> contents = right.getContents(); + assertEquals(3, contents.size()); + Model model = (Model)contents.get(0); + assertEquals(1, model.getPackagedElements().size()); + Class clazz = (Class)model.getPackagedElements().get(0); + assertEquals(2, clazz.getAppliedStereotypes().size()); + assertEquals("Class0", clazz.getName()); //$NON-NLS-1$ + assertEquals(1,model.getAppliedProfiles().size()); + EObject stereotypeApplication = contents.get(1); + assertSame(clazz, UMLUtil.getBaseElement(stereotypeApplication)); + EObject stereotypeApplication2 = contents.get(2); + assertSame(clazz, UMLUtil.getBaseElement(stereotypeApplication2)); + //@formatter:on + } + + /** + * Checks that the input has the same structure than described bellow: + * <p> + * <h4>Expected model</h4> + * + * <pre> + * <Model> model + * `-- <<ACliche, ACliche3>> <Class> Class0_newName + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche, ACliche3>> <Class> Class0_newName] + * ACliche3 [base <<ACliche, ACliche3>> <Class> Class0_newName] + * </pre> + * + * </p> + * + * @param input + */ + private void assertEqualsM5(Resource right) { + //@formatter:off + EList<EObject> contents = right.getContents(); + assertEquals(3, contents.size()); + Model model = (Model)contents.get(0); + assertEquals(1, model.getPackagedElements().size()); + Class clazz = (Class)model.getPackagedElements().get(0); + assertEquals(2, clazz.getAppliedStereotypes().size()); + assertEquals("Class0_newName", clazz.getName()); //$NON-NLS-1$ + assertEquals(1,model.getAppliedProfiles().size()); + EObject stereotypeApplication = contents.get(1); + assertSame(clazz, UMLUtil.getBaseElement(stereotypeApplication)); + EObject stereotypeApplication2 = contents.get(2); + assertSame(clazz, UMLUtil.getBaseElement(stereotypeApplication2)); + //@formatter:on + } + + /** + * Checks that the input has the same structure than described bellow: + * <p> + * <h4>Expected model</h4> + * + * <pre> + * <Model> model + * </pre> + * + * </p> + * + * @param input + */ + private void assertEqualsM6(Resource input) { + // @formatter:off + EList<EObject> leftContent = input.getContents(); + assertEquals(1, leftContent.size()); + Model leftModel = (Model)leftContent.get(0); + assertEquals(0, leftModel.getPackagedElements().size()); + assertEquals(0,leftModel.getAppliedProfiles().size()); + // @formatter:on + } + + /** + * Checks that the input has the same structure than described bellow: + * <p> + * <h4>Expected model</h4> + * + * <pre> + * <Model> model + * `-- <<ACliche, ACliche3>> <Class> Class0 + * `-- <Profile Application> UML2CompareTestProfile + * `-- UML + * ACliche [base <<ACliche, ACliche3>> <Class> Class0] + * ACliche3 [base <<ACliche, ACliche3>> <Class> Class0] + * </pre> + * + * </p> + * + * @param input + */ + private void assertEqualsM7(Resource inputs) { + // @formatter:off + EList<EObject> contents = inputs.getContents(); + assertEquals(3, contents.size()); + Model model = (Model)contents.get(0); + assertEquals(1, model.getPackagedElements().size()); + Class clazz = (Class)model.getPackagedElements().get(0); + assertEquals(2, clazz.getAppliedStereotypes().size()); + assertEquals(1,model.getAppliedProfiles().size()); + EObject stereotypeApplication = contents.get(1); + assertSame(clazz, UMLUtil.getBaseElement(stereotypeApplication)); + EObject stereotypeApplication2 = contents.get(2); + assertSame(clazz, UMLUtil.getBaseElement(stereotypeApplication2)); + // @formatter:on + } + + private StereotypedElementChange getStereotypedElementChange(final EList<Diff> differences, + DifferenceKind diffKind, int expectedRefine) { + Iterable<StereotypedElementChange> stereotypesChanges = getStereotypedElementChanges(differences, + diffKind); + assertEquals(1, Iterables.size(stereotypesChanges)); + final StereotypedElementChange stereotypedElementChange = stereotypesChanges.iterator().next(); + assertSame(diffKind, stereotypedElementChange.getKind()); + assertEquals(expectedRefine, stereotypedElementChange.getRefinedBy().size()); + return stereotypedElementChange; + } + + /** + * Gets the closure of the refined by elements from a starting diff. + * + * @param startingDiff + * @return + */ + private Set<Diff> getRefinedByClosure(Diff startingDiff) { + Set<Diff> result = new HashSet<Diff>(); + for (Diff refinedByDiff : startingDiff.getRefinedBy()) { + if (!result.contains(refinedByDiff)) { + getRefinedByClosure(refinedByDiff, result); + } + } + return result; + } + + private void getRefinedByClosure(Diff d, Set<Diff> result) { + result.add(d); + for (Diff refinedByDiff : d.getRefinedBy()) { + if (!result.contains(refinedByDiff)) { + getRefinedByClosure(refinedByDiff, result); + } + } + } + + protected void mergeLeftToRight(Diff difference) { + BatchMerger merger = new BatchMerger(getMergerRegistry()); + merger.copyAllLeftToRight(Collections.singleton(difference), new BasicMonitor()); + } + + protected void mergeRightToLeft(Diff difference) { + BatchMerger merger = new BatchMerger(getMergerRegistry()); + merger.copyAllRightToLeft(Collections.singleton(difference), new BasicMonitor()); + } + + private ReferenceChange assertAddedBaseElementDiff(Iterable<Diff> differences, String qualifiedName, + StereotypedElementChange stereotypedElementChange) { + ReferenceChange referenceChange = (ReferenceChange)Iterables.find(differences, added(qualifiedName)); + assertTrue(stereotypedElementChange.getRefinedBy().contains(referenceChange)); + assertSame(referenceChange.getValue(), stereotypedElementChange.getDiscriminant()); + return referenceChange; + } + + private ReferenceChange assertDeletedBaseElementDiff(Iterable<Diff> differences, String qualifiedName, + StereotypedElementChange stereotypedElementChange) { + ReferenceChange referenceChange = (ReferenceChange)Iterables + .find(differences, removed(qualifiedName)); + assertTrue(stereotypedElementChange.getRefinedBy().contains(referenceChange)); + assertSame(referenceChange.getValue(), stereotypedElementChange.getDiscriminant()); + return referenceChange; + } + + /** + * Gets the {@link StereotypedElementChange}s contained in the input differences. + * + * @param differences + * Input differences. + * @param diffKind + * Kind of difference you are looking for. + * @return + */ + private Iterable<StereotypedElementChange> getStereotypedElementChanges(Iterable<Diff> differences, + DifferenceKind diffKind) { + final Predicate<Diff> selectingPredicate = and(instanceOf(StereotypedElementChange.class), + ofKind(diffKind)); + return Iterables.transform(Iterables.filter(differences, selectingPredicate), + new Function<Diff, StereotypedElementChange>() { + + public StereotypedElementChange apply(Diff input) { + return (StereotypedElementChange)input; + } + }); + } + +} diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/DynamicStereotypedElementChangeTests.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/DynamicStereotypedElementChangeTests.java new file mode 100644 index 000000000..705195322 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/DynamicStereotypedElementChangeTests.java @@ -0,0 +1,173 @@ +/******************************************************************************* + * Copyright (c) 2014 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.uml2.tests.stereotypes; + +import java.io.IOException; + +import org.eclipse.emf.common.EMFPlugin; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.UML2CompareTestProfilePackage; +import org.eclipse.emf.compare.uml2.tests.AbstractUMLInputData; +import org.eclipse.emf.compare.uml2.tests.stereotypes.data.dynamic.DynamicStereotypeInputData; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.uml2.uml.UMLPlugin; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Tests the {@link org.eclipse.emf.compare.uml2.internal.postprocessor.StereotypedElementChangePostProcessor} + * for model with dynamic profiles. + * + * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> + */ +public class DynamicStereotypedElementChangeTests extends AbstractStereotypedElementChangeTests { + + private DynamicStereotypeInputData input; + + @Override + protected AbstractUMLInputData getInput() { + return input; + } + + static URI registeredURI; + + static Object registeredPackage; + + @BeforeClass + public static void initEPackageNsURIToProfileLocationMap() { + if (!EMFPlugin.IS_ECLIPSE_RUNNING) { + // It is required to link the EPackage to the UML package of the UML Profile + UMLPlugin + .getEPackageNsURIToProfileLocationMap() + .put("http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile", //$NON-NLS-1$ + URI.createURI("pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw")); //$NON-NLS-1$ + } else { + registeredURI = UMLPlugin.getEPackageNsURIToProfileLocationMap().remove( + UML2CompareTestProfilePackage.eNS_URI); + registeredPackage = EPackage.Registry.INSTANCE.remove(UML2CompareTestProfilePackage.eNS_URI); + } + } + + @AfterClass + public static void resetEPackageNsURIToProfileLocationMap() { + if (!EMFPlugin.IS_ECLIPSE_RUNNING) { + UMLPlugin.getEPackageNsURIToProfileLocationMap().remove( + "http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile"); //$NON-NLS-1$ + } else { + UMLPlugin.getEPackageNsURIToProfileLocationMap().put(UML2CompareTestProfilePackage.eNS_URI, + registeredURI); + EPackage.Registry.INSTANCE.put(UML2CompareTestProfilePackage.eNS_URI, registeredPackage); + } + } + + @Before + @Override + public void before() { + super.before(); + input = new DynamicStereotypeInputData(); + + } + + /** + * @see AbstractStereotypedElementChangeTests#testRemoveStereotypeOnExistingElement(Resource, Resource) + */ + @Test + public void testRemoveStereotypeOnExistingElement() throws IOException { + testRemoveStereotypeOnExistingElement(input.getA1Right(), input.getA1Left()); + + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddStereotypedElementMergeLToR(Resource, Resource) + */ + @Test + public void testAddStereotypeElementMergeLToR() throws IOException { + testAddStereotypedElementMergeLToR(input.getA4Left(), input.getA4Right()); + + } + + /** + * @see AbstractStereotypedElementChangeTests#testDelStereotypedElementMergeRToL(Resource, Resource) + */ + @Test + public void testDelStereotypeElementMergeLToR() throws IOException { + testDelStereotypedElementMergeLToR(input.getA4Right(), input.getA4Left()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddStereotypedElementMergeRToL(Resource, Resource) + */ + @Test + public void testAddStereotypeElementMergeRToL() throws IOException { + testAddStereotypedElementMergeRToL(input.getA4Left(), input.getA4Right()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testDelStereotypedElementMergeRToL(Resource, Resource) + */ + @Test + public void testDellStereotypeElementMergeRToL() throws IOException { + testDelStereotypedElementMergeRToL(input.getA4Right(), input.getA4Left()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddStereotypedElementLToR2(Resource, Resource) + */ + @Test + public void testAddStereotypedElementLToR2() throws IOException { + testAddStereotypedElementLToR2(input.getA3Left(), input.getA3Right()); + + } + + /** + * @see AbstractStereotypedElementChangeTests#testDelStereotypedElementLToR2(Resource, Resource) + */ + @Test + public void testDelStereotypedElementLToR2() throws IOException { + testDelStereotypedElementLToR2(input.getA3Right(), input.getA3Left()); + + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddStereotypedElementRToL2(Resource, Resource) + */ + @Test + public void testAddStereotypedElementRToL2() throws IOException { + testAddStereotypedElementRToL2(input.getA3Left(), input.getA3Right()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testDelStereotypedElementRToL2(Resource, Resource) + */ + @Test + public void testDelStereotypedElementRToL2() throws IOException { + testDelStereotypedElementRToL2(input.getA3Right(), input.getA3Left()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddMultipleStereotypesLToR(Resource, Resource) + */ + @Test + public void testAddMultipleStereotypeLToR() throws IOException { + testAddMultipleStereotypesLToR(input.getA12Left(), input.getA12Right()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddMultipleStereotypesRToL(Resource, Resource) + */ + @Test + public void testAddMultipleStereotypeRToL() throws IOException { + testAddMultipleStereotypesRToL(input.getA12Left(), input.getA12Right()); + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/StaticStereotypedElementChangeTests.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/StaticStereotypedElementChangeTests.java new file mode 100644 index 000000000..ad9700aba --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/StaticStereotypedElementChangeTests.java @@ -0,0 +1,183 @@ +/******************************************************************************* + * Copyright (c) 2014 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.uml2.tests.stereotypes; + +import java.io.IOException; +import java.util.Map; + +import org.eclipse.emf.common.EMFPlugin; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.UML2CompareTestProfilePackage; +import org.eclipse.emf.compare.uml2.tests.AbstractUMLInputData; +import org.eclipse.emf.compare.uml2.tests.stereotypes.data.static_.StaticStereotypeInputData; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.uml2.uml.UMLPlugin; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Tests the {@link org.eclipse.emf.compare.uml2.internal.postprocessor.StereotypedElementChangePostProcessor} + * for model with static profiles. + * + * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> + */ +public class StaticStereotypedElementChangeTests extends AbstractStereotypedElementChangeTests { + + private StaticStereotypeInputData input; + + @Override + protected AbstractUMLInputData getInput() { + return input; + } + + @BeforeClass + public static void fillRegistriesForStatic() { + if (!EMFPlugin.IS_ECLIPSE_RUNNING) { + EPackage.Registry.INSTANCE.put(UML2CompareTestProfilePackage.eNS_URI, + UML2CompareTestProfilePackage.eINSTANCE); // registers + // against + // EPackage.Registry + // It is required to link the EPackage to the UML package of the UML Profile + Map<String, URI> ePackageNsURIToProfileLocationMap = UMLPlugin + .getEPackageNsURIToProfileLocationMap(); + ePackageNsURIToProfileLocationMap + .put(UML2CompareTestProfilePackage.eNS_URI, + URI.createURI("pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw")); //$NON-NLS-1$ + } + } + + @AfterClass + public static void resetRegistriesForStatic() { + if (!EMFPlugin.IS_ECLIPSE_RUNNING) { + UMLPlugin.getEPackageNsURIToProfileLocationMap().remove(UML2CompareTestProfilePackage.eNS_URI); + EPackage.Registry.INSTANCE.remove(UML2CompareTestProfilePackage.eNS_URI); + } + } + + @Before + @Override + public void before() { + super.before(); + input = new StaticStereotypeInputData(); + } + + /** + * @see AbstractStereotypedElementChangeTests#testRemoveStereotypeOnExistingElement(Resource, Resource) + */ + @Test + public void testRemoveStereotypeOnExistingElement() throws IOException { + testRemoveStereotypeOnExistingElement(input.getB1Right(), input.getB1Left()); + + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddStereotypedElementMergeLToR(Resource, Resource) + */ + @Test + public void testAddStereotypeElementMergeLToR() throws IOException { + testAddStereotypedElementMergeLToR(input.getB4Left(), input.getB4Right()); + + } + + /** + * @see AbstractStereotypedElementChangeTests#testDelStereotypedElementMergeRToL(Resource, Resource) + */ + @Test + public void testDelStereotypeElementMergeLToR() throws IOException { + // Reverses inputs to create Del diff + testDelStereotypedElementMergeLToR(input.getB4Right(), input.getB4Left()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddStereotypedElementMergeRToL(Resource, Resource) + */ + @Test + public void testAddStereotypeElementMergeRToL() throws IOException { + testAddStereotypedElementMergeRToL(input.getB4Left(), input.getB4Right()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testDelStereotypedElementMergeRToL(Resource, Resource) + */ + @Test + public void testDellStereotypeElementMergeRToL() throws IOException { + testDelStereotypedElementMergeRToL(input.getB4Right(), input.getB4Left()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddStereotypedElementLToR2(Resource, Resource) + */ + @Test + public void testAddStereotypedElementLToR2() throws IOException { + testAddStereotypedElementLToR2(input.getB3Left(), input.getB3Right()); + + } + + /** + * @see AbstractStereotypedElementChangeTests#testDelStereotypedElementLToR2(Resource, Resource) + */ + @Test + public void testDelStereotypedElementLToR2() throws IOException { + testDelStereotypedElementLToR2(input.getB3Right(), input.getB3Left()); + + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddStereotypedElementRToL2(Resource, Resource) + */ + @Test + public void testAddStereotypedElementRToL2() throws IOException { + testAddStereotypedElementRToL2(input.getB3Left(), input.getB3Right()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testDelStereotypedElementRToL2(Resource, Resource) + */ + @Test + public void testDelStereotypedElementRToL2() throws IOException { + testDelStereotypedElementRToL2(input.getB3Right(), input.getB3Left()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddMultipleStereotypesLToR(Resource, Resource) + */ + @Test + public void testAddMultipleStereotypeLToR() throws IOException { + testAddMultipleStereotypesLToR(input.getB12Left(), input.getB12Right()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testAddMultipleStereotypesRToL(Resource, Resource) + */ + @Test + public void testAddMultipleStereotypeRToL() throws IOException { + testAddMultipleStereotypesRToL(input.getB12Left(), input.getB12Right()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testAbstractDelConflictRToL(Resource, Resource) + */ + @Test + public void testDelConflictRToL() throws IOException { + testDelConflictRToL(input.getB13Left(), input.getB13Right(), input.getB13Ancestor()); + } + + /** + * @see AbstractStereotypedElementChangeTests#testAbstractDelConflictLToR(Resource, Resource) + */ + @Test + public void testDelConflictLToR() throws IOException { + testAbstractDelConflictLToR(input.getB13Left(), input.getB13Right(), input.getB13Ancestor()); + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/DynamicStereotypeInputData.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/DynamicStereotypeInputData.java index 1e6392516..13ad7f038 100644 --- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/DynamicStereotypeInputData.java +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/DynamicStereotypeInputData.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2014 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.uml2.tests.stereotypes.data.dynamic; import java.io.IOException; @@ -99,4 +109,24 @@ public class DynamicStereotypeInputData extends AbstractUMLInputData { return loadFromClassLoader("a11/ancestor.uml"); //$NON-NLS-1$ } + public Resource getA12Right() throws IOException { + return loadFromClassLoader("a12/right.uml"); //$NON-NLS-1$ + } + + public Resource getA12Left() throws IOException { + return loadFromClassLoader("a12/left.uml"); //$NON-NLS-1$ + } + + public Resource getB13Left() throws IOException { + return loadFromClassLoader("b13/left.uml"); //$NON-NLS-1$ + } + + public Resource getB13Right() throws IOException { + return loadFromClassLoader("b13/right.uml"); //$NON-NLS-1$ + } + + public Resource getB13Ancestor() throws IOException { + return loadFromClassLoader("b13/origin.uml"); //$NON-NLS-1$ + } + } diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a12/left.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a12/left.uml new file mode 100644 index 000000000..b1908561a --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a12/left.uml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_59tLoPU0EeOznPU7N6uHbQ"> + <uml:Model xmi:id="_GfO3Ifr8EeCcXd0vrIzyPg" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_MNDVkPr8EeCcXd0vrIzyPg" name="Class0"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jAMnAPzmEeGvprorRl_paQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jAMnAfzmEeGvprorRl_paQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_59tLoPU0EeOznPU7N6uHbQ"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> + </uml:Model> + <testProfile:ACliche xmi:id="_lLJboPzmEeGvprorRl_paQ" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> + <testProfile:ACliche3 xmi:id="_pPX_kPVUEeO7Dcw-5FdA8g" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a12/right.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a12/right.uml new file mode 100644 index 000000000..8535fd2c9 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a12/right.uml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_GfO3Ifr8EeCcXd0vrIzyPg" name="model"> +<profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jAMnAPzmEeGvprorRl_paQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jAMnAfzmEeGvprorRl_paQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_59tLoPU0EeOznPU7N6uHbQ"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> +</uml:Model> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a13/left.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a13/left.uml new file mode 100644 index 000000000..edfae8227 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a13/left.uml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <uml:Model xmi:id="_GfO3Ifr8EeCcXd0vrIzyPg" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_MNDVkPr8EeCcXd0vrIzyPg" name="Class0_NewName"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jAMnAPzmEeGvprorRl_paQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jAMnAfzmEeGvprorRl_paQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> + </uml:Model> + <testProfile:ACliche xmi:id="_lLJboPzmEeGvprorRl_paQ" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> + <testProfile:ACliche3 xmi:id="_pPX_kPVUEeO7Dcw-5FdA8g" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a13/origin.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a13/origin.uml new file mode 100644 index 000000000..617ea3a9a --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a13/origin.uml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <uml:Model xmi:id="_GfO3Ifr8EeCcXd0vrIzyPg" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_MNDVkPr8EeCcXd0vrIzyPg" name="Class0"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jAMnAPzmEeGvprorRl_paQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jAMnAfzmEeGvprorRl_paQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> + </uml:Model> + <testProfile:ACliche xmi:id="_lLJboPzmEeGvprorRl_paQ" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> + <testProfile:ACliche3 xmi:id="_pPX_kPVUEeO7Dcw-5FdA8g" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a13/right.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a13/right.uml new file mode 100644 index 000000000..80bff0c28 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/dynamic/a13/right.uml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_GfO3Ifr8EeCcXd0vrIzyPg" name="model"> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jAMnAPzmEeGvprorRl_paQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jAMnAfzmEeGvprorRl_paQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> +</uml:Model> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/StaticStereotypeInputData.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/StaticStereotypeInputData.java index a40ab397b..3c784ce17 100644 --- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/StaticStereotypeInputData.java +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/StaticStereotypeInputData.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2014 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.uml2.tests.stereotypes.data.static_; import java.io.IOException; @@ -87,4 +97,24 @@ public class StaticStereotypeInputData extends AbstractUMLInputData { return loadFromClassLoader("b10/right.uml"); //$NON-NLS-1$ } + public Resource getB12Left() throws IOException { + return loadFromClassLoader("b12/left.uml"); //$NON-NLS-1$ + } + + public Resource getB12Right() throws IOException { + return loadFromClassLoader("b12/right.uml"); //$NON-NLS-1$ + } + + public Resource getB13Left() throws IOException { + return loadFromClassLoader("b13/left.uml"); //$NON-NLS-1$ + } + + public Resource getB13Right() throws IOException { + return loadFromClassLoader("b13/right.uml"); //$NON-NLS-1$ + } + + public Resource getB13Ancestor() throws IOException { + return loadFromClassLoader("b13/origin.uml"); //$NON-NLS-1$ + } + } diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b12/left.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b12/left.uml new file mode 100644 index 000000000..bc78d8496 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b12/left.uml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <uml:Model xmi:id="_GfO3Ifr8EeCcXd0vrIzyPg" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_MNDVkPr8EeCcXd0vrIzyPg" name="Class0"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jAMnAPzmEeGvprorRl_paQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jAMnAfzmEeGvprorRl_paQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="platform:/plugin/org.eclipse.emf.compare.uml2.tests/model/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> + </uml:Model> + <testProfile:ACliche xmi:id="_lLJboPzmEeGvprorRl_paQ" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> + <testProfile:ACliche3 xmi:id="_xgRh8PVYEeOpD7riSMddVA" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b12/right.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b12/right.uml new file mode 100644 index 000000000..80bff0c28 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b12/right.uml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_GfO3Ifr8EeCcXd0vrIzyPg" name="model"> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jAMnAPzmEeGvprorRl_paQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jAMnAfzmEeGvprorRl_paQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> +</uml:Model> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b13/left.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b13/left.uml new file mode 100644 index 000000000..1bfd49fb0 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b13/left.uml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <uml:Model xmi:id="_GfO3Ifr8EeCcXd0vrIzyPg" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_MNDVkPr8EeCcXd0vrIzyPg" name="Class0_newName"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jAMnAPzmEeGvprorRl_paQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jAMnAfzmEeGvprorRl_paQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="platform:/plugin/org.eclipse.emf.compare.uml2.tests/model/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> + </uml:Model> + <testProfile:ACliche xmi:id="_lLJboPzmEeGvprorRl_paQ" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> + <testProfile:ACliche3 xmi:id="_xgRh8PVYEeOpD7riSMddVA" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b13/origin.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b13/origin.uml new file mode 100644 index 000000000..bc78d8496 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b13/origin.uml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <uml:Model xmi:id="_GfO3Ifr8EeCcXd0vrIzyPg" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_MNDVkPr8EeCcXd0vrIzyPg" name="Class0"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jAMnAPzmEeGvprorRl_paQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jAMnAfzmEeGvprorRl_paQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="platform:/plugin/org.eclipse.emf.compare.uml2.tests/model/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> + </uml:Model> + <testProfile:ACliche xmi:id="_lLJboPzmEeGvprorRl_paQ" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> + <testProfile:ACliche3 xmi:id="_xgRh8PVYEeOpD7riSMddVA" base_Class="_MNDVkPr8EeCcXd0vrIzyPg"/> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b13/right.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b13/right.uml new file mode 100644 index 000000000..55d590c32 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/stereotypes/data/static_/b13/right.uml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_GfO3Ifr8EeCcXd0vrIzyPg" name="model"> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jAMnAPzmEeGvprorRl_paQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jAMnAfzmEeGvprorRl_paQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="platform:/plugin/org.eclipse.emf.compare.uml2.tests/model/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> +</uml:Model> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java index 7a0af4d95..b553f1cdc 100644 --- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Obeo. + * Copyright (c) 2012, 2014 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 @@ -39,7 +39,9 @@ import org.eclipse.emf.compare.uml2.tests.message.AddMessageTest; import org.eclipse.emf.compare.uml2.tests.profiles.DynamicProfileTest; import org.eclipse.emf.compare.uml2.tests.profiles.StaticProfileTest; import org.eclipse.emf.compare.uml2.tests.stereotypes.DynamicStereotypeTest; +import org.eclipse.emf.compare.uml2.tests.stereotypes.DynamicStereotypedElementChangeTests; import org.eclipse.emf.compare.uml2.tests.stereotypes.StaticStereotypeTest; +import org.eclipse.emf.compare.uml2.tests.stereotypes.StaticStereotypedElementChangeTests; import org.eclipse.emf.compare.uml2.tests.timeConstraint.AddTimeConstraintTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -58,7 +60,8 @@ import org.junit.runners.Suite.SuiteClasses; AddSubstitutionTest.class, AddUsageTest.class, AddMessageTest.class, AddActionExecutionSpecificationTest.class, AddBehaviorExecutionSpecificationTest.class, AddIncludeTest.class, AddTimeConstraintTest.class, StaticProfileTest.class, DynamicProfileTest.class, - StaticStereotypeTest.class, DynamicStereotypeTest.class, ImplicationsAssociationTest.class, + StaticStereotypeTest.class, StaticStereotypedElementChangeTests.class, DynamicStereotypeTest.class, + DynamicStereotypedElementChangeTests.class, ImplicationsAssociationTest.class, ImplicationsTransitionTest.class, ImplicationsInterfaceRealizationTest.class }) public class AllTests { |