Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFanch BONNABESSE2015-11-19 12:44:19 +0000
committervincent lorenzo2015-12-04 12:31:29 +0000
commit1f171bd0213d10d1d791f622e7ebf0b6484c40c5 (patch)
treedab6c18bf974d2818499da1aeebcbe4beccc9bb8 /tests
parent72cbff7e19723adae3eeabf506aa42a41eaa5554 (diff)
downloadorg.eclipse.papyrus-1f171bd0213d10d1d791f622e7ebf0b6484c40c5.tar.gz
org.eclipse.papyrus-1f171bd0213d10d1d791f622e7ebf0b6484c40c5.tar.xz
org.eclipse.papyrus-1f171bd0213d10d1d791f622e7ebf0b6484c40c5.zip
Bug 476873: [Class diagram] Moving a generalization shall update the
corresponding figure(s) https://bugs.eclipse.org/bugs/show_bug.cgi?id=476873 Adding Tests: - Moving a Generalization: Class1 to Class3 --> deleting references to the diagram. - Moving two Generalizations: Class1 to Class3 --> deleting references to the diagram Change-Id: Id98f2bf07b5799a8fddcb70737f9f2709cd7b088 Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/META-INF/MANIFEST.MF75
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.di2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.notation107
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.uml9
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java5
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/Bug476873_MoveCommandTest.java338
6 files changed, 497 insertions, 39 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/META-INF/MANIFEST.MF
index 503dd621710..ac864f20661 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/META-INF/MANIFEST.MF
@@ -1,37 +1,38 @@
-Manifest-Version: 1.0
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.junit,
- org.eclipse.emf.transaction,
- org.eclipse.ui.ide,
- org.eclipse.papyrus.uml.tools.utils;bundle-version="1.2.0",
- org.eclipse.papyrus.junit.framework;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.tools;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.2.0",
- org.eclipse.gmf.runtime.notation.edit,
- org.eclipse.papyrus.infra.widgets;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.diagram.tests;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.gmfdiag.css;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.diagram.common;bundle-version="1.2.0",
- org.eclipse.papyrus.junit.utils;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.diagram.clazz;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.gmfdiag.canonical.tests;bundle-version="1.2.0",
- org.eclipse.gmf.tooling.runtime;bundle-version="3.3.0",
- org.eclipse.papyrus.infra.gmfdiag.css.model;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.gmfdiag.css.properties;bundle-version="1.2.0"
-Export-Package: org.eclipse.papyrus.uml.diagram.common.tests,
- org.eclipse.papyrus.uml.diagram.common.tests.css,
- org.eclipse.papyrus.uml.diagram.common.tests.parser,
- org.eclipse.papyrus.uml.diagram.common.tests.tests
-Bundle-Vendor: %Bundle-Vendor
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
-Bundle-Localization: plugin
-Bundle-Name: %Bundle-Name
-Bundle-Activator: org.eclipse.papyrus.uml.diagram.common.tests.Activator
-Bundle-ManifestVersion: 2
-Bundle-Description: This plugin provides tests for the papyrus plugin UML Diagram Common
-Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.common.tests
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.junit,
+ org.eclipse.emf.transaction,
+ org.eclipse.ui.ide,
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="1.2.0",
+ org.eclipse.papyrus.junit.framework;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
+ org.eclipse.papyrus.uml.tools;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.2.0",
+ org.eclipse.gmf.runtime.notation.edit,
+ org.eclipse.papyrus.infra.widgets;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.2.0",
+ org.eclipse.papyrus.uml.diagram.tests;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.gmfdiag.css;bundle-version="1.2.0",
+ org.eclipse.papyrus.uml.diagram.common;bundle-version="1.2.0",
+ org.eclipse.papyrus.junit.utils;bundle-version="1.2.0",
+ org.eclipse.papyrus.uml.diagram.clazz;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.gmfdiag.canonical.tests;bundle-version="1.2.0",
+ org.eclipse.gmf.tooling.runtime;bundle-version="3.3.0",
+ org.eclipse.papyrus.infra.gmfdiag.css.model;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.gmfdiag.css.properties;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.services.edit
+Export-Package: org.eclipse.papyrus.uml.diagram.common.tests,
+ org.eclipse.papyrus.uml.diagram.common.tests.css,
+ org.eclipse.papyrus.uml.diagram.common.tests.parser,
+ org.eclipse.papyrus.uml.diagram.common.tests.tests
+Bundle-Vendor: %Bundle-Vendor
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.2.0.qualifier
+Bundle-Localization: plugin
+Bundle-Name: %Bundle-Name
+Bundle-Activator: org.eclipse.papyrus.uml.diagram.common.tests.Activator
+Bundle-ManifestVersion: 2
+Bundle-Description: This plugin provides tests for the papyrus plugin UML Diagram Common
+Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.common.tests
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.di b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.di
new file mode 100644
index 00000000000..bf9abab340f
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.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/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.notation b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.notation
new file mode 100644
index 00000000000..40aa8ac494f
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.notation
@@ -0,0 +1,107 @@
+<?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="_iPu8EGzOEeWw3Lk1FWCieQ" type="PapyrusUMLClassDiagram" name="ClassDiagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="__D7XcIxPEeWGQ9p1A8IDkw" type="2008">
+ <children xmi:type="notation:DecorationNode" xmi:id="__D8lkIxPEeWGQ9p1A8IDkw" type="5029"/>
+ <children xmi:type="notation:DecorationNode" xmi:id="__D8lkYxPEeWGQ9p1A8IDkw" type="8510">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="__D8lkoxPEeWGQ9p1A8IDkw" y="5"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="__D8lk4xPEeWGQ9p1A8IDkw" type="7017">
+ <styles xmi:type="notation:TitleStyle" xmi:id="__D8llIxPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="__D8llYxPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="__D8lloxPEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__D8ll4xPEeWGQ9p1A8IDkw"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="__D9MoIxPEeWGQ9p1A8IDkw" type="7018">
+ <styles xmi:type="notation:TitleStyle" xmi:id="__D9MoYxPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="__D9MooxPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="__D9Mo4xPEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__D9MpIxPEeWGQ9p1A8IDkw"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="__D9MpYxPEeWGQ9p1A8IDkw" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="__D9MpoxPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="__D9Mp4xPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="__D9MqIxPEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__D9MqYxPEeWGQ9p1A8IDkw"/>
+ </children>
+ <element xmi:type="uml:Class" href="uml.uml#__DqRsIxPEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__D7XcYxPEeWGQ9p1A8IDkw" x="201" y="138"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="__UVyAIxPEeWGQ9p1A8IDkw" type="2008">
+ <children xmi:type="notation:DecorationNode" xmi:id="__UWZEIxPEeWGQ9p1A8IDkw" type="5029"/>
+ <children xmi:type="notation:DecorationNode" xmi:id="__UWZEYxPEeWGQ9p1A8IDkw" type="8510">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="__UWZEoxPEeWGQ9p1A8IDkw" y="5"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="__UWZE4xPEeWGQ9p1A8IDkw" type="7017">
+ <styles xmi:type="notation:TitleStyle" xmi:id="__UWZFIxPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="__UWZFYxPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="__UWZFoxPEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__UWZF4xPEeWGQ9p1A8IDkw"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="__UWZGIxPEeWGQ9p1A8IDkw" type="7018">
+ <styles xmi:type="notation:TitleStyle" xmi:id="__UWZGYxPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="__UWZGoxPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="__UWZG4xPEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__UWZHIxPEeWGQ9p1A8IDkw"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="__UWZHYxPEeWGQ9p1A8IDkw" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="__UWZHoxPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="__UWZH4xPEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="__UWZIIxPEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__UWZIYxPEeWGQ9p1A8IDkw"/>
+ </children>
+ <element xmi:type="uml:Class" href="uml.uml#__UUj4IxPEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__UVyAYxPEeWGQ9p1A8IDkw" x="597" y="144"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_CHAG4IxQEeWGQ9p1A8IDkw" type="2008">
+ <children xmi:type="notation:DecorationNode" xmi:id="_CHAt8IxQEeWGQ9p1A8IDkw" type="5029"/>
+ <children xmi:type="notation:DecorationNode" xmi:id="_CHAt8YxQEeWGQ9p1A8IDkw" type="8510">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_CHAt8oxQEeWGQ9p1A8IDkw" y="5"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_CHAt84xQEeWGQ9p1A8IDkw" type="7017">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_CHAt9IxQEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_CHAt9YxQEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_CHAt9oxQEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CHAt94xQEeWGQ9p1A8IDkw"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_CHAt-IxQEeWGQ9p1A8IDkw" type="7018">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_CHAt-YxQEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_CHAt-oxQEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_CHAt-4xQEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CHAt_IxQEeWGQ9p1A8IDkw"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_CHAt_YxQEeWGQ9p1A8IDkw" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_CHAt_oxQEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_CHAt_4xQEeWGQ9p1A8IDkw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_CHAuAIxQEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CHAuAYxQEeWGQ9p1A8IDkw"/>
+ </children>
+ <element xmi:type="uml:Class" href="uml.uml#_CG-4wIxQEeWGQ9p1A8IDkw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CHAG4YxQEeWGQ9p1A8IDkw" x="406" y="287"/>
+ </children>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_iPu8EWzOEeWw3Lk1FWCieQ" name="diagram_compatibility_version" stringValue="1.1.0"/>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_iPu8EmzOEeWw3Lk1FWCieQ"/>
+ <styles xmi:type="style:PapyrusViewStyle" xmi:id="_iPu8E2zOEeWw3Lk1FWCieQ">
+ <owner xmi:type="uml:Model" href="uml.uml#_uGj_YGw6EeWDCZ2SxMaACA"/>
+ </styles>
+ <element xmi:type="uml:Model" href="uml.uml#_uGj_YGw6EeWDCZ2SxMaACA"/>
+ <edges xmi:type="notation:Connector" xmi:id="_iUtkgIxQEeWGQ9p1A8IDkw" type="4002" source="__D7XcIxPEeWGQ9p1A8IDkw" target="__UVyAIxPEeWGQ9p1A8IDkw">
+ <children xmi:type="notation:DecorationNode" xmi:id="_iUtkg4xQEeWGQ9p1A8IDkw" type="6007">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_iUtkhIxQEeWGQ9p1A8IDkw" y="40"/>
+ </children>
+ <styles xmi:type="notation:FontStyle" xmi:id="_iUtkgYxQEeWGQ9p1A8IDkw"/>
+ <element xmi:type="uml:Generalization" href="uml.uml#_iUWYIIxQEeWGQ9p1A8IDkw"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_iUtkgoxQEeWGQ9p1A8IDkw" points="[301, 164, -643984, -643984]$[597, 167, -643984, -643984]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_iWOAYIxQEeWGQ9p1A8IDkw" id="(1.0,0.2628735632183907)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_iWOncIxQEeWGQ9p1A8IDkw" id="(0.0,0.23689655172413807)"/>
+ </edges>
+ <edges xmi:type="notation:Connector" xmi:id="_irj-QIxQEeWGQ9p1A8IDkw" type="4002" source="__D7XcIxPEeWGQ9p1A8IDkw" target="__UVyAIxPEeWGQ9p1A8IDkw">
+ <children xmi:type="notation:DecorationNode" xmi:id="_irklUIxQEeWGQ9p1A8IDkw" type="6007">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_irklUYxQEeWGQ9p1A8IDkw" y="40"/>
+ </children>
+ <styles xmi:type="notation:FontStyle" xmi:id="_irj-QYxQEeWGQ9p1A8IDkw"/>
+ <element xmi:type="uml:Generalization" href="uml.uml#_ireesIxQEeWGQ9p1A8IDkw"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_irj-QoxQEeWGQ9p1A8IDkw" points="[301, 207, -643984, -643984]$[597, 208, -643984, -643984]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_irzO0IxQEeWGQ9p1A8IDkw" id="(1.0,0.6929508196721312)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_irzO0YxQEeWGQ9p1A8IDkw" id="(0.0,0.6491256830601094)"/>
+ </edges>
+</notation:Diagram>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.uml b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.uml
new file mode 100644
index 00000000000..f3022c4ef99
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/476873/uml.uml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_uGj_YGw6EeWDCZ2SxMaACA" name="RootElement">
+ <packagedElement xmi:type="uml:Class" xmi:id="__DqRsIxPEeWGQ9p1A8IDkw" name="Class1">
+ <generalization xmi:type="uml:Generalization" xmi:id="_iUWYIIxQEeWGQ9p1A8IDkw" general="__UUj4IxPEeWGQ9p1A8IDkw"/>
+ <generalization xmi:type="uml:Generalization" xmi:id="_ireesIxQEeWGQ9p1A8IDkw" general="__UUj4IxPEeWGQ9p1A8IDkw"/>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Class" xmi:id="__UUj4IxPEeWGQ9p1A8IDkw" name="Class2"/>
+ <packagedElement xmi:type="uml:Class" xmi:id="_CG-4wIxQEeWGQ9p1A8IDkw" name="Class3"/>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java
index 9b6f06020ee..e140f3fcfec 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java
@@ -15,6 +15,7 @@
package org.eclipse.papyrus.uml.diagram.common.tests.tests;
+import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite;
import org.eclipse.papyrus.uml.diagram.common.canonical.tests.CanonicalRegressionTest;
import org.eclipse.papyrus.uml.diagram.common.tests.css.Bug431694_UndoDeleteTest;
import org.eclipse.papyrus.uml.diagram.common.tests.parser.HTMLCleanerTestCase;
@@ -23,7 +24,6 @@ import org.eclipse.papyrus.uml.diagram.common.tests.parser.MultiplicityStringFor
import org.eclipse.papyrus.uml.diagram.common.tests.parser.ValueSpecificationUtilTestCase;
import org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display.AppliedStereotypeDisplayStructureTest;
import org.junit.runner.RunWith;
-import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(ClassificationSuite.class)
@@ -37,7 +37,8 @@ import org.junit.runners.Suite.SuiteClasses;
MultiplicityStringFormatterTestCase.class,
ValueSpecificationUtilTestCase.class,
CanonicalRegressionTest.class,
- ShapeCustomisationTest.class
+ ShapeCustomisationTest.class,
+ Bug476873_MoveCommandTest.class
})
public class AllTests {
// JUnit 4 test suite
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/Bug476873_MoveCommandTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/Bug476873_MoveCommandTest.java
new file mode 100644
index 00000000000..4f1a682f182
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/Bug476873_MoveCommandTest.java
@@ -0,0 +1,338 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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:
+ * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.tests.tests;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.impl.NodeImpl;
+import org.eclipse.gmf.runtime.notation.impl.ShapeImpl;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.DiagramUtils;
+import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassEditPart;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Generalization;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * The Class Bug476873_MoveCommandTest.
+ */
+@PluginResource("/resources/476873/uml.di")
+public class Bug476873_MoveCommandTest extends AbstractPapyrusTest {
+
+ /** The name of the source class of the generalizations. */
+ private static final String NAME_CLASS_1 = "Class1"; //$NON-NLS-1$
+ /** The name of the target class of the generalizations. */
+ private static final String NAME_CLASS_3 = "Class3"; //$NON-NLS-1$
+ /** The name of the diagram used for testing. */
+ private static final String NAME_DIAGRAM = "ClassDiagram"; //$NON-NLS-1$
+
+ /** The Papyrus editor fixture. */
+ @Rule
+ public final PapyrusEditorFixture papyrusEditorFixture = new PapyrusEditorFixture();
+
+ /** The target Class edit part. */
+ private EditPart targetClassEditPart = null;
+
+ /** The first generalization to move. */
+ private Generalization firstGeneralization = null;
+
+ /** The second generalization to move. */
+ private Generalization secondGeneralization = null;
+
+ /** The diagram. */
+ private Diagram diagram = null;
+
+ @Before
+ public void init() {
+ diagram = DiagramUtils.getNotationDiagram(papyrusEditorFixture.getModelSet(), NAME_DIAGRAM);
+
+ assertNotNull(diagram);
+
+ papyrusEditorFixture.getPageManager().openPage(diagram);
+ papyrusEditorFixture.flushDisplayEvents();
+
+ targetClassEditPart = getEditPart(NAME_CLASS_3); // The target class of the generalizations
+ Assert.assertTrue("The Edit Part must be a ClassEditPart", targetClassEditPart instanceof ClassEditPart); //$NON-NLS-1$
+
+ EditPart sourceClassEditPart = getEditPart(NAME_CLASS_1); // The source class of the generalizations
+ Assert.assertTrue("The Edit Part must be a ClassEditPart", sourceClassEditPart instanceof ClassEditPart); //$NON-NLS-1$
+
+ Object sourceModel = sourceClassEditPart.getModel();
+
+ if (sourceModel instanceof ShapeImpl) {
+ EObject sourceElement = ((ShapeImpl) sourceModel).getElement();
+
+ if (sourceElement instanceof Classifier) {
+ EList<Generalization> generalizations = ((Classifier) sourceElement).getGeneralizations();
+
+ if (generalizations.size() >= 2) {
+ firstGeneralization = generalizations.get(0);
+ secondGeneralization = generalizations.get(1);
+ }
+
+ }
+ }
+ }
+
+ /**
+ * Tests of the move of one generalization.
+ */
+ @Test
+ public void testMoveOneGeneralization() {
+ List<EObject> elements = new ArrayList<EObject>();
+ elements.add(firstGeneralization);
+
+ // Retrieve the command to move the first generalization
+ ICommand command = getCommandMovedElements(elements);
+
+ assertNotNull(command);
+
+ // Get views of the generalizations, The two must be not null.
+ View firstGeneralizationView = getDiagramViewGeneralization(firstGeneralization);
+ View secondGeneralizationView = getDiagramViewGeneralization(secondGeneralization);
+
+ assertNotNull(firstGeneralizationView);
+ assertNotNull(secondGeneralizationView);
+
+ // Moved the first generalization
+ getCommandStack().execute(new GMFtoEMFCommandWrapper(command));
+
+ // Get the views, only the first must be null
+ firstGeneralizationView = getDiagramViewGeneralization(firstGeneralization);
+ secondGeneralizationView = getDiagramViewGeneralization(secondGeneralization);
+
+ assertNull(firstGeneralizationView);
+ assertNotNull(secondGeneralizationView);
+
+ getCommandStack().undo();
+
+ // After the undo command, the two views must be not null
+ firstGeneralizationView = getDiagramViewGeneralization(firstGeneralization);
+ secondGeneralizationView = getDiagramViewGeneralization(secondGeneralization);
+
+ assertNotNull(firstGeneralizationView);
+ assertNotNull(secondGeneralizationView);
+
+ getCommandStack().redo();
+
+ // After the redo command, only the first must be null
+ firstGeneralizationView = getDiagramViewGeneralization(firstGeneralization);
+ secondGeneralizationView = getDiagramViewGeneralization(secondGeneralization);
+
+ assertNull(firstGeneralizationView);
+ assertNotNull(secondGeneralizationView);
+ }
+
+ /**
+ * Tests of the move of two generalizations.
+ */
+ @Test
+ public void testMoveTwoGeneralizations() {
+ List<EObject> elements = new ArrayList<EObject>();
+ elements.add(firstGeneralization);
+ elements.add(secondGeneralization);
+
+ // Retrieve the command to move the generalizations (first and second)
+ ICommand command = getCommandMovedElements(elements);
+
+ assertNotNull(command);
+
+ // Get views of the generalizations, The two must be not null.
+ View diagramViewGeneralization1 = getDiagramViewGeneralization(firstGeneralization);
+ View diagramViewGeneralization2 = getDiagramViewGeneralization(secondGeneralization);
+
+ assertNotNull(diagramViewGeneralization1);
+ assertNotNull(diagramViewGeneralization2);
+
+ // Moved the two generalizations
+ getCommandStack().execute(new GMFtoEMFCommandWrapper(command));
+
+ // Get the views, the two must be null
+ diagramViewGeneralization1 = getDiagramViewGeneralization(firstGeneralization);
+ diagramViewGeneralization2 = getDiagramViewGeneralization(secondGeneralization);
+
+ assertNull(diagramViewGeneralization1);
+ assertNull(diagramViewGeneralization2);
+
+ getCommandStack().undo();
+
+ // After the undo command, the two views must be not null
+ diagramViewGeneralization1 = getDiagramViewGeneralization(firstGeneralization);
+ diagramViewGeneralization2 = getDiagramViewGeneralization(secondGeneralization);
+
+ assertNotNull(diagramViewGeneralization1);
+ assertNotNull(diagramViewGeneralization2);
+
+ getCommandStack().redo();
+
+ // After the redo command, the two must be null
+ diagramViewGeneralization1 = getDiagramViewGeneralization(firstGeneralization);
+ diagramViewGeneralization2 = getDiagramViewGeneralization(secondGeneralization);
+
+ assertNull(diagramViewGeneralization1);
+ assertNull(diagramViewGeneralization2);
+ }
+
+ /**
+ * This creates the command to move the Elements.
+ *
+ * @param elementsToMove
+ * The list of the elements to move.
+ * @return The command to move the elements.
+ */
+ private ICommand getCommandMovedElements(final List<EObject> elementsToMove) {
+ ICommand command = null;
+
+ final Object modelTarget = targetClassEditPart.getModel();
+
+ assertThat(modelTarget, instanceOf(NodeImpl.class));
+
+ final EObject elementTarget = ((NodeImpl) modelTarget).getElement();
+
+ assertNotNull(elementTarget);
+
+ final MoveRequest moveRequest = new MoveRequest(elementTarget, elementsToMove);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(elementTarget);
+
+ assertNotNull(provider);
+
+ // Retrieve delete command from the Element Edit service
+ command = provider.getEditCommand(moveRequest);
+
+ return command;
+ }
+
+
+ /**
+ * Gets the command stack.
+ *
+ * @return the command stack
+ */
+ private CommandStack getCommandStack() {
+ return papyrusEditorFixture.getEditingDomain().getCommandStack();
+ }
+
+ /**
+ * Gets the edit part.
+ *
+ * @param semanticElement
+ * the semantic element
+ * @return The edit part
+ */
+ private EditPart getEditPart(final String semanticElement) {
+ final View diagramView = getDiagramView(semanticElement);
+ assertNotNull(diagramView);
+
+ final IGraphicalEditPart semanticEP = DiagramUtils.findEditPartforView(papyrusEditorFixture.getEditor(), diagramView, IGraphicalEditPart.class);
+ assertNotNull(semanticEP);
+
+ return semanticEP;
+ }
+
+ /**
+ * Gets view of the semantic element.
+ *
+ * @param semanticElement
+ * The name of the semantic element.
+ * @return A corresponding view of the semantic element.
+ */
+ private View getDiagramView(final String semanticElement) {
+ View diagramView = DiagramUtils.findShape(diagram, semanticElement);
+ if (diagramView == null) {
+ diagramView = DiagramUtils.findEdge(diagram, semanticElement);
+ }
+ if (diagramView == null) {
+ Iterator<?> iterator = diagram.eAllContents();
+ while (null == diagramView && iterator.hasNext()) {
+ final Object object = iterator.next();
+ if (object instanceof View) {
+ diagramView = DiagramUtils.findShape((View) object, semanticElement);
+ if (diagramView == null) {
+ diagramView = DiagramUtils.findEdge((View) object, semanticElement);
+ }
+ }
+ }
+ }
+
+ return diagramView;
+ }
+
+ /**
+ * Gets view of a generalization on the diagram.
+ *
+ * @param generalization
+ * The Generalization.
+ * @return A corresponding view of the generalization.
+ */
+ private View getDiagramViewGeneralization(final Generalization generalization) {
+ View diagramView = findViewGeneralization(diagram, generalization);
+ if (diagramView == null) {
+ Iterator<?> iterator = diagram.eAllContents();
+ while (null == diagramView && iterator.hasNext()) {
+ final Object object = iterator.next();
+ if (object instanceof View) {
+ diagramView = findViewGeneralization((View) object, generalization);
+ }
+ }
+ }
+
+ return diagramView;
+ }
+
+ /**
+ * Gets view of the generalization on a specific element.
+ *
+ * @param container
+ * The specific element to find generalization.
+ * @param generalization
+ * Generalization to find.
+ * @return A view of the generalization.
+ */
+ private View findViewGeneralization(final View container, final Generalization generalization) {
+ for (final Object viewObject : container.getChildren()) {
+ final View view = (View) viewObject;
+ if (view.getElement() instanceof Generalization) {
+ final Generalization element = (Generalization) view.getElement();
+ if (generalization.equals(element)) {
+ return view;
+ }
+ }
+ }
+ return null;
+ }
+}

Back to the top