Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-08-23 21:07:27 +0000
committerChristian W. Damus2016-08-23 21:07:27 +0000
commitae293862c718921e47a62e456d48f3c19cfbe78e (patch)
treefe95bc4745b4db378f7caecebf754c62454df2da /tests/junit/plugins/infra/services
parent7e0c2b842c458bd621914b68da67ce97ee6fed21 (diff)
downloadorg.eclipse.papyrus-ae293862c718921e47a62e456d48f3c19cfbe78e.tar.gz
org.eclipse.papyrus-ae293862c718921e47a62e456d48f3c19cfbe78e.tar.xz
org.eclipse.papyrus-ae293862c718921e47a62e456d48f3c19cfbe78e.zip
Bug 497865: [Control Mode] UI for dependent controlled units
https://bugs.eclipse.org/bugs/show_bug.cgi?id=497865 Add an option to the standard control (create fragment) dialog for option to create sub-model unit (independently openable) or not (in which case it's a 'shard'). Add an approver interface to the participant protocols for validation of control/uncontrol requests and also to determine whether an object supports the sub-model unit form of controlled resource. Use this to let the UML participant disable the sub-model unit option for non-packages. Add a label decorator for controlled unit resources in the Project Explorer, with different presentation for 'shards' as for sub-model units that are independently openable. Add a context menu on model elements to toggle their independent sub-model status when they are currently controlled units. This is supported by another optional participant protocol for changing sub-unit mode so that for UML we can add/remove redundant profile applications on packages as necessary. (cherry-picked from streams/2.0-maintenance) Change-Id: I08ac9cc64d70432851f8e7e815f352f4b00d50f2
Diffstat (limited to 'tests/junit/plugins/infra/services')
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/META-INF/MANIFEST.MF5
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/build.properties3
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.di2
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.manifest9
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.notation31
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.uml10
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.di8
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.notation2
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.uml10
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.profile.di2
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.profile.notation43
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.profile.uml31
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/UncontrolModeWithProfileTest/submodel.uml23
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/plugin.xml11
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/AllTests.java15
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/control/ControlModeManagerTest.java133
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/control/ShardModeTest.java110
17 files changed, 431 insertions, 17 deletions
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/META-INF/MANIFEST.MF
index bef0c0a73be..c2cc6b9efb1 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/META-INF/MANIFEST.MF
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.106.0",
org.eclipse.ui.navigator;bundle-version="3.5.500",
com.google.guava;bundle-version="11.0.0",
org.eclipse.papyrus.infra.ui;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="1.2.0"
+ org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.emf.gmf;bundle-version="1.2.0"
Export-Package: org.eclipse.papyrus.infra.services.controlmode.tests,
org.eclipse.papyrus.infra.services.controlmode.tests.control,
org.eclipse.papyrus.infra.services.controlmode.tests.uncontrol
@@ -25,5 +26,5 @@ Bundle-Version: 1.4.0.qualifier
Bundle-Name: %Bundle-Name
Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.infra.services.controlmode.tests.control.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.infra.services.controlmode.tests
+Bundle-SymbolicName: org.eclipse.papyrus.infra.services.controlmode.tests;singleton:=true
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/build.properties b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/build.properties
index b154c910659..878b084add3 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/build.properties
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/build.properties
@@ -5,5 +5,6 @@ bin.includes = META-INF/,\
model/,\
build.properties,\
about.html,\
- OSGI-INF/
+ OSGI-INF/,\
+ plugin.xml
src.includes = about.html
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.di b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.di
new file mode 100644
index 00000000000..bf9abab340f
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.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/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.manifest b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.manifest
new file mode 100644
index 00000000000..15e789c52a4
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.manifest
@@ -0,0 +1,9 @@
+ShardedWithProfileTestModel.di
+ShardedWithProfileTestModel.notation
+ShardedWithProfileTestModel.uml
+submodel.di
+submodel.notation
+submodel.uml
+testProfile.profile.di
+testProfile.profile.notation
+testProfile.profile.uml \ No newline at end of file
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.notation b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.notation
new file mode 100644
index 00000000000..e1f9f4aea98
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.notation
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" 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="_VTrFwLpyEeOiIqA0Y8pjRA" type="PapyrusUMLClassDiagram" name="ClassDiagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_zQoBsLpyEeOiIqA0Y8pjRA" type="2008">
+ <children xmi:type="notation:DecorationNode" xmi:id="_zQoowLpyEeOiIqA0Y8pjRA" type="5029"/>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_zQoowbpyEeOiIqA0Y8pjRA" type="7017">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_zQoowrpyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_zQoow7pyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_zQooxLpyEeOiIqA0Y8pjRA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_zQooxbpyEeOiIqA0Y8pjRA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_zQooxrpyEeOiIqA0Y8pjRA" type="7018">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_zQoox7pyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_zQooyLpyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_zQooybpyEeOiIqA0Y8pjRA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_zQooyrpyEeOiIqA0Y8pjRA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_zQooy7pyEeOiIqA0Y8pjRA" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_zQoozLpyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_zQoozbpyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_zQpP0LpyEeOiIqA0Y8pjRA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_zQpP0bpyEeOiIqA0Y8pjRA"/>
+ </children>
+ <element xmi:type="uml:Class" href="submodel.uml#_zQQOQLpyEeOiIqA0Y8pjRA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_zQoBsbpyEeOiIqA0Y8pjRA" x="292" y="260"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_VTrFwbpyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="style:PapyrusViewStyle" xmi:id="_VTrFwrpyEeOiIqA0Y8pjRA">
+ <owner xmi:type="uml:Model" href="ShardedWithProfileTestModel.uml#_zf8FgLpxEeOiIqA0Y8pjRA"/>
+ </styles>
+ <element xmi:type="uml:Model" href="ShardedWithProfileTestModel.uml#_zf8FgLpxEeOiIqA0Y8pjRA"/>
+</notation:Diagram>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.uml b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.uml
new file mode 100644
index 00000000000..ae236870f30
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/ShardedWithProfileTestModel.uml
@@ -0,0 +1,10 @@
+<?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="_zf8FgLpxEeOiIqA0Y8pjRA" name="model">
+ <packagedElement xmi:type="uml:Package" href="submodel.uml#_BRaDULsMEeO75-I_oucZEA"/>
+ <profileApplication xmi:id="_KHurgFNjEeata5Gc6au8dw">
+ <eAnnotations xmi:id="_KHv5oFNjEeata5Gc6au8dw" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="testProfile.profile.uml#_RtfCMLpyEeOiIqA0Y8pjRA"/>
+ </eAnnotations>
+ <appliedProfile href="testProfile.profile.uml#_JOBikLpyEeOiIqA0Y8pjRA"/>
+ </profileApplication>
+</uml:Model>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.di b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.di
new file mode 100644
index 00000000000..9c61b75f345
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.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/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.notation b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.notation
new file mode 100644
index 00000000000..8634d4c00e0
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.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/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.uml b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.uml
new file mode 100644
index 00000000000..1fef11c13eb
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/submodel.uml
@@ -0,0 +1,10 @@
+<?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/_Rtcl8LpyEeOiIqA0Y8pjRA/0" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http:///schemas/profile/_Rtcl8LpyEeOiIqA0Y8pjRA/0 testProfile.profile.uml#_RtfCMLpyEeOiIqA0Y8pjRA">
+ <uml:Package xmi:id="_BRaDULsMEeO75-I_oucZEA" name="submodel">
+ <eAnnotations xmi:id="_wnhgILswEeOBNLJQ9YB1Vw" source="http://www.eclipse.org/papyrus/2016/resource/shard">
+ <references xmi:type="uml:Model" href="ShardedWithProfileTestModel.uml#_zf8FgLpxEeOiIqA0Y8pjRA"/>
+ </eAnnotations>
+ <packagedElement xmi:type="uml:Class" xmi:id="_zQQOQLpyEeOiIqA0Y8pjRA" name="Class1"/>
+ </uml:Package>
+ <profile:Stereotype1 xmi:id="_LugcEFNjEeata5Gc6au8dw" base_Class="_zQQOQLpyEeOiIqA0Y8pjRA"/>
+</xmi:XMI>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.profile.di b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.profile.di
new file mode 100644
index 00000000000..8634d4c00e0
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.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/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.profile.notation b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.profile.notation
new file mode 100644
index 00000000000..94dd5e30272
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.profile.notation
@@ -0,0 +1,43 @@
+<?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="_JOdAYLpyEeOiIqA0Y8pjRA" type="PapyrusUMLProfileDiagram" name="NewDiagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_MTfesLpyEeOiIqA0Y8pjRA" type="1026">
+ <children xmi:type="notation:DecorationNode" xmi:id="_MTgFwLpyEeOiIqA0Y8pjRA" type="1034"/>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_MTgs0LpyEeOiIqA0Y8pjRA" type="1071">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_MTgs0bpyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_MTgs0rpyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_MTgs07pyEeOiIqA0Y8pjRA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_MTgs1LpyEeOiIqA0Y8pjRA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_MTgs1bpyEeOiIqA0Y8pjRA" type="1019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_MTgs1rpyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_MTgs17pyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_MTgs2LpyEeOiIqA0Y8pjRA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_MTgs2bpyEeOiIqA0Y8pjRA"/>
+ </children>
+ <element xmi:type="uml:Stereotype" href="testProfile.profile.uml#_MTPnELpyEeOiIqA0Y8pjRA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_MTfesbpyEeOiIqA0Y8pjRA" x="327" y="185"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_P1ovwLpyEeOiIqA0Y8pjRA" type="1031">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_P1qk8LpyEeOiIqA0Y8pjRA" source="Stereotype_Annotation">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_P1rMALpyEeOiIqA0Y8pjRA" key="StereotypeWithQualifiedNameList" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_P1rMAbpyEeOiIqA0Y8pjRA" key="StereotypeList" value="StandardProfile::Metaclass"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_P1rMArpyEeOiIqA0Y8pjRA" key="Stereotype_Presentation_Kind" value="HorizontalStereo"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_P1rzELpyEeOiIqA0Y8pjRA" key="PropStereoDisplay" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_P1rzEbpyEeOiIqA0Y8pjRA" key="StereotypePropertyLocation" value="Compartment"/>
+ </eAnnotations>
+ <children xmi:type="notation:DecorationNode" xmi:id="_P1pW0LpyEeOiIqA0Y8pjRA" type="1084"/>
+ <element xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_P1pW0bpyEeOiIqA0Y8pjRA" x="703" y="240"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_JOdAYbpyEeOiIqA0Y8pjRA"/>
+ <styles xmi:type="style:PapyrusViewStyle" xmi:id="_JOdAYrpyEeOiIqA0Y8pjRA">
+ <owner xmi:type="uml:Profile" href="testProfile.profile.uml#_JOBikLpyEeOiIqA0Y8pjRA"/>
+ </styles>
+ <element xmi:type="uml:Profile" href="testProfile.profile.uml#_JOBikLpyEeOiIqA0Y8pjRA"/>
+ <edges xmi:type="notation:Connector" xmi:id="_Qo5_wLpyEeOiIqA0Y8pjRA" type="1013" source="_MTfesLpyEeOiIqA0Y8pjRA" target="_P1ovwLpyEeOiIqA0Y8pjRA">
+ <styles xmi:type="notation:FontStyle" xmi:id="_Qo5_wbpyEeOiIqA0Y8pjRA"/>
+ <element xmi:type="uml:Extension" href="testProfile.profile.uml#_QoqIILpyEeOiIqA0Y8pjRA"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Qo5_wrpyEeOiIqA0Y8pjRA" points="[50, 4, -295, -24]$[326, 26, -19, -2]"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Qpa9ILpyEeOiIqA0Y8pjRA" id="(0.19,0.46)"/>
+ </edges>
+</notation:Diagram>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.profile.uml b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.profile.uml
new file mode 100644
index 00000000000..3c81e91ae6c
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/ShardedWithProfileTest/testProfile.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="_JOBikLpyEeOiIqA0Y8pjRA" name="profile" metaclassReference="_P1j3QLpyEeOiIqA0Y8pjRA">
+ <eAnnotations xmi:id="_RtebILpyEeOiIqA0Y8pjRA" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <contents xmi:type="ecore:EPackage" xmi:id="_RtfCMLpyEeOiIqA0Y8pjRA" name="profile" nsURI="http:///schemas/profile/_Rtcl8LpyEeOiIqA0Y8pjRA/0" nsPrefix="profile">
+ <eAnnotations xmi:id="_RtiFgLpyEeOiIqA0Y8pjRA" source="PapyrusVersion">
+ <details xmi:id="_RtiFgbpyEeOiIqA0Y8pjRA" key="Version" value="0.0.1"/>
+ <details xmi:id="_RtiFgrpyEeOiIqA0Y8pjRA" key="Comment" value=""/>
+ <details xmi:id="_RtiFg7pyEeOiIqA0Y8pjRA" key="Copyright" value=""/>
+ <details xmi:id="_RtiFhLpyEeOiIqA0Y8pjRA" key="Date" value="2014-04-02"/>
+ <details xmi:id="_RtiFhbpyEeOiIqA0Y8pjRA" key="Author" value=""/>
+ </eAnnotations>
+ <eClassifiers xmi:type="ecore:EClass" xmi:id="_RtfCMbpyEeOiIqA0Y8pjRA" name="Stereotype1">
+ <eAnnotations xmi:id="_RtfCMrpyEeOiIqA0Y8pjRA" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_MTPnELpyEeOiIqA0Y8pjRA"/>
+ <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_RtfCM7pyEeOiIqA0Y8pjRA" 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:id="_P1j3QLpyEeOiIqA0Y8pjRA" alias="Class">
+ <importedElement xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
+ </elementImport>
+ <packagedElement xmi:type="uml:Stereotype" xmi:id="_MTPnELpyEeOiIqA0Y8pjRA" name="Stereotype1">
+ <ownedAttribute xmi:id="_Qoo6ALpyEeOiIqA0Y8pjRA" name="base_Class" association="_QoqIILpyEeOiIqA0Y8pjRA">
+ <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
+ </ownedAttribute>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Extension" xmi:id="_QoqIILpyEeOiIqA0Y8pjRA" name="E_Stereotype1_Class1" memberEnd="_QoqIIbpyEeOiIqA0Y8pjRA _Qoo6ALpyEeOiIqA0Y8pjRA">
+ <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_QoqIIbpyEeOiIqA0Y8pjRA" name="extension_Stereotype1" type="_MTPnELpyEeOiIqA0Y8pjRA" aggregation="composite" association="_QoqIILpyEeOiIqA0Y8pjRA"/>
+ </packagedElement>
+</uml:Profile>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/UncontrolModeWithProfileTest/submodel.uml b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/UncontrolModeWithProfileTest/submodel.uml
index 7ca7f75bb5d..69af42b7394 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/UncontrolModeWithProfileTest/submodel.uml
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/model/UncontrolModeWithProfileTest/submodel.uml
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<uml:Package 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="_BRaDULsMEeO75-I_oucZEA" name="submodel">
- <packagedElement xmi:type="uml:Class" xmi:id="_zQQOQLpyEeOiIqA0Y8pjRA" name="Class1"/>
- <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_wnZkULswEeOBNLJQ9YB1Vw">
- <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_wnZkUbswEeOBNLJQ9YB1Vw" source="http://www.eclipse.org/uml2/2.0.0/UML">
- <references xmi:type="ecore:EPackage" href="testProfile.profile.uml#_RtfCMLpyEeOiIqA0Y8pjRA"/>
- </eAnnotations>
- <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_wnhgILswEeOBNLJQ9YB1Vw" source="duplicatedProfile"/>
- <appliedProfile xmi:type="uml:Profile" href="testProfile.profile.uml#_JOBikLpyEeOiIqA0Y8pjRA"/>
- </profileApplication>
-</uml:Package>
+<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/emf/2002/Ecore" xmlns:profile="http:///schemas/profile/_Rtcl8LpyEeOiIqA0Y8pjRA/0" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http:///schemas/profile/_Rtcl8LpyEeOiIqA0Y8pjRA/0 testProfile.profile.uml#_RtfCMLpyEeOiIqA0Y8pjRA">
+ <uml:Package xmi:id="_BRaDULsMEeO75-I_oucZEA" name="submodel">
+ <packagedElement xmi:type="uml:Class" xmi:id="_zQQOQLpyEeOiIqA0Y8pjRA" name="Class1"/>
+ <profileApplication xmi:id="_wnZkULswEeOBNLJQ9YB1Vw">
+ <eAnnotations xmi:id="_wnZkUbswEeOBNLJQ9YB1Vw" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="testProfile.profile.uml#_RtfCMLpyEeOiIqA0Y8pjRA"/>
+ </eAnnotations>
+ <eAnnotations xmi:id="_wnhgILswEeOBNLJQ9YB1Vw" source="duplicatedProfile"/>
+ <appliedProfile href="testProfile.profile.uml#_JOBikLpyEeOiIqA0Y8pjRA"/>
+ </profileApplication>
+ </uml:Package>
+ <profile:Stereotype1 xmi:id="_ShirkFNiEeata5Gc6au8dw" base_Class="_zQQOQLpyEeOiIqA0Y8pjRA"/>
+</xmi:XMI>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/plugin.xml b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/plugin.xml
new file mode 100644
index 00000000000..d2c8fb631c0
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/plugin.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.infra.services.controlmode.participant">
+ <participant
+ class="org.eclipse.papyrus.infra.services.controlmode.tests.control.ControlModeManagerTest$TestApproverParticipant">
+ </participant>
+ </extension>
+
+</plugin>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/AllTests.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/AllTests.java
index 8a65148f21a..f8fabcfcef1 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/AllTests.java
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/AllTests.java
@@ -1,22 +1,26 @@
/*******************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2016 CEA LIST, 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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Juan Cadavid <juan.cadavid@cea.fr> implementation
+ * Juan Cadavid <juan.cadavid@cea.fr> - Initial API and implementation
+ * Christian W. Damus - bug 497865
+ *
******************************************************************************/
package org.eclipse.papyrus.infra.services.controlmode.tests;
import org.eclipse.papyrus.infra.services.controlmode.tests.control.ControlLegacyModelTest;
+import org.eclipse.papyrus.infra.services.controlmode.tests.control.ControlModeManagerTest;
import org.eclipse.papyrus.infra.services.controlmode.tests.control.ControlModelTest;
import org.eclipse.papyrus.infra.services.controlmode.tests.control.ControlModelWithProfileTest;
+import org.eclipse.papyrus.infra.services.controlmode.tests.control.ShardModeTest;
import org.eclipse.papyrus.infra.services.controlmode.tests.uncontrol.UncontrolModelTest;
import org.eclipse.papyrus.infra.services.controlmode.tests.uncontrol.UncontrolModelWithProfileTest;
-import org.junit.runner.RunWith;
import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite;
+import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(ClassificationSuite.class)
@@ -24,7 +28,10 @@ import org.junit.runners.Suite.SuiteClasses;
UncontrolModelTest.class,
ControlModelTest.class,
UncontrolModelWithProfileTest.class,
- ControlLegacyModelTest.class })
+ ControlLegacyModelTest.class,
+ ControlModeManagerTest.class,
+ ShardModeTest.class,
+})
public class AllTests {
}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/control/ControlModeManagerTest.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/control/ControlModeManagerTest.java
new file mode 100644
index 00000000000..d55b4d3f1f7
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/control/ControlModeManagerTest.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial implementation and API
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.infra.services.controlmode.tests.control;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeManager;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.IControlModeManager;
+import org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandApprover;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Package;
+import org.junit.Test;
+
+/**
+ * Tests for the {@link ControlModeManager} class.
+ */
+@PluginResource("model/ControlModeTest/ControlModeTestModel.di")
+public class ControlModeManagerTest extends AbstractControlModeTest {
+ static final String DENY_ME = "test.parameter.deny.me";
+
+ private IControlModeManager mgr = ControlModeManager.getInstance();
+
+ @Test
+ public void canCreateSubModel() {
+ Package package_ = editorFixture.getModel().getNestedPackage("Package");
+ Class class_ = (Class) package_.getOwnedType("Class");
+
+ assertThat("Cannot make a package independently openable",
+ mgr.canCreateSubmodel(package_), is(true));
+ assertThat("Can make a class independently openable",
+ mgr.canCreateSubmodel(class_), is(false));
+ }
+
+ @Test
+ public void approveControlRequest() throws Exception {
+ EObject object = editorFixture.getModel().getNestedPackage("Package");
+
+ ControlModeRequest request = ControlModeRequest.createUIControlModelRequest(
+ editorFixture.getEditingDomain(),
+ object,
+ URI.createURI("platform:/resource/bogus/model.di"));
+
+ Diagnostic diagnostic = mgr.approveRequest(request);
+ assertThat("Request not approved", diagnostic.getSeverity(), is(Diagnostic.OK));
+ }
+
+ @Test
+ public void disapproveControlRequest() throws Exception {
+ IControlModeManager mgr = ControlModeManager.getInstance();
+ EObject object = editorFixture.getModel().getNestedPackage("Package");
+
+ ControlModeRequest request = ControlModeRequest.createUIControlModelRequest(
+ editorFixture.getEditingDomain(),
+ object,
+ URI.createURI("platform:/resource/bogus/model.di"));
+ request.setParameter(DENY_ME, true);
+
+ Diagnostic diagnostic = mgr.approveRequest(request);
+ assertThat("Request approved", diagnostic.getSeverity(), is(Diagnostic.ERROR));
+ }
+
+ @Test
+ @PluginResource("model/UncontrolModeTest/ReintegrateTestModel.di")
+ public void approveUncontrolRequest() throws Exception {
+ EObject object = editorFixture.getModel().getNestedPackage("Subpackage");
+
+ ControlModeRequest request = ControlModeRequest.createUIUncontrolModelRequest(
+ editorFixture.getEditingDomain(),
+ object);
+
+ Diagnostic diagnostic = mgr.approveRequest(request);
+ assertThat("Request not approved", diagnostic.getSeverity(), is(Diagnostic.OK));
+ }
+
+ @Test
+ @PluginResource("model/UncontrolModeTest/ReintegrateTestModel.di")
+ public void disapproveUncontrolRequest() throws Exception {
+ IControlModeManager mgr = ControlModeManager.getInstance();
+ EObject object = editorFixture.getModel().getNestedPackage("Subpackage");
+
+ ControlModeRequest request = ControlModeRequest.createUIUncontrolModelRequest(
+ editorFixture.getEditingDomain(),
+ object);
+ request.setParameter(DENY_ME, true);
+
+ Diagnostic diagnostic = mgr.approveRequest(request);
+ assertThat("Request approved", diagnostic.getSeverity(), is(Diagnostic.ERROR));
+ }
+
+ //
+ // Nested types
+ //
+
+ public static final class TestApproverParticipant implements IControlCommandApprover {
+
+ @Override
+ public String getID() {
+ return "org.eclipse.papyrus.uml.controlmode.profile.tests.TestApprover";
+ }
+
+ @Override
+ public int getPriority() {
+ return 10;
+ }
+
+ @Override
+ public Diagnostic approveRequest(ControlModeRequest request) {
+ return (request.getParameter(DENY_ME) == null)
+ ? null
+ : new BasicDiagnostic(Diagnostic.ERROR,
+ "org.eclipse.papyrus.uml.controlmode.profile.tests",
+ 1, "Permission denied", null);
+ }
+
+ }
+}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/control/ShardModeTest.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/control/ShardModeTest.java
new file mode 100644
index 00000000000..816eacb0d76
--- /dev/null
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/control/ShardModeTest.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial implementation and API
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.infra.services.controlmode.tests.control;
+
+import static com.google.common.collect.Iterables.getFirst;
+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.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.papyrus.infra.emf.resource.ShardResourceHelper;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeManager;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequestParameters;
+import org.eclipse.papyrus.infra.services.controlmode.IControlModeManager;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.ProfileApplication;
+import org.eclipse.uml2.uml.util.UMLUtil;
+import org.junit.Test;
+
+/**
+ * Tests for the management of the 'shard' mode of a controlled unit.
+ */
+public class ShardModeTest extends AbstractControlModeTest {
+
+ private IControlModeManager mgr = ControlModeManager.getInstance();
+
+ @Test
+ @PluginResource("model/UncontrolModeWithProfileTest/UncontrolModeWithProfileTestModel.di")
+ public void convertSubmodelToShard() {
+ Package submodel = editorFixture.getModel().getNestedPackage("submodel");
+ ProfileApplication profile = getFirst(submodel.getProfileApplications(), null);
+ Class class1 = (Class) submodel.getOwnedType("Class1");
+ EObject stereo = getFirst(class1.getStereotypeApplications(), null);
+
+ ControlModeRequest request = ControlModeRequest.createUIControlModelRequest(
+ editorFixture.getEditingDomain(), submodel, submodel.eResource().getURI());
+ request.setParameter(ControlModeRequestParameters.CREATE_SHARD, true);
+
+ ShardResourceHelper helper = new ShardResourceHelper(submodel);
+ houseKeeper.cleanUpLater(helper, ShardResourceHelper::close);
+
+ ICommand changeToShard = mgr.getShardModeCommand(request);
+
+ assumeThat("No redundant profile applications before", profile, notNullValue());
+ assumeThat("No stereotype application before", stereo, notNullValue());
+ assumeThat("Wrong resource for stereotype application before", stereo.eResource(), is(class1.eResource()));
+ assumeThat("Sub-unit is not a submodel", helper.isShard(), is(false));
+
+ assertThat("No command provided", changeToShard, notNullValue());
+ assertThat("Command not executable", changeToShard.canExecute(), is(true));
+
+ editorFixture.execute(changeToShard);
+
+ assertThat("Sub-unit is not a shard", helper.isShard(), is(true));
+ assertThat("Redundant profile application still exists", profile.getApplyingPackage(), nullValue());
+ assertThat("Stereotype application is gone", stereo.eResource(), is(class1.eResource()));
+ assertThat("Stereotype unapplied", UMLUtil.getBaseElement(stereo), is(class1));
+ }
+
+ @Test
+ @PluginResource("model/ShardedWithProfileTest/ShardedWithProfileTestModel.di")
+ public void convertShardToSubmodel() {
+ Package submodel = editorFixture.getModel().getNestedPackage("submodel");
+ ProfileApplication profile = getFirst(submodel.getProfileApplications(), null);
+ Class class1 = (Class) submodel.getOwnedType("Class1");
+ EObject stereo = getFirst(class1.getStereotypeApplications(), null);
+
+ ControlModeRequest request = ControlModeRequest.createUIControlModelRequest(
+ editorFixture.getEditingDomain(), submodel, submodel.eResource().getURI());
+ request.setParameter(ControlModeRequestParameters.CREATE_SHARD, false);
+
+ ShardResourceHelper helper = new ShardResourceHelper(submodel);
+ houseKeeper.cleanUpLater(helper, ShardResourceHelper::close);
+
+ ICommand changeToSubmodel = mgr.getShardModeCommand(request);
+
+ assumeThat("Had redundant profile application before", profile, nullValue());
+ assumeThat("No stereotype application before", stereo, notNullValue());
+ assumeThat("Wrong resource for stereotype application before", stereo.eResource(), is(class1.eResource()));
+ assumeThat("Sub-unit is not a shard", helper.isShard(), is(true));
+
+ assertThat("No command provided", changeToSubmodel, notNullValue());
+ assertThat("Command not executable", changeToSubmodel.canExecute(), is(true));
+
+ editorFixture.execute(changeToSubmodel);
+
+ profile = getFirst(submodel.getProfileApplications(), null);
+
+ assertThat("Sub-unit is not a submodel", helper.isShard(), is(false));
+ assertThat("No redundant profile application", profile, notNullValue());
+ assertThat("Stereotype application is gone", stereo.eResource(), is(class1.eResource()));
+ assertThat("Stereotype unapplied", UMLUtil.getBaseElement(stereo), is(class1));
+ }
+}

Back to the top