diff options
author | Fanch BONNABESSE | 2016-09-15 14:18:30 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-09-30 10:54:28 +0000 |
commit | d0d15ba0b89d384a0a1937799da0cdacb8e37aa6 (patch) | |
tree | 95b6622578f20b90cf5fccce65e5cf856d5ad43e /tests | |
parent | 76cf97689ddc3334970178550d90655cc402701f (diff) | |
download | org.eclipse.papyrus-d0d15ba0b89d384a0a1937799da0cdacb8e37aa6.tar.gz org.eclipse.papyrus-d0d15ba0b89d384a0a1937799da0cdacb8e37aa6.tar.xz org.eclipse.papyrus-d0d15ba0b89d384a0a1937799da0cdacb8e37aa6.zip |
Bug 500642: [Class Diagram] Property views shall be updated after a
semantic move
https://bugs.eclipse.org/bugs/show_bug.cgi?id=500642
Delete inconsistent views during a move of a Property on the
ModelExplorer view.
Same treatment for Operations and NestClassifiers.
Add of JUnit tests.
Change-Id: I63767c7f51f075972bbfa9142dd77673445da8e1
Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net>
Diffstat (limited to 'tests')
5 files changed, 609 insertions, 1 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/model/MoveContents/model.di b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/model/MoveContents/model.di new file mode 100644 index 00000000000..bf9abab340f --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/model/MoveContents/model.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/> diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/model/MoveContents/model.notation b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/model/MoveContents/model.notation new file mode 100644 index 00000000000..db9fbca1465 --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/model/MoveContents/model.notation @@ -0,0 +1,291 @@ +<?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="_gcF6UIPHEeaLUMUL-20XlQ" type="PapyrusUMLClassDiagram" name="Class Diagram" measurementUnit="Pixel"> + <children xmi:type="notation:Shape" xmi:id="_kAywIIPHEeaLUMUL-20XlQ" type="Class_Shape"> + <children xmi:type="notation:DecorationNode" xmi:id="_kAz-QIPHEeaLUMUL-20XlQ" type="Class_NameLabel"/> + <children xmi:type="notation:DecorationNode" xmi:id="_kA0lUIPHEeaLUMUL-20XlQ" type="Class_FloatingNameLabel"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_kA0lUYPHEeaLUMUL-20XlQ" y="5"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_kA0lUoPHEeaLUMUL-20XlQ" type="Class_AttributeCompartment"> + <children xmi:type="notation:Shape" xmi:id="_HYF_cIPJEeaLUMUL-20XlQ" type="Property_ClassAttributeLabel"> + <element xmi:type="uml:Property" href="model.uml#_chLugIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_HYF_cYPJEeaLUMUL-20XlQ"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_kA0lU4PHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_kA0lVIPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_kA0lVYPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kA0lVoPHEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_kA0lV4PHEeaLUMUL-20XlQ" type="Class_OperationCompartment"> + <children xmi:type="notation:Shape" xmi:id="_HYGmgIPJEeaLUMUL-20XlQ" type="Operation_ClassOperationLabel"> + <element xmi:type="uml:Operation" href="model.uml#_szb1AIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_HYGmgYPJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_HYHNkIPJEeaLUMUL-20XlQ" type="Reception_ReceptionLabel"> + <element xmi:type="uml:Reception" href="model.uml#_-6gIEIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_HYHNkYPJEeaLUMUL-20XlQ"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_kA0lWIPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_kA0lWYPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_kA0lWoPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kA0lW4PHEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_kA0lXIPHEeaLUMUL-20XlQ" type="Class_NestedClassifierCompartment"> + <children xmi:type="notation:Shape" xmi:id="_HYHNkoPJEeaLUMUL-20XlQ" type="Class_ClassNestedClassifierLabel"> + <element xmi:type="uml:Class" href="model.uml#_qv1lkIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_HYHNk4PJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_HYH0oIPJEeaLUMUL-20XlQ" type="PrimitiveType_ClassNestedClassifierLabel"> + <element xmi:type="uml:PrimitiveType" href="model.uml#_tfseEIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_HYH0oYPJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_HYH0ooPJEeaLUMUL-20XlQ" type="Signal_ClassNestedClassifierLabel"> + <element xmi:type="uml:Signal" href="model.uml#_uL3nkIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_HYH0o4PJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_HYIbsIPJEeaLUMUL-20XlQ" type="Interface_ClassNestedClassifierLabel"> + <element xmi:type="uml:Interface" href="model.uml#_v7t0kIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_HYIbsYPJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_HYIbsoPJEeaLUMUL-20XlQ" type="DataType_ClassNestedClassifierLabel"> + <element xmi:type="uml:DataType" href="model.uml#_yKTzEIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_HYIbs4PJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_HYIbtIPJEeaLUMUL-20XlQ" type="Class_ClassNestedClassifierLabel"> + <element xmi:type="uml:StateMachine" href="model.uml#_ADDrkIPJEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_HYIbtYPJEeaLUMUL-20XlQ"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_kA0lXYPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_kA0lXoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_kA0lX4PHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kA0lYIPHEeaLUMUL-20XlQ"/> + </children> + <element xmi:type="uml:Class" href="model.uml#_kArbYIPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kAywIYPHEeaLUMUL-20XlQ" x="76" y="192"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_kYuvAIPHEeaLUMUL-20XlQ" type="Class_Shape"> + <children xmi:type="notation:DecorationNode" xmi:id="_kYv9IIPHEeaLUMUL-20XlQ" type="Class_NameLabel"/> + <children xmi:type="notation:DecorationNode" xmi:id="_kYv9IYPHEeaLUMUL-20XlQ" type="Class_FloatingNameLabel"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_kYv9IoPHEeaLUMUL-20XlQ" y="5"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_kYv9I4PHEeaLUMUL-20XlQ" type="Class_AttributeCompartment"> + <children xmi:type="notation:Shape" xmi:id="_G4TsIIPJEeaLUMUL-20XlQ" type="Property_ClassAttributeLabel"> + <element xmi:type="uml:Property" href="model.uml#_chLugIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_G4TsIYPJEeaLUMUL-20XlQ"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_kYv9JIPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_kYv9JYPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_kYv9JoPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kYv9J4PHEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_kYv9KIPHEeaLUMUL-20XlQ" type="Class_OperationCompartment"> + <children xmi:type="notation:Shape" xmi:id="_G4UTMIPJEeaLUMUL-20XlQ" type="Operation_ClassOperationLabel"> + <element xmi:type="uml:Operation" href="model.uml#_szb1AIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_G4UTMYPJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_G4U6QIPJEeaLUMUL-20XlQ" type="Reception_ReceptionLabel"> + <element xmi:type="uml:Reception" href="model.uml#_-6gIEIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_G4U6QYPJEeaLUMUL-20XlQ"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_kYv9KYPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_kYv9KoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_kYv9K4PHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kYv9LIPHEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_kYv9LYPHEeaLUMUL-20XlQ" type="Class_NestedClassifierCompartment"> + <children xmi:type="notation:Shape" xmi:id="_G4U6QoPJEeaLUMUL-20XlQ" type="Class_ClassNestedClassifierLabel"> + <element xmi:type="uml:Class" href="model.uml#_qv1lkIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_G4U6Q4PJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_G4VhUIPJEeaLUMUL-20XlQ" type="PrimitiveType_ClassNestedClassifierLabel"> + <element xmi:type="uml:PrimitiveType" href="model.uml#_tfseEIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_G4VhUYPJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_G4VhUoPJEeaLUMUL-20XlQ" type="Signal_ClassNestedClassifierLabel"> + <element xmi:type="uml:Signal" href="model.uml#_uL3nkIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_G4VhU4PJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_G4WIYIPJEeaLUMUL-20XlQ" type="Interface_ClassNestedClassifierLabel"> + <element xmi:type="uml:Interface" href="model.uml#_v7t0kIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_G4WIYYPJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_G4WIYoPJEeaLUMUL-20XlQ" type="DataType_ClassNestedClassifierLabel"> + <element xmi:type="uml:DataType" href="model.uml#_yKTzEIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_G4WIY4PJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_G4WIZIPJEeaLUMUL-20XlQ" type="Class_ClassNestedClassifierLabel"> + <element xmi:type="uml:StateMachine" href="model.uml#_ADDrkIPJEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_G4WIZYPJEeaLUMUL-20XlQ"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_kYv9LoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_kYv9L4PHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_kYv9MIPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kYv9MYPHEeaLUMUL-20XlQ"/> + </children> + <element xmi:type="uml:Class" href="model.uml#_kYtg4IPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kYuvAYPHEeaLUMUL-20XlQ" x="332" y="88"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_k9XGEIPHEeaLUMUL-20XlQ" type="Class_Shape"> + <children xmi:type="notation:DecorationNode" xmi:id="_k9XGEoPHEeaLUMUL-20XlQ" type="Class_NameLabel"/> + <children xmi:type="notation:DecorationNode" xmi:id="_k9XGE4PHEeaLUMUL-20XlQ" type="Class_FloatingNameLabel"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_k9XGFIPHEeaLUMUL-20XlQ" y="5"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_k9XGFYPHEeaLUMUL-20XlQ" type="Class_AttributeCompartment"> + <children xmi:type="notation:Shape" xmi:id="_GL55IIPJEeaLUMUL-20XlQ" type="Property_ClassAttributeLabel"> + <element xmi:type="uml:Property" href="model.uml#_chLugIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_GL55IYPJEeaLUMUL-20XlQ"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_k9XGFoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_k9XGF4PHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_k9XGGIPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_k9XGGYPHEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_k9XtIIPHEeaLUMUL-20XlQ" type="Class_OperationCompartment"> + <children xmi:type="notation:Shape" xmi:id="_GL7HQIPJEeaLUMUL-20XlQ" type="Operation_ClassOperationLabel"> + <element xmi:type="uml:Operation" href="model.uml#_szb1AIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_GL7HQYPJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_GL7uUIPJEeaLUMUL-20XlQ" type="Reception_ReceptionLabel"> + <element xmi:type="uml:Reception" href="model.uml#_-6gIEIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_GL7uUYPJEeaLUMUL-20XlQ"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_k9XtIYPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_k9XtIoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_k9XtI4PHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_k9XtJIPHEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_k9XtJYPHEeaLUMUL-20XlQ" type="Class_NestedClassifierCompartment"> + <children xmi:type="notation:Shape" xmi:id="_GL7uUoPJEeaLUMUL-20XlQ" type="Class_ClassNestedClassifierLabel"> + <element xmi:type="uml:Class" href="model.uml#_qv1lkIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_GL7uU4PJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_GL8VYIPJEeaLUMUL-20XlQ" type="PrimitiveType_ClassNestedClassifierLabel"> + <element xmi:type="uml:PrimitiveType" href="model.uml#_tfseEIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_GL8VYYPJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_GL88cIPJEeaLUMUL-20XlQ" type="Signal_ClassNestedClassifierLabel"> + <element xmi:type="uml:Signal" href="model.uml#_uL3nkIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_GL88cYPJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_GL88coPJEeaLUMUL-20XlQ" type="Interface_ClassNestedClassifierLabel"> + <element xmi:type="uml:Interface" href="model.uml#_v7t0kIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_GL88c4PJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_GL9jgIPJEeaLUMUL-20XlQ" type="DataType_ClassNestedClassifierLabel"> + <element xmi:type="uml:DataType" href="model.uml#_yKTzEIPIEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_GL9jgYPJEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_GL9jgoPJEeaLUMUL-20XlQ" type="Class_ClassNestedClassifierLabel"> + <element xmi:type="uml:StateMachine" href="model.uml#_ADDrkIPJEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_GL9jg4PJEeaLUMUL-20XlQ"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_k9XtJoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_k9XtJ4PHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_k9XtKIPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_k9XtKYPHEeaLUMUL-20XlQ"/> + </children> + <element xmi:type="uml:Class" href="model.uml#_k9V38IPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_k9XGEYPHEeaLUMUL-20XlQ" x="609" y="93"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_lL2OAIPHEeaLUMUL-20XlQ" type="Class_Shape"> + <children xmi:type="notation:DecorationNode" xmi:id="_lL2OAoPHEeaLUMUL-20XlQ" type="Class_NameLabel"/> + <children xmi:type="notation:DecorationNode" xmi:id="_lL2OA4PHEeaLUMUL-20XlQ" type="Class_FloatingNameLabel"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_lL2OBIPHEeaLUMUL-20XlQ" y="5"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_lL21EIPHEeaLUMUL-20XlQ" type="Class_AttributeCompartment"> + <styles xmi:type="notation:TitleStyle" xmi:id="_lL21EYPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_lL21EoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_lL21E4PHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_lL21FIPHEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_lL21FYPHEeaLUMUL-20XlQ" type="Class_OperationCompartment"> + <styles xmi:type="notation:TitleStyle" xmi:id="_lL21FoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_lL21F4PHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_lL21GIPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_lL21GYPHEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_lL21GoPHEeaLUMUL-20XlQ" type="Class_NestedClassifierCompartment"> + <styles xmi:type="notation:TitleStyle" xmi:id="_lL21G4PHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_lL21HIPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_lL21HYPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_lL21HoPHEeaLUMUL-20XlQ"/> + </children> + <element xmi:type="uml:Class" href="model.uml#_lL0_4IPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_lL2OAYPHEeaLUMUL-20XlQ" x="400" y="417"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_mqTJAIPHEeaLUMUL-20XlQ" type="Class_Shape"> + <children xmi:type="notation:DecorationNode" xmi:id="_mqTwEIPHEeaLUMUL-20XlQ" type="Class_NameLabel"/> + <children xmi:type="notation:DecorationNode" xmi:id="_mqTwEYPHEeaLUMUL-20XlQ" type="Class_FloatingNameLabel"> + <layoutConstraint xmi:type="notation:Location" xmi:id="_mqTwEoPHEeaLUMUL-20XlQ" y="5"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_mqTwE4PHEeaLUMUL-20XlQ" type="Class_AttributeCompartment"> + <styles xmi:type="notation:TitleStyle" xmi:id="_mqTwFIPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_mqTwFYPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_mqTwFoPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_mqTwF4PHEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_mqTwGIPHEeaLUMUL-20XlQ" type="Class_OperationCompartment"> + <styles xmi:type="notation:TitleStyle" xmi:id="_mqTwGYPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_mqTwGoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_mqTwG4PHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_mqTwHIPHEeaLUMUL-20XlQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_mqTwHYPHEeaLUMUL-20XlQ" type="Class_NestedClassifierCompartment"> + <styles xmi:type="notation:TitleStyle" xmi:id="_mqTwHoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_mqTwH4PHEeaLUMUL-20XlQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_mqTwIIPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_mqTwIYPHEeaLUMUL-20XlQ"/> + </children> + <element xmi:type="uml:Class" href="model.uml#_mqR64IPHEeaLUMUL-20XlQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_mqTJAYPHEeaLUMUL-20XlQ" x="637" y="413"/> + </children> + <styles xmi:type="notation:StringValueStyle" xmi:id="_gcF6UYPHEeaLUMUL-20XlQ" name="diagram_compatibility_version" stringValue="1.2.0"/> + <styles xmi:type="notation:DiagramStyle" xmi:id="_gcF6UoPHEeaLUMUL-20XlQ"/> + <styles xmi:type="style:PapyrusViewStyle" xmi:id="_gcF6U4PHEeaLUMUL-20XlQ"> + <owner xmi:type="uml:Model" href="model.uml#_gbFNsIPHEeaLUMUL-20XlQ"/> + </styles> + <element xmi:type="uml:Model" href="model.uml#_gbFNsIPHEeaLUMUL-20XlQ"/> + <edges xmi:type="notation:Connector" xmi:id="_wV32cIPHEeaLUMUL-20XlQ" type="Generalization_Edge" source="_kAywIIPHEeaLUMUL-20XlQ" target="_kYuvAIPHEeaLUMUL-20XlQ"> + <children xmi:type="notation:DecorationNode" xmi:id="_wV32c4PHEeaLUMUL-20XlQ" type="Generalization_StereotypeLabel"> + <styles xmi:type="notation:BooleanValueStyle" xmi:id="_DV7xkIPJEeaLUMUL-20XlQ" name="IS_UPDATED_POSITION" booleanValue="true"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_wV32dIPHEeaLUMUL-20XlQ" x="-1" y="39"/> + </children> + <styles xmi:type="notation:FontStyle" xmi:id="_wV32cYPHEeaLUMUL-20XlQ"/> + <element xmi:type="uml:Generalization" href="model.uml#_wVmJoIPHEeaLUMUL-20XlQ"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_wV32coPHEeaLUMUL-20XlQ" points="[193, 223, -643984, -643984]$[405, 144, -643984, -643984]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_wW04sIPHEeaLUMUL-20XlQ" id="(1.0,0.11650485436893204)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_wW04sYPHEeaLUMUL-20XlQ" id="(0.0,0.3786407766990291)"/> + </edges> + <edges xmi:type="notation:Connector" xmi:id="_w7qrIIPHEeaLUMUL-20XlQ" type="Generalization_Edge" source="_kYuvAIPHEeaLUMUL-20XlQ" target="_k9XGEIPHEeaLUMUL-20XlQ"> + <children xmi:type="notation:DecorationNode" xmi:id="_w7rSMIPHEeaLUMUL-20XlQ" type="Generalization_StereotypeLabel"> + <styles xmi:type="notation:BooleanValueStyle" xmi:id="_DWS98IPJEeaLUMUL-20XlQ" name="IS_UPDATED_POSITION" booleanValue="true"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_w7rSMYPHEeaLUMUL-20XlQ" y="39"/> + </children> + <styles xmi:type="notation:FontStyle" xmi:id="_w7qrIYPHEeaLUMUL-20XlQ"/> + <element xmi:type="uml:Generalization" href="model.uml#_w7YXQIPHEeaLUMUL-20XlQ"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_w7qrIoPHEeaLUMUL-20XlQ" points="[505, 150, -643984, -643984]$[681, 151, -643984, -643984]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_w8KaYIPHEeaLUMUL-20XlQ" id="(1.0,0.4368932038834951)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_w8LBcIPHEeaLUMUL-20XlQ" id="(0.0,0.4077669902912621)"/> + </edges> + <edges xmi:type="notation:Connector" xmi:id="_xRApAIPHEeaLUMUL-20XlQ" type="Generalization_Edge" source="_kAywIIPHEeaLUMUL-20XlQ" target="_lL2OAIPHEeaLUMUL-20XlQ"> + <children xmi:type="notation:DecorationNode" xmi:id="_xRBQEIPHEeaLUMUL-20XlQ" type="Generalization_StereotypeLabel"> + <styles xmi:type="notation:BooleanValueStyle" xmi:id="_DWHXwIPJEeaLUMUL-20XlQ" name="IS_UPDATED_POSITION" booleanValue="true"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_xRBQEYPHEeaLUMUL-20XlQ" x="1" y="38"/> + </children> + <styles xmi:type="notation:FontStyle" xmi:id="_xRApAYPHEeaLUMUL-20XlQ"/> + <element xmi:type="uml:Generalization" href="model.uml#_xQ1p4IPHEeaLUMUL-20XlQ"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_xRApAoPHEeaLUMUL-20XlQ" points="[193, 287, -643984, -643984]$[410, 385, -643984, -643984]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_xRXOUIPHEeaLUMUL-20XlQ" id="(1.0,0.7572815533980582)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_xRXOUYPHEeaLUMUL-20XlQ" id="(0.0,0.41)"/> + </edges> + <edges xmi:type="notation:Connector" xmi:id="_xxHFYIPHEeaLUMUL-20XlQ" type="Generalization_Edge" source="_lL2OAIPHEeaLUMUL-20XlQ" target="_mqTJAIPHEeaLUMUL-20XlQ"> + <children xmi:type="notation:DecorationNode" xmi:id="_xxHFY4PHEeaLUMUL-20XlQ" type="Generalization_StereotypeLabel"> + <styles xmi:type="notation:BooleanValueStyle" xmi:id="_DWhAYIPJEeaLUMUL-20XlQ" name="IS_UPDATED_POSITION" booleanValue="true"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_xxHFZIPHEeaLUMUL-20XlQ" y="40"/> + </children> + <styles xmi:type="notation:FontStyle" xmi:id="_xxHFYYPHEeaLUMUL-20XlQ"/> + <element xmi:type="uml:Generalization" href="model.uml#_xwyVQIPHEeaLUMUL-20XlQ"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_xxHFYoPHEeaLUMUL-20XlQ" points="[510, 411, -643984, -643984]$[689, 411, -643984, -643984]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_xxijMIPHEeaLUMUL-20XlQ" id="(1.0,0.67)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_xxijMYPHEeaLUMUL-20XlQ" id="(0.0,0.69)"/> + </edges> +</notation:Diagram> diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/model/MoveContents/model.uml b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/model/MoveContents/model.uml new file mode 100644 index 00000000000..9cc91753e06 --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/model/MoveContents/model.uml @@ -0,0 +1,25 @@ +<?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="_gbFNsIPHEeaLUMUL-20XlQ" name="RootElement"> + <packagedElement xmi:type="uml:Class" xmi:id="_kArbYIPHEeaLUMUL-20XlQ" name="Class1"> + <generalization xmi:type="uml:Generalization" xmi:id="_wVmJoIPHEeaLUMUL-20XlQ" general="_kYtg4IPHEeaLUMUL-20XlQ"/> + <generalization xmi:type="uml:Generalization" xmi:id="_xQ1p4IPHEeaLUMUL-20XlQ" general="_lL0_4IPHEeaLUMUL-20XlQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Class" xmi:id="_kYtg4IPHEeaLUMUL-20XlQ" name="Class2"> + <generalization xmi:type="uml:Generalization" xmi:id="_w7YXQIPHEeaLUMUL-20XlQ" general="_k9V38IPHEeaLUMUL-20XlQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Class" xmi:id="_k9V38IPHEeaLUMUL-20XlQ" name="Class3"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_chLugIPIEeaLUMUL-20XlQ" name="Attribute1"/> + <ownedOperation xmi:type="uml:Operation" xmi:id="_szb1AIPIEeaLUMUL-20XlQ" name="Operation1"/> + <nestedClassifier xmi:type="uml:Class" xmi:id="_qv1lkIPIEeaLUMUL-20XlQ" name="NestedClass"/> + <nestedClassifier xmi:type="uml:PrimitiveType" xmi:id="_tfseEIPIEeaLUMUL-20XlQ" name="PrimitiveType1"/> + <nestedClassifier xmi:type="uml:Signal" xmi:id="_uL3nkIPIEeaLUMUL-20XlQ" name="Signal1"/> + <nestedClassifier xmi:type="uml:Interface" xmi:id="_v7t0kIPIEeaLUMUL-20XlQ" name="Interface1"/> + <nestedClassifier xmi:type="uml:DataType" xmi:id="_yKTzEIPIEeaLUMUL-20XlQ" name="DataType1"/> + <nestedClassifier xmi:type="uml:StateMachine" xmi:id="_ADDrkIPJEeaLUMUL-20XlQ" name="StateMachine1"/> + <ownedReception xmi:type="uml:Reception" xmi:id="_-6gIEIPIEeaLUMUL-20XlQ" name="Reception1"/> + </packagedElement> + <packagedElement xmi:type="uml:Class" xmi:id="_lL0_4IPHEeaLUMUL-20XlQ" name="Class4"> + <generalization xmi:type="uml:Generalization" xmi:id="_xwyVQIPHEeaLUMUL-20XlQ" general="_mqR64IPHEeaLUMUL-20XlQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Class" xmi:id="_mqR64IPHEeaLUMUL-20XlQ" name="Class5"/> +</uml:Model> diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/AllTests.java index f38a89a969f..1195b94b39b 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/AllTests.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/AllTests.java @@ -22,6 +22,7 @@ import org.eclipse.papyrus.uml.diagram.clazz.test.legacy.PackageDiagramLegacyTes import org.eclipse.papyrus.uml.diagram.clazz.test.tests.Bug382954_InstanceSpecificationLink; import org.eclipse.papyrus.uml.diagram.clazz.test.tests.Bug476872_MoveCommandTest; import org.eclipse.papyrus.uml.diagram.clazz.test.tests.Bug481317_MoveGeneralizationTest; +import org.eclipse.papyrus.uml.diagram.clazz.test.tests.MoveContentsTest; import org.eclipse.papyrus.uml.diagram.clazz.test.tests.RoundedCompartmentTest; import org.junit.runner.RunWith; import org.junit.runners.Suite.SuiteClasses; @@ -39,7 +40,8 @@ import org.junit.runners.Suite.SuiteClasses; ConstraintPasteStrategyTest.class, RoundedCompartmentTest.class, Bug476872_MoveCommandTest.class, - Bug481317_MoveGeneralizationTest.class + Bug481317_MoveGeneralizationTest.class, + MoveContentsTest.class // load // LoadTests.class diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/tests/MoveContentsTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/tests/MoveContentsTest.java new file mode 100644 index 00000000000..3827eed5b0e --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/tests/MoveContentsTest.java @@ -0,0 +1,288 @@ +/***************************************************************************** + * Copyright (c) 2016 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@alltec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.clazz.test.tests; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +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.papyrus.infra.emf.gmf.command.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.uml2.uml.Class; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Package; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +/** + * + * Used to test the deletion of the views of contents (Attributes, Operations, Receptions and NestedClassifiers) when it is moved. + * + */ +@PluginResource("/model/MoveContents/model.di") +public class MoveContentsTest extends AbstractPapyrusTest { + + /** The name of the Class1. */ + private static final String NAME_CLASS_1 = "Class1"; //$NON-NLS-1$ + /** The name of the Class2. */ + private static final String NAME_CLASS_2 = "Class2"; //$NON-NLS-1$ + /** The name of the Class3. */ + private static final String NAME_CLASS_3 = "Class3"; //$NON-NLS-1$ + /** The name of the Class5. */ + private static final String NAME_CLASS_5 = "Class5"; //$NON-NLS-1$ + /** The name of the diagram used for testing. */ + private static final String NAME_DIAGRAM = "Class Diagram"; //$NON-NLS-1$ + + /** The Papyrus editor fixture. */ + @Rule + public final PapyrusEditorFixture papyrusEditorFixture = new PapyrusEditorFixture(); + + /** The model of the fixture. */ + private Package model = null; + + /** The list of the contents of the element. */ + private List<EObject> contents = null; + + /** The diagram. */ + private Diagram diagram = null; + + @Before + public void init() { + model = papyrusEditorFixture.getModel(); + assertNotNull("The model cannot be null", model); //$NON-NLS-1$ + + diagram = DiagramUtils.getNotationDiagram(papyrusEditorFixture.getModelSet(), NAME_DIAGRAM); + assertNotNull(diagram); + + // Get the source element. + EObject element = model.getMember(NAME_CLASS_3); + assertTrue("The object must be a Class.", element instanceof Class); //$NON-NLS-1$ + + // Get all the contents. The element contains 1 attribute, 1 operation, 1 reception and 6 nested classifiers. + contents = new ArrayList<EObject>(); + contents.addAll(((Class) element).getAllAttributes()); + // 1 attribute + assertTrue("The list must contains 1 element but was " + contents.size(), 1 == contents.size()); //$NON-NLS-1$ + contents.addAll(((Class) element).getAllOperations()); + // 1 Attribute + 1 Operation + assertTrue("The list must contains 2 elements but was " + contents.size(), 2 == contents.size()); //$NON-NLS-1$ + contents.addAll(((Class) element).getOwnedReceptions()); + // 1 Attribute + 1 Operation + 1 Reception + assertTrue("The list must contains 3 elements but was " + contents.size(), 3 == contents.size()); //$NON-NLS-1$ + contents.addAll(((Class) element).getNestedClassifiers()); + // 1 Attribute + 1 Operation + 1 Reception + 6 NestedClassifiers + assertTrue("The list must contains 9 elements but was " + contents.size(), 9 == contents.size()); //$NON-NLS-1$ + + papyrusEditorFixture.getPageManager().openPage(diagram); + papyrusEditorFixture.flushDisplayEvents(); + } + + /** + * Test to move all the contents (Attributes, Operations and Nest Classifiers) of the class 'Class3' to 'Class5'. + * No inheritance exists between the classes. + */ + @Test + public void testAllContentsNoInheritance() { + // The target class is 'Class5'. + NamedElement targetMember = model.getMember(NAME_CLASS_5); + assertTrue("The object must be a Class.", targetMember instanceof Class); //$NON-NLS-1$ + + // Retrieve the command to move the elements. + ICommand command = getCommandMovedElements(contents, targetMember); + assertNotNull("The command must not be null.", command); //$NON-NLS-1$ + + papyrusEditorFixture.getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(command)); + + for (EObject eObject : contents) { + // Target class 'Class5' is a parent of Class1, the views must not be deleted + View objectView = getDiagramViewEObject(eObject, NAME_CLASS_1); + assertNotNull("Many views must be found.", objectView); //$NON-NLS-1$ + // Target class 'Class5' is not a parent of Class2, the views must be deleted + objectView = getDiagramViewEObject(eObject, NAME_CLASS_2); + assertNull("No view must be found.", objectView); //$NON-NLS-1$ + // Target class 'Class5' is not a parent of Class3, the views must be deleted + objectView = getDiagramViewEObject(eObject, NAME_CLASS_3); + assertNull("No view must be found.", objectView); //$NON-NLS-1$ + } + + papyrusEditorFixture.getEditingDomain().getCommandStack().undo(); + + for (EObject eObject : contents) { + // All the views are shown after the undo. + View objectView = getDiagramViewEObject(eObject, NAME_CLASS_1); + assertNotNull("Many views must be found.", objectView);//$NON-NLS-1$ + objectView = getDiagramViewEObject(eObject, NAME_CLASS_2); + assertNotNull("Many views must be found.", objectView); //$NON-NLS-1$ + objectView = getDiagramViewEObject(eObject, NAME_CLASS_3); + assertNotNull("Many views must be found.", objectView); //$NON-NLS-1$ + } + + papyrusEditorFixture.getEditingDomain().getCommandStack().redo(); + + for (EObject eObject : contents) { + // Target class 'Class5' is a parent of 'Class1', the views must not be deleted + View objectView = getDiagramViewEObject(eObject, NAME_CLASS_1); + assertNotNull("Many views must be found.", objectView); //$NON-NLS-1$ + // Target class 'Class5' is not a parent of 'Class2', the views must be deleted + objectView = getDiagramViewEObject(eObject, NAME_CLASS_2); + assertNull("No view must be found.", objectView); //$NON-NLS-1$ + // Target class 'Class5' is not a parent of 'Class3', the views must be deleted + objectView = getDiagramViewEObject(eObject, NAME_CLASS_3); + assertNull("No view must be found.", objectView); //$NON-NLS-1$ + } + } + + /** + * Test to move all the contents (Attributes, Operations and Nest Classifiers) of the class 'Class3' to 'Class2'. + * The class 'Class2' is a child of 'Class3'. + */ + @Test + public void testAllContentsToChild() { + // The target class is 'Class2'. + NamedElement targetMember = model.getMember(NAME_CLASS_2); + assertTrue("The object must be a Class.", targetMember instanceof Class); //$NON-NLS-1$ + + // Retrieve the command to move the elements. + ICommand command = getCommandMovedElements(contents, targetMember); + assertNotNull("The command must not be null.", command); //$NON-NLS-1$ + + papyrusEditorFixture.getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(command)); + + for (EObject eObject : contents) { + // Target class 'Class2' is a parent of Class1, the views must not be deleted + View objectView = getDiagramViewEObject(eObject, NAME_CLASS_1); + assertNotNull("Many views must be found.", objectView); //$NON-NLS-1$ + // It's the target class, the views must not be deleted. + objectView = getDiagramViewEObject(eObject, NAME_CLASS_2); + assertNotNull("Many views must be found..", objectView); //$NON-NLS-1$ + // Target class 'Class2' is not a parent of 'Class2', the views must be deleted + objectView = getDiagramViewEObject(eObject, NAME_CLASS_3); + assertNull("No view must be found.", objectView); //$NON-NLS-1$ + } + + papyrusEditorFixture.getEditingDomain().getCommandStack().undo(); + + for (EObject eObject : contents) { + // All the views are shown after the undo. + View objectView = getDiagramViewEObject(eObject, NAME_CLASS_1); + assertNotNull("Many views must be found.", objectView); //$NON-NLS-1$ + objectView = getDiagramViewEObject(eObject, NAME_CLASS_2); + assertNotNull("Many views must be found.", objectView); //$NON-NLS-1$ + objectView = getDiagramViewEObject(eObject, NAME_CLASS_3); + assertNotNull("Many views must be found.", objectView); //$NON-NLS-1$ + } + + papyrusEditorFixture.getEditingDomain().getCommandStack().redo(); + + for (EObject eObject : contents) { + // Target class 'Class2' is a parent of Class1, the views must not be deleted + View objectView = getDiagramViewEObject(eObject, NAME_CLASS_1); + assertNotNull("Many views must be found.", objectView); //$NON-NLS-1$ + // It's the target class, the views must not be deleted. + objectView = getDiagramViewEObject(eObject, NAME_CLASS_2); + assertNotNull("Many views must be found..", objectView); //$NON-NLS-1$ + // Target class 'Class2' is not a parent of 'Class2', the views must be deleted + objectView = getDiagramViewEObject(eObject, NAME_CLASS_3); + assertNull("No view must be found.", objectView); //$NON-NLS-1$ + } + } + + /** + * 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, final EObject elementTarget) { + ICommand command = null; + + 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 view of an EObject on the diagram and on a class. + * + * @param eObject + * The EObject. + * @param classNameReference + * The name of the class in which the EObject reference must be. + * @return A corresponding view of the EObject. + */ + private View getDiagramViewEObject(final EObject eObject, final String classNameReference) { + View diagramView = findViewReference(diagram, eObject); + + if (null == diagramView) { + Iterator<?> iterator = diagram.eAllContents(); + while (null == diagramView && iterator.hasNext()) { + final Object object = iterator.next(); + if (object instanceof View) { + EObject element = ((View) object).getElement(); + if (element instanceof Classifier) { + if (classNameReference.equals(((Classifier) element).getName())) { + diagramView = findViewReference((View) object, eObject); + } + } + } + } + } + + return diagramView; + } + + /** + * Gets view of the EObject on a specific element. + * + * @param container + * The specific element to find EObject. + * @param eObject + * EObject to find. + * @return A view of the EObject. + */ + private View findViewReference(final View container, final EObject eObject) { + for (final Object viewObject : container.getChildren()) { + final View view = (View) viewObject; + final EObject element = view.getElement(); + if (eObject.equals(element)) { + return view; + } + } + return null; + } + +} |