diff options
author | Christian W. Damus | 2014-12-15 19:26:22 +0000 |
---|---|---|
committer | Christian W. Damus | 2014-12-15 19:37:41 +0000 |
commit | 2e90ebd361a5ec9e64244c734cacafbfc6df2ced (patch) | |
tree | a9ef404443700513a4552b7de487c38be63eb089 /tests | |
parent | 5a2226b011989c4de4ec8cef444dba6d963cf2ce (diff) | |
download | org.eclipse.papyrus-2e90ebd361a5ec9e64244c734cacafbfc6df2ced.tar.gz org.eclipse.papyrus-2e90ebd361a5ec9e64244c734cacafbfc6df2ced.tar.xz org.eclipse.papyrus-2e90ebd361a5ec9e64244c734cacafbfc6df2ced.zip |
455248: [Stereotypes Repair] The Stereotypes Repair dialog doesn't properly handle Controlled Packages without their own Profile Application
https://bugs.eclipse.org/bugs/show_bug.cgi?id=455248
Ensure that profile applications inherited from containing package contents (in case of a package unit being loaded) are properly accounted for to avoid spurious zombie reports.
Diffstat (limited to 'tests')
7 files changed, 143 insertions, 12 deletions
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/Package1.di b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/Package1.di new file mode 100644 index 00000000000..cac982021da --- /dev/null +++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/Package1.di @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi"> + <sashModel currentSelection="//@sashModel/@windows.0/@children.0"> + <windows> + <children xsi:type="di:TabFolder"/> + </windows> + </sashModel> +</di:SashWindowsMngr> diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/Package1.notation b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/Package1.notation new file mode 100644 index 00000000000..bf9abab340f --- /dev/null +++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/Package1.notation @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/> diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/Package1.uml b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/Package1.uml new file mode 100644 index 00000000000..279841c57e6 --- /dev/null +++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/Package1.uml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/5" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/5 pathmap://UML_PROFILES/Ecore.profile.uml#_z1OFcHjqEdy8S4Cr8Rc_NA"> + <uml:Package xmi:id="_y6CX0IR_EeStyqE6C7UDFA" name="Package1"> + <packagedElement xmi:type="uml:Class" xmi:id="_zwZ_IIR_EeStyqE6C7UDFA" name="Class1"/> + </uml:Package> + <Ecore:EClass xmi:id="_6nLpsIR_EeStyqE6C7UDFA" base_Class="_zwZ_IIR_EeStyqE6C7UDFA"/> +</xmi:XMI> diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/model.di b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/model.di new file mode 100644 index 00000000000..bf9abab340f --- /dev/null +++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/model.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/> diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/model.notation b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/model.notation new file mode 100644 index 00000000000..f89b3bd720f --- /dev/null +++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/model.notation @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_xPp5oIR_EeStyqE6C7UDFA" type="PapyrusUMLClassDiagram" name="classes" measurementUnit="Pixel"> + <children xmi:type="notation:Shape" xmi:id="_y6ttQIR_EeStyqE6C7UDFA" type="2007"> + <children xmi:type="notation:DecorationNode" xmi:id="_y6x-sIR_EeStyqE6C7UDFA" type="5026"/> + <children xmi:type="notation:DecorationNode" xmi:id="_y6zz4IR_EeStyqE6C7UDFA" type="7016"> + <children xmi:type="notation:Shape" xmi:id="_zwmzcIR_EeStyqE6C7UDFA" type="3010"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_6nbhUIR_EeStyqE6C7UDFA" source="Stereotype_Annotation"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_6ncIYIR_EeStyqE6C7UDFA" key="StereotypeWithQualifiedNameList" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_6ncIYYR_EeStyqE6C7UDFA" key="StereotypeList" value="Ecore::EClass"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_6ncIYoR_EeStyqE6C7UDFA" key="Stereotype_Presentation_Kind" value="HorizontalStereo"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_6ncIY4R_EeStyqE6C7UDFA" key="PropStereoDisplay" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_6ncIZIR_EeStyqE6C7UDFA" key="StereotypePropertyLocation" value="Compartment"/> + </eAnnotations> + <children xmi:type="notation:DecorationNode" xmi:id="_zwnagIR_EeStyqE6C7UDFA" type="5014"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_zwqd0IR_EeStyqE6C7UDFA" type="7011"> + <styles xmi:type="notation:TitleStyle" xmi:id="_zwqd0YR_EeStyqE6C7UDFA"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_zwqd0oR_EeStyqE6C7UDFA"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_zwqd04R_EeStyqE6C7UDFA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_zwqd1IR_EeStyqE6C7UDFA"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_zwqd1YR_EeStyqE6C7UDFA" type="7012"> + <styles xmi:type="notation:TitleStyle" xmi:id="_zwqd1oR_EeStyqE6C7UDFA"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_zwqd14R_EeStyqE6C7UDFA"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_zwqd2IR_EeStyqE6C7UDFA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_zwqd2YR_EeStyqE6C7UDFA"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_zwqd2oR_EeStyqE6C7UDFA" type="7013"> + <styles xmi:type="notation:TitleStyle" xmi:id="_zwqd24R_EeStyqE6C7UDFA"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_zwqd3IR_EeStyqE6C7UDFA"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_zwqd3YR_EeStyqE6C7UDFA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_zwqd3oR_EeStyqE6C7UDFA"/> + </children> + <element xmi:type="uml:Class" href="Package1.uml#_zwZ_IIR_EeStyqE6C7UDFA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_zwmzcYR_EeStyqE6C7UDFA" x="48" y="13"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_y6zz4YR_EeStyqE6C7UDFA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_y6zz4oR_EeStyqE6C7UDFA"/> + </children> + <element xmi:type="uml:Package" href="Package1.uml#_y6CX0IR_EeStyqE6C7UDFA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_y6ttQYR_EeStyqE6C7UDFA" x="46" y="70" width="283" height="173"/> + </children> + <styles xmi:type="notation:StringValueStyle" xmi:id="_xPp5oYR_EeStyqE6C7UDFA" name="diagram_compatibility_version" stringValue="1.0.0"/> + <styles xmi:type="notation:DiagramStyle" xmi:id="_xPp5ooR_EeStyqE6C7UDFA"/> + <styles xmi:type="style:PapyrusViewStyle" xmi:id="_xPp5o4R_EeStyqE6C7UDFA"> + <owner xmi:type="uml:Model" href="model.uml#_xNmrMIR_EeStyqE6C7UDFA"/> + </styles> + <element xmi:type="uml:Model" href="model.uml#_xNmrMIR_EeStyqE6C7UDFA"/> +</notation:Diagram> diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/model.uml b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/model.uml new file mode 100644 index 00000000000..f62f39f6c91 --- /dev/null +++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug455248/model.uml @@ -0,0 +1,13 @@ +<?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="_xNmrMIR_EeStyqE6C7UDFA" name="Model"> + <packageImport xmi:type="uml:PackageImport" xmi:id="_xNmrMYR_EeStyqE6C7UDFA"> + <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/> + </packageImport> + <packagedElement xmi:type="uml:Package" href="Package1.uml#_y6CX0IR_EeStyqE6C7UDFA"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_3afrQIR_EeStyqE6C7UDFA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_3a4FwIR_EeStyqE6C7UDFA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="pathmap://UML_PROFILES/Ecore.profile.uml#_z1OFcHjqEdy8S4Cr8Rc_NA"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/> + </profileApplication> +</uml:Model> diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/StereotypeRepairRegressionTest.java b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/StereotypeRepairRegressionTest.java index 9ff8491945b..ba7e76e88cd 100644 --- a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/StereotypeRepairRegressionTest.java +++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/StereotypeRepairRegressionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 CEA and others. + * Copyright (c) 2014 CEA, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,6 +8,7 @@ * * Contributors: * Christian W. Damus (CEA) - Initial API and implementation + * Christian W. Damus - bug 455248 * */ package org.eclipse.papyrus.uml.modelrepair.internal.stereotypes; @@ -17,7 +18,13 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Method; import java.util.Collection; +import java.util.Set; import org.eclipse.emf.ecore.EPackage; import org.eclipse.papyrus.infra.core.utils.TransactionHelper; @@ -37,6 +44,7 @@ import org.junit.Test; import com.google.common.base.Function; import com.google.common.base.Functions; +import com.google.common.collect.ImmutableSet; /** @@ -148,6 +156,7 @@ public class StereotypeRepairRegressionTest extends AbstractPapyrusTest { * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=436666 */ @Test + @Bug("436666") @PluginResource("/resources/regression/bug436666/model2.uml") public void nestedPackageInProfileIsOK_bug436666() { assertThat("Should not have found zombie stereotypes", zombies, nullValue()); @@ -160,6 +169,7 @@ public class StereotypeRepairRegressionTest extends AbstractPapyrusTest { * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=436666 */ @Test + @Bug("436666") @PluginResource("/resources/regression/bug436666/model2-missing-schemalocation.uml") public void nestedPackageSchemaMissing_bug436666() { EPackage schema = getOnlyZombieSchema(); @@ -188,11 +198,26 @@ public class StereotypeRepairRegressionTest extends AbstractPapyrusTest { * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=436666 */ @Test + @Bug("436666bis") @PluginResource("/resources/regression/bug436666/model-with-stylesheet.uml") public void nonStereotypeApplicationsAreOK_bug436666() { assertThat("Should not have found zombie stereotypes", zombies, nullValue()); } + /** + * Tests that a sub-united model in which package units do not repeat profile applications, + * but rather just inherit them from parent units, such as might be imported from some other + * UML tool, does not falsely trigger repair. + * + * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=455248 + */ + @Test + @Bug("455248") + @PluginResource("/resources/regression/bug455248/model.uml") + public void packageUnitWithoutOwnProfileApplication_bug455248() { + assertThat("Should not have found zombie stereotypes", zombies, nullValue()); + } + // // Test framework // @@ -201,24 +226,38 @@ public class StereotypeRepairRegressionTest extends AbstractPapyrusTest { public void createFixture() throws Exception { model = modelSet.getModel(); - if (modelSet.getModelResourceURI().toString().contains("model-with-stylesheet")) { - createSimpleFixture(); - } else if (modelSet.getModelResourceURI().toString().contains("bug436666")) { - createBug436666Fixture(); + // Look for fixture-method correlation + Method fixtureMethod = null; + Method test = getClass().getMethod(this.houseKeeper.getTestName()); + if (test.isAnnotationPresent(Bug.class)) { + String bug = test.getAnnotation(Bug.class).value()[0]; + for (Method next : getClass().getDeclaredMethods()) { + if (next.isAnnotationPresent(Bug.class) && StereotypeApplicationRepairSnippet.class.isAssignableFrom(next.getReturnType())) { + Set<String> bugs = ImmutableSet.copyOf(next.getAnnotation(Bug.class).value()); + if (bugs.contains(bug)) { + fixtureMethod = next; + break; + } + } + } + } + + if (fixtureMethod == null) { + fixture = createDefaultFixture(); } else { - createDefaultFixture(); + fixture = (StereotypeApplicationRepairSnippet) fixtureMethod.invoke(this); } fixture.start(modelSet.getResourceSet()); houseKeeper.setField("zombies", fixture.getZombieStereotypes(modelSet.getModelResource(), modelSet.getModel())); } - protected void createDefaultFixture() { + protected StereotypeApplicationRepairSnippet createDefaultFixture() { final Profile rootProfile = model.getAppliedProfile("Profile"); final Profile nested1 = model.getNestedPackage("Package1").getAppliedProfile("Profile::Nested1"); final Profile nested2 = model.getNestedPackage("Package2").getAppliedProfile("Profile::Nested2"); - fixture = houseKeeper.cleanUpLater(new StereotypeApplicationRepairSnippet(new Function<EPackage, Profile>() { + return houseKeeper.cleanUpLater(new StereotypeApplicationRepairSnippet(new Function<EPackage, Profile>() { @Override public Profile apply(EPackage input) { @@ -238,11 +277,12 @@ public class StereotypeRepairRegressionTest extends AbstractPapyrusTest { }), "dispose", modelSet.getResourceSet()); } - protected void createBug436666Fixture() { + @Bug("436666") + protected StereotypeApplicationRepairSnippet createBug436666Fixture() { final Profile rootProfile = model.getAppliedProfile("Profile"); final Profile nestedProfile = model.getAppliedProfile("Profile::Profile1"); - fixture = houseKeeper.cleanUpLater(new StereotypeApplicationRepairSnippet(new Function<EPackage, Profile>() { + return houseKeeper.cleanUpLater(new StereotypeApplicationRepairSnippet(new Function<EPackage, Profile>() { @Override public Profile apply(EPackage input) { @@ -260,8 +300,9 @@ public class StereotypeRepairRegressionTest extends AbstractPapyrusTest { }), "dispose", modelSet.getResourceSet()); } - protected void createSimpleFixture() { - fixture = houseKeeper.cleanUpLater(new StereotypeApplicationRepairSnippet(Functions.constant((Profile) null)), "dispose", modelSet.getResourceSet()); + @Bug({ "436666bis", "455248" }) + protected StereotypeApplicationRepairSnippet createSimpleFixture() { + return houseKeeper.cleanUpLater(new StereotypeApplicationRepairSnippet(Functions.constant((Profile) null)), "dispose", modelSet.getResourceSet()); } void repair(final EPackage schema, final IRepairAction action) { @@ -284,4 +325,14 @@ public class StereotypeRepairRegressionTest extends AbstractPapyrusTest { assertThat("Wrong number of zombie packages", schemata.size(), is(1)); return schemata.iterator().next(); } + + // + // Nested types + // + + @Target(ElementType.METHOD) + @Retention(RetentionPolicy.RUNTIME) + private @interface Bug { + String[] value(); + } } |