Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-02-17 12:23:54 -0500
committerChristian W. Damus2015-02-17 12:44:04 -0500
commitbc1be322ee5c1d01a37baf09c3c0a9e86241b79a (patch)
tree8363a0fa33bc7605332ebf058c899e09c2cb7533
parent471ad410fcaa6b541dca7496602d6b5f55d5de87 (diff)
downloadorg.eclipse.papyrus-bc1be322ee5c1d01a37baf09c3c0a9e86241b79a.tar.gz
org.eclipse.papyrus-bc1be322ee5c1d01a37baf09c3c0a9e86241b79a.tar.xz
org.eclipse.papyrus-bc1be322ee5c1d01a37baf09c3c0a9e86241b79a.zip
Bug 459488: [Model Import] Stereotypes gone in fragmented model, one large activity diagram is missing
https://bugs.eclipse.org/bugs/show_bug.cgi?id=459488 Support repairing stereotypes in resources whose root element is not a UML Package but some other kind of UML Element (e.g., a Class).
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/StereotypeApplicationRepairSnippet.java26
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/org.eclipse.papyrus.uml.modelrepair.tests.launch2
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/Class1.di2
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/Class1.notation2
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/Class1.uml5
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model.di2
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model.notation42
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model.uml17
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.di2
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.notation45
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.uml31
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/StereotypeRepairRegressionTest.java60
12 files changed, 230 insertions, 6 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/StereotypeApplicationRepairSnippet.java b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/StereotypeApplicationRepairSnippet.java
index c2037a08a7e..99ffbb3e535 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/StereotypeApplicationRepairSnippet.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/StereotypeApplicationRepairSnippet.java
@@ -10,6 +10,7 @@
* Christian W. Damus (CEA) - Initial API and implementation
* Christian W. Damus - bug 455248
* Christian W. Damus - bug 455329
+ * Christian W. Damus - bug 459488
*
*/
package org.eclipse.papyrus.uml.modelrepair.internal.stereotypes;
@@ -143,8 +144,11 @@ public class StereotypeApplicationRepairSnippet implements IModelSetSnippet {
Element root = getRootUMLElement(resource);
// Only check for zombies in resources that we can modify (those being the resources in the user model opened in the editor)
- if ((root instanceof Package) && !EMFHelper.isReadOnly(resource, EMFHelper.resolveEditingDomain(root))) {
- result = getZombieStereotypes(resource, (Package) root);
+ if ((root instanceof Element) && !EMFHelper.isReadOnly(resource, EMFHelper.resolveEditingDomain(root))) {
+ Element rootElement = root;
+ if (rootElement.getNearestPackage() != null) {
+ result = getZombieStereotypes(resource, rootElement);
+ }
}
return result;
@@ -154,7 +158,18 @@ public class StereotypeApplicationRepairSnippet implements IModelSetSnippet {
return (Element) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.ELEMENT);
}
- protected ZombieStereotypesDescriptor getZombieStereotypes(Resource resource, Package root) {
+ /**
+ * Gets the zombie stereotypes (if any) in the scope of the specified {@code root} element.
+ *
+ * @param resource
+ * the resource being scanned for zombie stereotypes
+ * @param root
+ * the root element of the {@code resource}
+ * @return the zombie stereotypes, or {@code null} if there are none needing repair
+ *
+ * @precondition the {@code root} has a {@linkplain Element#getNearestPackage() package context} that can provide stereotype applications
+ */
+ protected ZombieStereotypesDescriptor getZombieStereotypes(Resource resource, Element root) {
ZombieStereotypesDescriptor result = null;
Collection<ProfileApplication> profileApplications = Lists.newArrayList();
@@ -169,7 +184,8 @@ public class StereotypeApplicationRepairSnippet implements IModelSetSnippet {
}
}
- // We also need to get all profile applications inherited from containing packages in parent model units
+ // We also need to get all profile applications inherited from containing packages in parent model units.
+ // Especially in the case that the 'root' is not a Package!
if (root.eContainer() instanceof Element) {
Package containingPackage = ((Element) root.eContainer()).getNearestPackage();
if (containingPackage != null) {
@@ -184,7 +200,7 @@ public class StereotypeApplicationRepairSnippet implements IModelSetSnippet {
profileSupplier = presenter.getDynamicProfileSupplier();
}
- ZombieStereotypesDescriptor zombies = new ZombieStereotypesDescriptor(resource, root, appliedDefinitions, profileSupplier, getLabelProvider());
+ ZombieStereotypesDescriptor zombies = new ZombieStereotypesDescriptor(resource, root.getNearestPackage(), appliedDefinitions, profileSupplier, getLabelProvider());
for (EObject next : resource.getContents()) {
if (!(next instanceof Element)) {
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/org.eclipse.papyrus.uml.modelrepair.tests.launch b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/org.eclipse.papyrus.uml.modelrepair.tests.launch
index f899c4e8f38..6083d8c656a 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/org.eclipse.papyrus.uml.modelrepair.tests.launch
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/org.eclipse.papyrus.uml.modelrepair.tests.launch
@@ -29,7 +29,7 @@
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.papyrus.uml.modelrepair.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Doomph.setup.questionnaire.skip=true"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Doomph.setup.questionnaire.skip=true&#10;-Doomph.setup.skip=true"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/Class1.di b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/Class1.di
new file mode 100644
index 00000000000..bf9abab340f
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/Class1.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/bug459488/Class1.notation b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/Class1.notation
new file mode 100644
index 00000000000..bf9abab340f
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/Class1.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/bug459488/Class1.uml b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/Class1.uml
new file mode 100644
index 00000000000..593e96e52d6
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/Class1.uml
@@ -0,0 +1,5 @@
+<?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:profile="http:///schemas/profile/_afjq0LakEeSRy7TNM6JrNA/0" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http:///schemas/profile/_afjq0LakEeSRy7TNM6JrNA/0 model2.profile.uml">
+ <uml:Class xmi:id="_dfoJkLakEeSRy7TNM6JrNA" name="Class1"/>
+ <profile:Stereotype1 xmi:id="_mMo9ALakEeSRy7TNM6JrNA" base_Class="_dfoJkLakEeSRy7TNM6JrNA"/>
+</xmi:XMI>
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model.di b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model.di
new file mode 100644
index 00000000000..bf9abab340f
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/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/bug459488/model.notation b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model.notation
new file mode 100644
index 00000000000..b542f3f09b6
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model.notation
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:css="http://www.eclipse.org/papyrus/infra/gmfdiag/css" 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">
+ <notation:Diagram xmi:id="_S4nuoLakEeSRy7TNM6JrNA" type="PapyrusUMLClassDiagram" name="NewDiagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_lGkFwLakEeSRy7TNM6JrNA" type="2008">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_l7050LakEeSRy7TNM6JrNA" source="Stereotype_Annotation">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_mMo9AbakEeSRy7TNM6JrNA" key="StereotypeWithQualifiedNameList" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_mMo9ArakEeSRy7TNM6JrNA" key="StereotypeList" value="profile::Stereotype1"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_mMo9A7akEeSRy7TNM6JrNA" key="Stereotype_Presentation_Kind" value="HorizontalStereo"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_mMo9BLakEeSRy7TNM6JrNA" key="PropStereoDisplay" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_mMo9BbakEeSRy7TNM6JrNA" key="StereotypePropertyLocation" value="Compartment"/>
+ </eAnnotations>
+ <children xmi:type="notation:DecorationNode" xmi:id="_lGkFwrakEeSRy7TNM6JrNA" type="5029"/>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_lGkFw7akEeSRy7TNM6JrNA" type="7017">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_lGkFxLakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_lGkFxbakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_lGkFxrakEeSRy7TNM6JrNA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_lGkFx7akEeSRy7TNM6JrNA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_lGkFyLakEeSRy7TNM6JrNA" type="7018">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_lGkFybakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_lGkFyrakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_lGkFy7akEeSRy7TNM6JrNA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_lGkFzLakEeSRy7TNM6JrNA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_lGkFzbakEeSRy7TNM6JrNA" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_lGkFzrakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_lGkFz7akEeSRy7TNM6JrNA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_lGkF0LakEeSRy7TNM6JrNA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_lGkF0bakEeSRy7TNM6JrNA"/>
+ </children>
+ <element xmi:type="uml:Class" href="Class1.uml#_dfoJkLakEeSRy7TNM6JrNA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_lGkFwbakEeSRy7TNM6JrNA" x="462" y="308"/>
+ </children>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_S4nuobakEeSRy7TNM6JrNA" name="diagram_compatibility_version" stringValue="1.0.0"/>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_S4nuorakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="style:PapyrusViewStyle" xmi:id="_S4nuo7akEeSRy7TNM6JrNA">
+ <owner xmi:type="uml:Model" href="model.uml#_S4LpwLakEeSRy7TNM6JrNA"/>
+ </styles>
+ <element xmi:type="uml:Model" href="model.uml#_S4LpwLakEeSRy7TNM6JrNA"/>
+ </notation:Diagram>
+ <css:ModelStyleSheets xmi:id="_bVkFwLakEeSRy7TNM6JrNA"/>
+</xmi:XMI>
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model.uml b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model.uml
new file mode 100644
index 00000000000..186e7664b79
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model.uml
@@ -0,0 +1,17 @@
+<?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="_S4LpwLakEeSRy7TNM6JrNA" name="model">
+ <packagedElement xmi:type="uml:Class" href="Class1.uml#_dfoJkLakEeSRy7TNM6JrNA"/>
+ <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_csKFQLakEeSRy7TNM6JrNA">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_cs5sIbakEeSRy7TNM6JrNA" source="PapyrusVersion">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_cs5sIrakEeSRy7TNM6JrNA" key="Version" value="0.0.1"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_cs5sI7akEeSRy7TNM6JrNA" key="Comment" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_cs5sJLakEeSRy7TNM6JrNA" key="Copyright" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_cs5sJbakEeSRy7TNM6JrNA" key="Date" value="2015-02-17"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_cs5sJrakEeSRy7TNM6JrNA" key="Author" value=""/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_cs5sILakEeSRy7TNM6JrNA" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="model2.profile.uml#_aftb0bakEeSRy7TNM6JrNA"/>
+ </eAnnotations>
+ <appliedProfile xmi:type="uml:Profile" href="model2.profile.uml#_WWvbULakEeSRy7TNM6JrNA"/>
+ </profileApplication>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.di b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.di
new file mode 100644
index 00000000000..bf9abab340f
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.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/bug459488/model2.profile.notation b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.notation
new file mode 100644
index 00000000000..44e7a9de4a8
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.notation
@@ -0,0 +1,45 @@
+<?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="_WW5MULakEeSRy7TNM6JrNA" type="PapyrusUMLProfileDiagram" name="NewDiagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_XKXQoLakEeSRy7TNM6JrNA" type="1026">
+ <children xmi:type="notation:DecorationNode" xmi:id="_XKXQorakEeSRy7TNM6JrNA" type="1034"/>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_XKXQo7akEeSRy7TNM6JrNA" type="1071">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_XKXQpLakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_XKXQpbakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_XKXQprakEeSRy7TNM6JrNA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_XKXQp7akEeSRy7TNM6JrNA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_XKXQqLakEeSRy7TNM6JrNA" type="1019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_XKXQqbakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_XKXQqrakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_XKXQq7akEeSRy7TNM6JrNA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_XKXQrLakEeSRy7TNM6JrNA"/>
+ </children>
+ <element xmi:type="uml:Stereotype" href="model2.profile.uml#_XKEVsLakEeSRy7TNM6JrNA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_XKXQobakEeSRy7TNM6JrNA" x="838" y="441"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_Zf49kLakEeSRy7TNM6JrNA" type="1031">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_ZgCHgLakEeSRy7TNM6JrNA" source="Stereotype_Annotation">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ZgCHgbakEeSRy7TNM6JrNA" key="StereotypeWithQualifiedNameList" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ZgCHgrakEeSRy7TNM6JrNA" key="StereotypeList" value="StandardProfile::Metaclass"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ZgCHg7akEeSRy7TNM6JrNA" key="Stereotype_Presentation_Kind" value="HorizontalStereo"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ZgCHhLakEeSRy7TNM6JrNA" key="PropStereoDisplay" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ZgCHhbakEeSRy7TNM6JrNA" key="StereotypePropertyLocation" value="Compartment"/>
+ </eAnnotations>
+ <children xmi:type="notation:DecorationNode" xmi:id="_Zf49krakEeSRy7TNM6JrNA" type="1084"/>
+ <element xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Zf49k7akEeSRy7TNM6JrNA" x="840" y="221"/>
+ </children>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_WW5MUbakEeSRy7TNM6JrNA" name="diagram_compatibility_version" stringValue="1.0.0"/>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_WW5MUrakEeSRy7TNM6JrNA"/>
+ <styles xmi:type="style:PapyrusViewStyle" xmi:id="_WW5MU7akEeSRy7TNM6JrNA">
+ <owner xmi:type="uml:Profile" href="model2.profile.uml#_WWvbULakEeSRy7TNM6JrNA"/>
+ </styles>
+ <element xmi:type="uml:Profile" href="model2.profile.uml#_WWvbULakEeSRy7TNM6JrNA"/>
+ <edges xmi:type="notation:Connector" xmi:id="_Z3sZkLakEeSRy7TNM6JrNA" type="1013" source="_XKXQoLakEeSRy7TNM6JrNA" target="_Zf49kLakEeSRy7TNM6JrNA">
+ <styles xmi:type="notation:FontStyle" xmi:id="_Z3sZkbakEeSRy7TNM6JrNA"/>
+ <element xmi:type="uml:Extension" href="model2.profile.uml#_Z3iokbakEeSRy7TNM6JrNA"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Z3sZkrakEeSRy7TNM6JrNA" points="[-3, -50, 7, 195]$[-3, -270, 7, -25]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Z_bZQLakEeSRy7TNM6JrNA" id="(0.52,0.0)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Z_bZQbakEeSRy7TNM6JrNA" id="(0.5,1.0)"/>
+ </edges>
+</notation:Diagram>
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.uml b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.uml
new file mode 100644
index 00000000000..d7e4f5cc845
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.modelrepair.tests/resources/regression/bug459488/model2.profile.uml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Profile 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="_WWvbULakEeSRy7TNM6JrNA" name="profile" metaclassReference="_ZfSgoLakEeSRy7TNM6JrNA">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_aftb0LakEeSRy7TNM6JrNA" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <contents xmi:type="ecore:EPackage" xmi:id="_aftb0bakEeSRy7TNM6JrNA" name="profile" nsURI="http:///schemas/profile/_afjq0LakEeSRy7TNM6JrNA/0" nsPrefix="profile">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_aftb17akEeSRy7TNM6JrNA" source="PapyrusVersion">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_aftb2LakEeSRy7TNM6JrNA" key="Version" value="0.0.1"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_aftb2bakEeSRy7TNM6JrNA" key="Comment" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_aftb2rakEeSRy7TNM6JrNA" key="Copyright" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_aftb27akEeSRy7TNM6JrNA" key="Date" value="2015-02-17"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_aftb3LakEeSRy7TNM6JrNA" key="Author" value=""/>
+ </eAnnotations>
+ <eClassifiers xmi:type="ecore:EClass" xmi:id="_aftb0rakEeSRy7TNM6JrNA" name="Stereotype1">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_aftb07akEeSRy7TNM6JrNA" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_XKEVsLakEeSRy7TNM6JrNA"/>
+ <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_aftb1LakEeSRy7TNM6JrNA" name="base_Class" ordered="false" lowerBound="1">
+ <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
+ </eStructuralFeatures>
+ </eClassifiers>
+ </contents>
+ </eAnnotations>
+ <elementImport xmi:type="uml:ElementImport" xmi:id="_ZfSgoLakEeSRy7TNM6JrNA" alias="Class">
+ <importedElement xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
+ </elementImport>
+ <packagedElement xmi:type="uml:Stereotype" xmi:id="_XKEVsLakEeSRy7TNM6JrNA" name="Stereotype1">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_Z3iokLakEeSRy7TNM6JrNA" name="base_Class" association="_Z3iokbakEeSRy7TNM6JrNA">
+ <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
+ </ownedAttribute>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Extension" xmi:id="_Z3iokbakEeSRy7TNM6JrNA" name="E_Stereotype1_Class1" memberEnd="_Z3iokrakEeSRy7TNM6JrNA _Z3iokLakEeSRy7TNM6JrNA">
+ <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_Z3iokrakEeSRy7TNM6JrNA" name="extension_Stereotype1" type="_XKEVsLakEeSRy7TNM6JrNA" aggregation="composite" association="_Z3iokbakEeSRy7TNM6JrNA"/>
+ </packagedElement>
+</uml:Profile>
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 8ec42f5237b..3189613300e 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
@@ -11,11 +11,13 @@
* Christian W. Damus - bug 455248
* Christian W. Damus - bug 455329
* Christian W. Damus - bug 436666
+ * Christian W. Damus - bug 459488
*
*/
package org.eclipse.papyrus.uml.modelrepair.internal.stereotypes;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
@@ -25,24 +27,31 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.common.util.ECollections;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.core.utils.TransactionHelper;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.eclipse.papyrus.junit.utils.rules.ModelSetFixture;
import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.uml2.common.util.UML2Util;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.ProfileApplication;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLPackage;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -50,6 +59,7 @@ import org.junit.Test;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
/**
@@ -274,6 +284,38 @@ public class StereotypeRepairRegressionTest extends AbstractPapyrusTest {
assertThat(model.eResource().getContents(), is(ECollections.singletonEList((EObject) model)));
}
+ /**
+ * Tests that a scenario involving a malformed XSI schema-location for a profile schema in a non-package model fragment
+ * (sub-unit resource) is correctly detected and repaired.
+ *
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=459488
+ */
+ @Test
+ @Bug("459488")
+ @PluginResource("/resources/regression/bug459488/model.di")
+ public void badSchemaLocationInNonPackageFragment_bug459488() throws InterruptedException {
+ // Load the sub-unit, triggering (we hope) repair
+ EcoreUtil.resolveAll(modelSet.getModelResource());
+
+ Class class1 = (Class) model.getOwnedType("Class1");
+
+ // Scan the sub-unit for stereotype problems
+ zombies = fixture.getZombieStereotypes(class1.eResource(), class1);
+
+ IAdaptable schema = getOnlyZombieSchema();
+ IRepairAction action = zombies.getSuggestedRepairAction(schema);
+ assertThat("Wrong suggested repair action", action.kind(), is(IRepairAction.Kind.APPLY_LATEST_PROFILE_DEFINITION));
+
+ repair(schema, action);
+
+ // Verify the stereotype application that was migrated
+ Stereotype stereotype1 = class1.getAppliedStereotype("profile::Stereotype1");
+ assertThat("Stereotype1 does not seem to be applied", stereotype1, notNullValue());
+
+ // And that the migrated stereotype application is in the correct resource (the sub-model unit)
+ assertThat("Stereotype1 application in wrong resource", class1.getStereotypeApplication(stereotype1).eResource(), is(class1.eResource()));
+ }
+
//
// Test framework
//
@@ -361,6 +403,23 @@ public class StereotypeRepairRegressionTest extends AbstractPapyrusTest {
return houseKeeper.cleanUpLater(new StereotypeApplicationRepairSnippet(Functions.constant((Profile) null)), "dispose", modelSet.getResourceSet());
}
+ @Bug("459488")
+ protected StereotypeApplicationRepairSnippet createLocalProfileFixture() throws CoreException {
+ // Get the profile to supply for repairing
+ URI profileURI = null;
+ for (IFile next : Iterables.filter(Arrays.asList(modelSet.getProject().getProject().members()), IFile.class)) {
+ if (next.getName().endsWith(".profile.uml")) {
+ // This looks like our "local profile"
+ profileURI = URI.createPlatformResourceURI(next.getFullPath().toString(), true);
+ break;
+ }
+ }
+ assertThat("No profile resource found in test project", profileURI, notNullValue());
+ Profile profile = UML2Util.load(modelSet.getResourceSet(), profileURI, UMLPackage.Literals.PROFILE);
+
+ return houseKeeper.cleanUpLater(new StereotypeApplicationRepairSnippet(Functions.constant(profile)), "dispose", modelSet.getResourceSet());
+ }
+
void repair(final IAdaptable schema, final IRepairAction action) {
try {
TransactionHelper.run(modelSet.getEditingDomain(), new Runnable() {
@@ -377,6 +436,7 @@ public class StereotypeRepairRegressionTest extends AbstractPapyrusTest {
}
IAdaptable getOnlyZombieSchema() {
+ assertThat("No zombie packages found", zombies, notNullValue());
Collection<? extends IAdaptable> schemata = zombies.getZombieSchemas();
assertThat("Wrong number of zombie packages", schemata.size(), is(1));
return schemata.iterator().next();

Back to the top