Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-06-21 13:10:50 +0000
committerGerrit Code Review @ Eclipse.org2016-06-23 03:01:41 +0000
commit2639899e0ecf328775f1c0558c8f41d697cf44c8 (patch)
tree490af2ea3aabe010f8104ad005b24dab5592089b
parent96b817577296aa9ca6ff288aad28a8c15a3cf8ab (diff)
downloadorg.eclipse.papyrus-rt-2639899e0ecf328775f1c0558c8f41d697cf44c8.tar.gz
org.eclipse.papyrus-rt-2639899e0ecf328775f1c0558c8f41d697cf44c8.tar.xz
org.eclipse.papyrus-rt-2639899e0ecf328775f1c0558c8f41d697cf44c8.zip
Bug 462323: [Model Import] Structure diagram gets a name even if it has none in the source model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=462323 Make use of access to trace history provided by the Papyrus framework to clear out the defaulted names for diagrams whose originals in the RSA model did not have names. Change-Id: I01a4fe4bb6242e3ca3e1c06585bf02a31ae097ba
-rw-r--r--plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/META-INF/MANIFEST.MF3
-rw-r--r--plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/src/org/eclipse/papyrusrt/umlrt/migration/rsa/extension/ImportRTTransformationExtension.java45
-rw-r--r--plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/transform/PapyrusRTCommon.qvto88
-rw-r--r--plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/transform/PapyrusRTDiagrams.qvto66
-rw-r--r--tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/resources/rt/WrongViewTypeExampleWithNames.emx74
-rw-r--r--tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/src/org/eclipse/papyrusrt/umlrt/migration/rsa/tests/qvt/CapsuleStructureDiagramImportTest.java41
-rw-r--r--tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/src/org/eclipse/papyrusrt/umlrt/migration/rsa/tests/qvt/StateMachineDiagramImportTest.java45
7 files changed, 278 insertions, 84 deletions
diff --git a/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/META-INF/MANIFEST.MF b/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/META-INF/MANIFEST.MF
index 205f06b76..d7c0d7494 100644
--- a/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/META-INF/MANIFEST.MF
+++ b/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/META-INF/MANIFEST.MF
@@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.migration.rsa;bundle-version="1.2.0",
org.eclipse.papyrusrt.umlrt.profile;bundle-version="0.7.0",
org.eclipse.m2m.qvt.oml;bundle-version="3.6.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0"
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
+ org.eclipse.papyrus.m2m.qvto;bundle-version="1.2.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrusrt.umlrt.tooling.rsa.umlrt,
diff --git a/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/src/org/eclipse/papyrusrt/umlrt/migration/rsa/extension/ImportRTTransformationExtension.java b/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/src/org/eclipse/papyrusrt/umlrt/migration/rsa/extension/ImportRTTransformationExtension.java
index a03238639..4b2d4bff4 100644
--- a/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/src/org/eclipse/papyrusrt/umlrt/migration/rsa/extension/ImportRTTransformationExtension.java
+++ b/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/src/org/eclipse/papyrusrt/umlrt/migration/rsa/extension/ImportRTTransformationExtension.java
@@ -8,7 +8,7 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Christian W. Damus - bug 495572
+ * Christian W. Damus - bugs 495572, 462323
*
*****************************************************************************/
package org.eclipse.papyrusrt.umlrt.migration.rsa.extension;
@@ -32,7 +32,6 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.m2m.qvt.oml.BasicModelExtent;
import org.eclipse.m2m.qvt.oml.ExecutionContext;
-import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic;
import org.eclipse.m2m.qvt.oml.ModelExtent;
import org.eclipse.m2m.qvt.oml.TransformationExecutor;
import org.eclipse.papyrus.migration.rsa.concurrent.ExecutorsPool;
@@ -109,26 +108,7 @@ public class ImportRTTransformationExtension implements TransformationExtension
// Don't add the CacheAdapter to registered EPackages
extents.add(getInRTProfileDefinitions());
- TransformationExecutor executor;
- try {
- executor = getTransformation(transformationURI, monitor);
- } catch (DiagnosticException ex) {
- Diagnostic diagnostic = ex.getDiagnostic();
- Activator.log.warn(String.format("Cannot load the transformation : %s. Diagnostic: %s", transformationURI, diagnostic.getMessage()));
- return createStatusFromDiagnostic(diagnostic);
- }
-
- ExecutionDiagnostic result;
- synchronized (executor) {
- try {
- result = executor.execute(context, extents.toArray(new ModelExtent[0]));
- } finally {
- executor.cleanup();
- executorsPool.releaseExecutor(executor);
- }
- }
-
- return createStatusFromDiagnostic(result);
+ return importTransformation.runTransformation(transformationURI, extents, monitor);
}
protected IStatus importRTDiagrams(ExecutionContext context, IProgressMonitor monitor) {
@@ -147,26 +127,7 @@ public class ImportRTTransformationExtension implements TransformationExtension
// Add the viewpoints configuration models
extents.add(initializeExtent(getInUMLRTViewpointConfigurations()));
- TransformationExecutor executor;
- try {
- executor = getTransformation(transformationURI, monitor);
- } catch (DiagnosticException ex) {
- Diagnostic diagnostic = ex.getDiagnostic();
- Activator.log.warn(String.format("Cannot load the transformation : %s. Diagnostic: %s", transformationURI, diagnostic.getMessage()));
- return createStatusFromDiagnostic(diagnostic);
- }
-
- ExecutionDiagnostic result;
- synchronized (executor) {
- try {
- result = executor.execute(context, extents.toArray(new ModelExtent[extents.size()]));
- } finally {
- executor.cleanup();
- executorsPool.releaseExecutor(executor);
- }
- }
-
- return createStatusFromDiagnostic(result);
+ return importTransformation.runTransformation(transformationURI, extents, monitor);
}
protected ModelExtent initializeExtent(ModelExtent extent) {
diff --git a/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/transform/PapyrusRTCommon.qvto b/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/transform/PapyrusRTCommon.qvto
index 8195fc042..f44d7d04b 100644
--- a/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/transform/PapyrusRTCommon.qvto
+++ b/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/transform/PapyrusRTCommon.qvto
@@ -11,12 +11,37 @@
*
*****************************************************************************/
+import org.eclipse.papyrus.m2m.qvto.Traces;
+
modeltype uml "strict" uses 'http://www.eclipse.org/uml2/5.0.0/UML';
modeltype umlrt "strict" uses 'http://www.eclipse.org/papyrus/umlrt';
modeltype umlrtsm "strict" uses 'http://www.eclipse.org/papyrus/umlrt/statemachine';
+modeltype notation "strict" uses 'http://www.eclipse.org/gmf/runtime/1.0.2/notation';
library PapyrusRTCommon;
+query uml::Element::getOriginal() : uml::Element
+{
+ var myTrace : uml::Element := self.invresolveone(uml::Element);
+ return if myTrace.oclIsUndefined() then
+ // Try the black-box to access the previous transformations' traces
+ self.traceFrom('uml::Element').oclAsType(uml::Element)
+ else
+ myTrace
+ endif;
+}
+
+query notation::Diagram::getOriginal() : notation::Diagram
+{
+ var myTrace : notation::Diagram := self.invresolveone(notation::Diagram);
+ return if myTrace.oclIsUndefined() then
+ // Try the black-box to access the previous transformations' traces
+ self.traceFrom('notation::Diagram').oclAsType(notation::Diagram)
+ else
+ myTrace
+ endif;
+}
+
/**
* Is a class a Capsule?
*/
@@ -35,7 +60,6 @@ query uml::StateMachine::isRTStateMachine() : Boolean
self.getStereotypeApplications()->exists(oclIsKindOf(umlrtsm::RTStateMachine));
}
-
/**
* Is a state an RTState?
*/
@@ -44,3 +68,65 @@ query uml::State::isRTState() : Boolean
return not self.oclIsUndefined() and
self.getStereotypeApplications()->exists(oclIsKindOf(umlrtsm::RTState));
}
+
+/**
+ * Is an element a context for UML-RT diagrams?
+ */
+query uml::NamedElement::isRTContext() : Boolean
+{
+ return self.oclIsKindOf(uml::State) and self.oclAsType(uml::State).isRTState()
+ or self.oclIsKindOf(uml::StateMachine) and self.oclAsType(uml::StateMachine).isRTStateMachine()
+ or self.oclIsKindOf(uml::Class) and self.oclAsType(uml::Class).isCapsule();
+}
+
+query uml::NamedElement::hasName() : Boolean
+{
+ return not self.oclIsUndefined() and
+ not self.name.oclIsUndefined() and
+ self.name <> '';
+}
+
+query notation::Diagram::hasName() : Boolean
+{
+ return not self.oclIsUndefined() and
+ not self.name.oclIsUndefined() and
+ self.name <> '';
+}
+
+query uml::NamedElement::diagramContextElement() : uml::NamedElement
+{
+ return if self.oclIsKindOf(uml::Vertex) then
+ self.oclAsType(uml::Vertex).containingStateMachine().diagramContextElement()
+ elif self.oclIsKindOf(uml::Behavior) then
+ self.oclAsType(uml::Behavior).context.diagramContextElement()
+ else
+ self
+ endif;
+}
+
+query notation::Diagram::contextElement() : uml::NamedElement
+{
+ return if self.element.oclIsKindOf(uml::NamedElement) then
+ self.element.oclAsType(uml::NamedElement).diagramContextElement()
+ endif;
+}
+
+query notation::Diagram::isUMLRTDiagram() : Boolean
+{
+ var context : uml::NamedElement := self.contextElement();
+
+ return not context.oclIsUndefined() and context.isRTContext();
+}
+
+query notation::Diagram::isCapsuleDiagram() : Boolean
+{
+ return self.type = 'CompositeStructure' and
+ self.element.oclAsType(uml::Class).isCapsule();
+}
+
+query notation::Diagram::isRTStateMachineDiagram() : Boolean
+{
+ return self.type = 'PapyrusUMLStateMachineDiagram' and
+ (self.element.oclAsType(uml::StateMachine).isRTStateMachine() or
+ self.element.oclAsType(uml::State).isRTState());
+}
diff --git a/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/transform/PapyrusRTDiagrams.qvto b/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/transform/PapyrusRTDiagrams.qvto
index d910c7577..837eb5659 100644
--- a/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/transform/PapyrusRTDiagrams.qvto
+++ b/plugins/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa/transform/PapyrusRTDiagrams.qvto
@@ -23,53 +23,39 @@ modeltype vpstyle "strict" uses 'http://www.eclipse.org/papyrus/infra/viewpoints
transformation PapyrusRTDiagrams(inout semantics : uml, inout graphics : notation, in vpconfigs : viewpoints);
main() {
- graphics.rootObjects()[notation::Diagram].map addViewpoint();
+ graphics.rootObjects()[notation::Diagram].map cleanUpDiagram();
}
-/**
- * Ensures that the correct viewpoint prototype style is added to capsule structure diagrams.
- */
-mapping inout notation::Diagram::addCSDViewpoint()
-when { self.type = 'CompositeStructure' and
- self.element.oclAsType(uml::Class).isCapsule() }
+mapping inout notation::Diagram::cleanUpDiagram()
+when { self.isUMLRTDiagram() }
{
- // First, clear out any existing view style
- self.styles := self.styles->reject(oclIsKindOf(PapyrusViewStyle));
+ // Fix the name
+ var source := self.getOriginal();
+ if (source.oclIsKindOf(notation::Diagram) and not source.oclAsType(notation::Diagram).hasName()) {
+ self.name := null;
+ };
- // Create the view style
- self.styles += object vpstyle::PapyrusViewStyle {
- owner := self.element; // Diagram owner
- _configuration := getDiagramPrototype('UML-RT Capsule Structure Diagram');
- }
-}
-
-/**
- * Ensures that the correct viewpoint prototype style is added to capsule state machine diagrams.
- */
-mapping inout notation::Diagram::addSMDViewpoint()
-when { self.type = 'PapyrusUMLStateMachineDiagram' and
- (self.element.oclAsType(uml::StateMachine).isRTStateMachine() or
- self.element.oclAsType(uml::State).isRTState()) }
-{
- // First, clear out any existing view style
- self.styles := self.styles->reject(oclIsKindOf(PapyrusViewStyle));
+ // Find the appropriate viewpoint configuration prototype, if any
+ var protoConfig : viewpoints::PapyrusDiagram :=
+ switch {
+ case (self.isCapsuleDiagram()) getDiagramPrototype('UML-RT Capsule Structure Diagram');
+ case (self.isRTStateMachineDiagram()) getDiagramPrototype('UML-RT State Machine Diagram');
+ else null;
+ };
- // Create the view style
- self.styles += object vpstyle::PapyrusViewStyle {
- owner := self.element; // Diagram owner
- _configuration := getDiagramPrototype('UML-RT State Machine Diagram');
- }
+ if (not protoConfig.oclIsUndefined()) {
+ // First, clear out any existing view style so we can add the correct one
+ self.styles := self.styles->reject(oclIsKindOf(PapyrusViewStyle));
+
+ // Create the view style
+ self.styles += object vpstyle::PapyrusViewStyle {
+ owner := self.element; // Diagram owner
+ _configuration := protoConfig;
+ };
+ }
}
-/**
- * The union of viewpoint mappings.
- */
-mapping inout notation::Diagram::addViewpoint()
- disjuncts notation::Diagram::addCSDViewpoint,
- notation::Diagram::addSMDViewpoint
-{}
-
helper getDiagramPrototype(name : String) : viewpoints::PapyrusDiagram
{
return vpconfigs.objectsOfKind(PapyrusDiagram)->any(d | d.name = name)
-}
+} \ No newline at end of file
diff --git a/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/resources/rt/WrongViewTypeExampleWithNames.emx b/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/resources/rt/WrongViewTypeExampleWithNames.emx
new file mode 100644
index 000000000..c6f87c5a8
--- /dev/null
+++ b/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/resources/rt/WrongViewTypeExampleWithNames.emx
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--xtools2_universal_type_manager-->
+<?com.ibm.xtools.emf.core.signature <signature id="com.ibm.xtools.mmi.ui.signatures.diagram" version="7.0.0"><feature description="" name="Rational Modeling Platform (com.ibm.xtools.rmp)" url="" version="7.0.0"/></signature>?>
+<?com.ibm.xtools.emf.core.signature <signature id="com.ibm.xtools.uml.msl.model" version="7.0.0"><feature description="" name="com.ibm.xtools.ruml.feature" url="" version="7.0.0"/></signature>?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:UMLRealTime="http:///schemas/UMLRealTime/_3TUzoHq6Ed2hSeAAWZznoA/119" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmlns:umlnotation="http://www.ibm.com/xtools/1.5.3/Umlnotation" xsi:schemaLocation="http:///schemas/UMLRealTime/_3TUzoHq6Ed2hSeAAWZznoA/119 pathmap://RT_PROPERTIES/UMLRealTime.epx#_3TUzoXq6Ed2hSeAAWZznoA?UMLRealTime/UMLRealTime?">
+ <uml:Package xmi:id="_y_WEwCyAEeaKlOrmJ6XmAw" name="WrongViewTypeExample">
+ <eAnnotations xmi:id="_y_WEwSyAEeaKlOrmJ6XmAw" source="uml2.diagrams"/>
+ <eAnnotations xmi:id="_y_WEwyyAEeaKlOrmJ6XmAw" source="com.ibm.xtools.common.ui.reduction.editingCapabilities">
+ <details xmi:id="_y_WExCyAEeaKlOrmJ6XmAw" key="uml.rt.activity" value="2"/>
+ </eAnnotations>
+ <packagedElement xmi:type="uml:Class" xmi:id="_7_Ow4CyAEeaKlOrmJ6XmAw" name="Capsule1">
+ <eAnnotations xmi:id="_8LnnECyAEeaKlOrmJ6XmAw" source="uml2.diagrams" references="_8LnnESyAEeaKlOrmJ6XmAw">
+ <contents xmi:type="umlnotation:UMLDiagram" xmi:id="_8LnnESyAEeaKlOrmJ6XmAw" type="Structure" element="_7_Ow4CyAEeaKlOrmJ6XmAw" measurementUnit="Himetric" name="My Favourite Capsule">
+ <children xmi:type="umlnotation:UMLShape" xmi:id="_8LoOICyAEeaKlOrmJ6XmAw" type="StructureDiagramFrame" element="_7_Ow4CyAEeaKlOrmJ6XmAw" fontName="Sans" fontHeight="8" transparency="0" lineColor="14263149" lineWidth="1" showStereotype="Label">
+ <children xmi:type="umlnotation:UMLShapeCompartment" xmi:id="_8LoOISyAEeaKlOrmJ6XmAw" type="StructureCompartment"/>
+ <children xmi:type="notation:BasicDecorationNode" xmi:id="_8LoOIiyAEeaKlOrmJ6XmAw" type="Name"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8LoOIyyAEeaKlOrmJ6XmAw" x="1016" y="1016"/>
+ </children>
+ </contents>
+ </eAnnotations>
+ <ownedBehavior xmi:type="uml:StateMachine" xmi:id="_8KWbwCyAEeaKlOrmJ6XmAw" name="State Machine">
+ <eAnnotations xmi:id="_8LdPACyAEeaKlOrmJ6XmAw" source="uml2.diagrams" references="_8LdPASyAEeaKlOrmJ6XmAw">
+ <contents xmi:type="umlnotation:UMLDiagram" xmi:id="_8LdPASyAEeaKlOrmJ6XmAw" type="Statechart" element="_8KWbwCyAEeaKlOrmJ6XmAw" measurementUnit="Himetric" name="My Favourite Machine">
+ <children xmi:type="umlnotation:UMLFrame" xmi:id="_8LdPAiyAEeaKlOrmJ6XmAw" type="Statemachine" element="_8KWbwCyAEeaKlOrmJ6XmAw" fontName="Sans" fontHeight="8" fillColor="16250871" transparency="0" lineColor="12632258" lineWidth="1" showStereotype="Label" alignment="Horizontal">
+ <children xmi:type="umlnotation:UMLShapeCompartment" xmi:id="_8LdPAyyAEeaKlOrmJ6XmAw" type="Region" element="_8KaGICyAEeaKlOrmJ6XmAw" verticalAlignment="false"/>
+ <children xmi:type="notation:BasicDecorationNode" xmi:id="_8LdPBCyAEeaKlOrmJ6XmAw" type="Name"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8LdPBSyAEeaKlOrmJ6XmAw" x="1016" y="1016"/>
+ </children>
+ </contents>
+ </eAnnotations>
+ <region xmi:id="_8KaGICyAEeaKlOrmJ6XmAw" name="Region1">
+ <subvertex xmi:type="uml:Pseudostate" xmi:id="_8KdwgCyAEeaKlOrmJ6XmAw"/>
+ <subvertex xmi:type="uml:State" xmi:id="_8Kj3ICyAEeaKlOrmJ6XmAw" name="State1"/>
+ <transition xmi:id="_8Km6cCyAEeaKlOrmJ6XmAw" name="Initial" source="_8KdwgCyAEeaKlOrmJ6XmAw" target="_8Kj3ICyAEeaKlOrmJ6XmAw">
+ <eAnnotations xmi:id="_8KsaACyAEeaKlOrmJ6XmAw" source="uml2.alias">
+ <details xmi:id="_8KsaASyAEeaKlOrmJ6XmAw" key="Initial"/>
+ </eAnnotations>
+ </transition>
+ </region>
+ </ownedBehavior>
+ </packagedElement>
+ <profileApplication xmi:id="_y_WExSyAEeaKlOrmJ6XmAw">
+ <eAnnotations xmi:id="_y_WExiyAEeaKlOrmJ6XmAw" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="pathmap://UML_PROFILES/Standard.profile.uml#_yzU58YinEdqtvbnfB2L_5w"/>
+ </eAnnotations>
+ <appliedProfile href="pathmap://UML_PROFILES/Standard.profile.uml#_0"/>
+ </profileApplication>
+ <profileApplication xmi:id="_y_WExyyAEeaKlOrmJ6XmAw">
+ <eAnnotations xmi:id="_y_WEyCyAEeaKlOrmJ6XmAw" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="pathmap://UML2_MSL_PROFILES/Default.epx#_fNwoAAqoEd6-N_NOT9vsCA?Default/Default?"/>
+ </eAnnotations>
+ <appliedProfile href="pathmap://UML2_MSL_PROFILES/Default.epx#_a_S3wNWLEdiy4IqP8whjFA?Default?"/>
+ </profileApplication>
+ <profileApplication xmi:id="_y_WEySyAEeaKlOrmJ6XmAw">
+ <eAnnotations xmi:id="_y_WEyiyAEeaKlOrmJ6XmAw" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="pathmap://UML2_MSL_PROFILES/Deployment.epx#_4OVBUD0TEeKt-L0gyEptgQ?Deployment/Deployment?"/>
+ </eAnnotations>
+ <appliedProfile href="pathmap://UML2_MSL_PROFILES/Deployment.epx#_vjbuwOvHEdiDX5bji0iVSA?Deployment?"/>
+ </profileApplication>
+ <profileApplication xmi:id="_zBKpsCyAEeaKlOrmJ6XmAw">
+ <eAnnotations xmi:id="_zBR-cCyAEeaKlOrmJ6XmAw" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="pathmap://RT_PROPERTIES/UMLRealTime.epx#_3TUzoXq6Ed2hSeAAWZznoA?UMLRealTime/UMLRealTime?"/>
+ </eAnnotations>
+ <appliedProfile href="pathmap://RT_PROPERTIES/UMLRealTime.epx#_uTDwIRHVEdu19OChlR9tHg?UMLRealTime?"/>
+ </profileApplication>
+ <profileApplication xmi:id="_zC-nkCyAEeaKlOrmJ6XmAw">
+ <eAnnotations xmi:id="_zC_OoCyAEeaKlOrmJ6XmAw" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="pathmap://RT_PROPERTIES/InteractionProfile.epx#_dDVwwX8wEd2ags_Lr77Vow?InteractionProfile/InteractionProfile?"/>
+ </eAnnotations>
+ <appliedProfile href="pathmap://RT_PROPERTIES/InteractionProfile.epx#_LyeQ4HnVEd2No7ra0rEeOg?InteractionProfile?"/>
+ </profileApplication>
+ </uml:Package>
+ <UMLRealTime:Capsule xmi:id="_8KygoCyAEeaKlOrmJ6XmAw" base_Class="_7_Ow4CyAEeaKlOrmJ6XmAw"/>
+</xmi:XMI>
diff --git a/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/src/org/eclipse/papyrusrt/umlrt/migration/rsa/tests/qvt/CapsuleStructureDiagramImportTest.java b/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/src/org/eclipse/papyrusrt/umlrt/migration/rsa/tests/qvt/CapsuleStructureDiagramImportTest.java
index ef40f6519..0dbaba22e 100644
--- a/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/src/org/eclipse/papyrusrt/umlrt/migration/rsa/tests/qvt/CapsuleStructureDiagramImportTest.java
+++ b/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/src/org/eclipse/papyrusrt/umlrt/migration/rsa/tests/qvt/CapsuleStructureDiagramImportTest.java
@@ -13,9 +13,12 @@
package org.eclipse.papyrusrt.umlrt.migration.rsa.tests.qvt;
+import static org.hamcrest.CoreMatchers.either;
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.Assume.assumeThat;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
@@ -55,4 +58,42 @@ public class CapsuleStructureDiagramImportTest extends AbstractTransformationTes
assertThat(proto.getConfiguration().getName(), is("UML-RT Capsule Structure Diagram"));
}
+ /**
+ * Verify that the imported capsule structure diagram has no name.
+ *
+ * @see <a href="http://eclip.se/462323">bug 462323</a>
+ */
+ @Test
+ public void noDiagramName() throws Exception {
+ simpleImport("resources/rt/WrongViewTypeExample.emx");
+
+ openEditor();
+
+ Class capsule1 = (Class) rootPackage.getOwnedType("Capsule1");
+ Diagram csd = UMLRTCapsuleStructureDiagramUtils.getCapsuleStructureDiagram(capsule1);
+ assumeThat(csd, notNullValue());
+
+ // The Ecore default for Diagram::name is "" and it isn't unsettable
+ assertThat(csd.getName(), either(nullValue()).or(is("")));
+ }
+
+ /**
+ * Verify that the imported capsule structure diagram has a name if the source had
+ * an explicit name.
+ *
+ * @see <a href="http://eclip.se/462323">bug 462323</a>
+ */
+ @Test
+ public void explicitDiagramName() throws Exception {
+ simpleImport("resources/rt/WrongViewTypeExampleWithNames.emx");
+
+ openEditor();
+
+ Class capsule1 = (Class) rootPackage.getOwnedType("Capsule1");
+ Diagram csd = UMLRTCapsuleStructureDiagramUtils.getCapsuleStructureDiagram(capsule1);
+ assumeThat(csd, notNullValue());
+
+ assertThat(csd.getName(), is("My Favourite Capsule"));
+ }
+
}
diff --git a/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/src/org/eclipse/papyrusrt/umlrt/migration/rsa/tests/qvt/StateMachineDiagramImportTest.java b/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/src/org/eclipse/papyrusrt/umlrt/migration/rsa/tests/qvt/StateMachineDiagramImportTest.java
index fb81e596d..501eeaae4 100644
--- a/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/src/org/eclipse/papyrusrt/umlrt/migration/rsa/tests/qvt/StateMachineDiagramImportTest.java
+++ b/tests/junit/umlrt/migration/org.eclipse.papyrusrt.umlrt.migration.rsa.tests/src/org/eclipse/papyrusrt/umlrt/migration/rsa/tests/qvt/StateMachineDiagramImportTest.java
@@ -13,9 +13,12 @@
package org.eclipse.papyrusrt.umlrt.migration.rsa.tests.qvt;
+import static org.hamcrest.CoreMatchers.either;
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.Assume.assumeThat;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
@@ -58,4 +61,46 @@ public class StateMachineDiagramImportTest extends AbstractTransformationTest {
assertThat(proto.getConfiguration().getName(), is("UML-RT State Machine Diagram"));
}
+ /**
+ * Verify that the imported capsule structure diagram has no name.
+ *
+ * @see <a href="http://eclip.se/462323">bug 462323</a>
+ */
+ @Test
+ public void noDiagramName() throws Exception {
+ simpleImport("resources/rt/WrongViewTypeExample.emx");
+
+ openEditor();
+
+ Class capsule1 = (Class) rootPackage.getOwnedType("Capsule1");
+ StateMachine stateMachine = (StateMachine) capsule1.getOwnedBehavior("State Machine");
+
+ Diagram smd = UMLRTStateMachineDiagramUtils.getStateMachineDiagram(stateMachine);
+ assumeThat(smd, notNullValue());
+
+ // The Ecore default for Diagram::name is "" and it isn't unsettable
+ assertThat(smd.getName(), either(nullValue()).or(is("")));
+ }
+
+ /**
+ * Verify that the imported capsule structure diagram has a name if the source had
+ * an explicit name.
+ *
+ * @see <a href="http://eclip.se/462323">bug 462323</a>
+ */
+ @Test
+ public void explicitDiagramName() throws Exception {
+ simpleImport("resources/rt/WrongViewTypeExampleWithNames.emx");
+
+ openEditor();
+
+ Class capsule1 = (Class) rootPackage.getOwnedType("Capsule1");
+ StateMachine stateMachine = (StateMachine) capsule1.getOwnedBehavior("State Machine");
+
+ Diagram smd = UMLRTStateMachineDiagramUtils.getStateMachineDiagram(stateMachine);
+ assumeThat(smd, notNullValue());
+
+ assertThat(smd.getName(), is("My Favourite Machine"));
+ }
+
}

Back to the top