Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2019-01-16 07:34:10 -0500
committervincent lorenzo2019-01-27 05:06:46 -0500
commit17cb516fffb57b2968860900469d4987f5936500 (patch)
treef5d85fb5f96fd476a3cd02c92a834b210ec9f78f
parent84f851475dbcae5030c99bd3c762157551c37d62 (diff)
downloadorg.eclipse.papyrus-17cb516fffb57b2968860900469d4987f5936500.tar.gz
org.eclipse.papyrus-17cb516fffb57b2968860900469d4987f5936500.tar.xz
org.eclipse.papyrus-17cb516fffb57b2968860900469d4987f5936500.zip
Bug 541686 - Multiple clients and suppliers in edges after copy-paste
- Remove copy-references from DiagramPasteStrategy (duplicate, since already in defaultPasteStrategy) - Fix typo in DefaultPasteCommand - Add new test UMLCopyTestME. Similar to existing copy test, but based on copier command in model explorer (including additional strategies and not only the copier itself) Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr> Change-Id: Ia786713a069fb69fd24e520466e4021cc6ea0c20
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/DiagramPasteStrategy.java12
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.di2
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.notation72
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml8
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTest.java12
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTestME.java98
8 files changed, 194 insertions, 15 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java
index 7cac4ac1b5d..726ebe64899 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java
@@ -79,7 +79,7 @@ public class DefaultPasteCommand extends AbstractCommand {
Map<EObject, EObject> duplicatedObjects = new HashMap<EObject, EObject>();
duplicatedObjects.putAll(copier);
- // Inform the clipboard of the elment created (used by strategies)
+ // Inform the clipboard of the element created (used by strategies)
papyrusClipboard.addAllInternalToTargetCopy(duplicatedObjects);
// Prepare the move command to move UML element to their new owner
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/DiagramPasteStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/DiagramPasteStrategy.java
index e78efeb1ede..203f9ae7afe 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/DiagramPasteStrategy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/DiagramPasteStrategy.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2019 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,8 @@
*
* Contributors:
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - bug 541686 (duplicated replationships)
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste;
@@ -152,7 +154,7 @@ public class DiagramPasteStrategy extends AbstractPasteStrategy implements IPast
*/
@Override
public void prepare(PapyrusClipboard<Object> papyrusClipboard, Collection<EObject> selection) {
- Map<Object, IClipboardAdditionalData> mapCopyToClipboardAdditionalData = new HashMap<Object, IClipboardAdditionalData>();
+ Map<Object, IClipboardAdditionalData> mapCopyToClipboardAdditionalData = new HashMap<>();
Map sourceToInternalClipboard = papyrusClipboard.getSourceToInternalClipboard();
List<Diagram> extractSelectedWithoutOwner = extractDiagramWithoutOwner(selection);
if (extractSelectedWithoutOwner != null && !extractSelectedWithoutOwner.isEmpty()) {
@@ -182,7 +184,7 @@ public class DiagramPasteStrategy extends AbstractPasteStrategy implements IPast
* @return
*/
protected List<Diagram> extractDiagramWithoutOwner(Collection<EObject> selection) {
- List<Diagram> diagramWithoutOwnerInSelection = new ArrayList<Diagram>();
+ List<Diagram> diagramWithoutOwnerInSelection = new ArrayList<>();
if (selection != null) {
for (EObject eObject : selection) {
if (eObject instanceof Diagram) {
@@ -225,12 +227,12 @@ public class DiagramPasteStrategy extends AbstractPasteStrategy implements IPast
* @return duplicated diagrams
*/
protected Collection<Diagram> duplicateDiagrams(Collection<Diagram> diagrams, Map<? extends EObject, ? extends EObject> alreadyCopied) {
- Collection<Diagram> duplicatedDiagrams = new ArrayList<Diagram>();
+ Collection<Diagram> duplicatedDiagrams = new ArrayList<>();
EcoreUtil.Copier copier = new EcoreUtil.Copier();
copier.putAll(alreadyCopied);
for (Diagram diagram : diagrams) {
copier.copy(diagram);
- copier.copyReferences();
+ // do not copy references (already done in default strategy), avoid duplicates
EObject copy = copier.get(diagram);
if (copy instanceof Diagram) {
duplicatedDiagrams.add((Diagram) copy);
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF
index 9ad079b75b9..2f396010ead 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF
@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.junit.utils;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.0.0,4.0.0)",
org.eclipse.jface.text;bundle-version="3.10.0",
- org.eclipse.papyrus.infra.ui.emf;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.infra.ui.emf;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.views.modelexplorer;bundle-version="[3.0.0,4.0.0)"
Export-Package: org.eclipse.papyrus.uml.tools.tests,
org.eclipse.papyrus.uml.tools.tests.tests
Bundle-Vendor: Eclipse Modeling Project
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.di b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.di
new file mode 100644
index 00000000000..bf9abab340f
--- /dev/null
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.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/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.notation b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.notation
new file mode 100644
index 00000000000..8801412fa57
--- /dev/null
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.notation
@@ -0,0 +1,72 @@
+<?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/gmfdiag/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_9lbGkBjaEem8A9OSivWrCQ" type="PapyrusUMLClassDiagram" name="NewClassDiagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_-sxJIBjaEem8A9OSivWrCQ" type="Class_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_-sxwMBjaEem8A9OSivWrCQ" type="Class_NameLabel"/>
+ <children xmi:type="notation:DecorationNode" xmi:id="_-syXQBjaEem8A9OSivWrCQ" type="Class_FloatingNameLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_-syXQRjaEem8A9OSivWrCQ" y="15"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_-syXQhjaEem8A9OSivWrCQ" visible="false" type="Class_AttributeCompartment">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_-syXQxjaEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_-syXRBjaEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_-syXRRjaEem8A9OSivWrCQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_-syXRhjaEem8A9OSivWrCQ"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_-syXRxjaEem8A9OSivWrCQ" visible="false" type="Class_OperationCompartment">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_-syXSBjaEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_-syXSRjaEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_-syXShjaEem8A9OSivWrCQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_-syXSxjaEem8A9OSivWrCQ"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_-syXTBjaEem8A9OSivWrCQ" visible="false" type="Class_NestedClassifierCompartment">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_-syXTRjaEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_-syXThjaEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_-syXTxjaEem8A9OSivWrCQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_-syXUBjaEem8A9OSivWrCQ"/>
+ </children>
+ <element xmi:type="uml:Class" href="copy.uml#_ayu-EJ1CEeaVooFvMLWt7w"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_-sxJIRjaEem8A9OSivWrCQ" x="60" y="160" width="143" height="47"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_CjtlgBjbEem8A9OSivWrCQ" type="Interface_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_CjuMkBjbEem8A9OSivWrCQ" type="Interface_NameLabel"/>
+ <children xmi:type="notation:DecorationNode" xmi:id="_CjuMkRjbEem8A9OSivWrCQ" type="Interface_FloatingNameLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_CjuMkhjbEem8A9OSivWrCQ" y="15"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_CjuzoBjbEem8A9OSivWrCQ" visible="false" type="Interface_AttributeCompartment">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_CjuzoRjbEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_CjuzohjbEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_CjuzoxjbEem8A9OSivWrCQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CjuzpBjbEem8A9OSivWrCQ"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_CjuzpRjbEem8A9OSivWrCQ" visible="false" type="Interface_OperationCompartment">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_CjuzphjbEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_CjuzpxjbEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_CjuzqBjbEem8A9OSivWrCQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CjuzqRjbEem8A9OSivWrCQ"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_CjuzqhjbEem8A9OSivWrCQ" visible="false" type="Interface_NestedClassifierCompartment">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_CjuzqxjbEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_CjuzrBjbEem8A9OSivWrCQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_CjuzrRjbEem8A9OSivWrCQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CjuzrhjbEem8A9OSivWrCQ"/>
+ </children>
+ <element xmi:type="uml:Interface" href="copy.uml#_X4LRcJ1CEeaVooFvMLWt7w"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_CjtlgRjbEem8A9OSivWrCQ" x="60" y="40" width="141" height="61"/>
+ </children>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_9lbGkRjaEem8A9OSivWrCQ" name="diagram_compatibility_version" stringValue="1.4.0"/>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_9lbGkhjaEem8A9OSivWrCQ"/>
+ <styles xmi:type="style:PapyrusDiagramStyle" xmi:id="_9lbGkxjaEem8A9OSivWrCQ" diagramKindId="org.eclipse.papyrus.uml.diagram.class">
+ <owner xmi:type="uml:Package" href="copy.uml#_AIJz8BjZEem7BIZrhZyBaw"/>
+ </styles>
+ <element xmi:type="uml:Package" href="copy.uml#_AIJz8BjZEem7BIZrhZyBaw"/>
+ <edges xmi:type="notation:Connector" xmi:id="_KqfhUBmJEemC__uBmE7O8g" type="InterfaceRealization_Edge" source="_-sxJIBjaEem8A9OSivWrCQ" target="_CjtlgBjbEem8A9OSivWrCQ">
+ <children xmi:type="notation:DecorationNode" xmi:id="_KqhWgBmJEemC__uBmE7O8g" type="InterfaceRealization_StereotypeLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_KqhWgRmJEemC__uBmE7O8g" y="40"/>
+ </children>
+ <children xmi:type="notation:DecorationNode" xmi:id="_Kqh9kBmJEemC__uBmE7O8g" type="InterfaceRealization_NameLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Kqh9kRmJEemC__uBmE7O8g" y="60"/>
+ </children>
+ <styles xmi:type="notation:FontStyle" xmi:id="_KqfhURmJEemC__uBmE7O8g"/>
+ <element xmi:type="uml:InterfaceRealization" href="copy.uml#_cy_loJ1CEeaVooFvMLWt7w"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_KqfhUhmJEemC__uBmE7O8g" points="[130, 160, -643984, -643984]$[131, 101, -643984, -643984]"/>
+ </edges>
+</notation:Diagram>
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml
index 05188ff7ec1..f1665c43305 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<uml:Package 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="_Oo_lEJ1CEeaVooFvMLWt7w" name="copy" URI="http://www.eclipse.org/papyrus/test/copy">
- <packagedElement xmi:type="uml:Interface" xmi:id="_X4LRcJ1CEeaVooFvMLWt7w" name="Foo"/>
- <packagedElement xmi:type="uml:Class" xmi:id="_ayu-EJ1CEeaVooFvMLWt7w" name="Bar">
- <interfaceRealization xmi:id="_cy_loJ1CEeaVooFvMLWt7w" client="_ayu-EJ1CEeaVooFvMLWt7w" supplier="_X4LRcJ1CEeaVooFvMLWt7w" contract="_X4LRcJ1CEeaVooFvMLWt7w"/>
+ <packagedElement xmi:type="uml:Package" xmi:id="_AIJz8BjZEem7BIZrhZyBaw" name="pkg">
+ <packagedElement xmi:type="uml:Interface" xmi:id="_X4LRcJ1CEeaVooFvMLWt7w" name="Foo"/>
+ <packagedElement xmi:type="uml:Class" xmi:id="_ayu-EJ1CEeaVooFvMLWt7w" name="Bar">
+ <interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_cy_loJ1CEeaVooFvMLWt7w" client="_ayu-EJ1CEeaVooFvMLWt7w" supplier="_X4LRcJ1CEeaVooFvMLWt7w" contract="_X4LRcJ1CEeaVooFvMLWt7w"/>
+ </packagedElement>
</packagedElement>
</uml:Package>
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTest.java b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTest.java
index b55af332381..19630cf7f06 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTest.java
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTest.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2016 Christian W. Damus and others.
- *
+ * Copyright (c) 2016, 2019 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 2.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,8 @@
*
* Contributors:
* Christian W. Damus - Initial API and implementation
- *
+ * Ansgar Radermacher (CEA LIST) - common test model with UMLCopyTestME (context bug 541686)
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.tools.tests.tests;
@@ -88,8 +89,9 @@ public class UMLCopyTest {
model = UMLUtil.load(rset,
URI.createPlatformPluginURI("org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml", true),
UMLPackage.Literals.PACKAGE);
- foo = (Interface) model.getOwnedType("Foo");
- bar = (Class) model.getOwnedType("Bar");
+ Package pkg = model.getNestedPackage("pkg");
+ foo = (Interface) pkg.getOwnedType("Foo");
+ bar = (Class) pkg.getOwnedType("Bar");
rlz = bar.getInterfaceRealization(null, foo);
}
}
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTestME.java b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTestME.java
new file mode 100644
index 00000000000..32ad903ba58
--- /dev/null
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTestME.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2014, 2019 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Ansgar Radermacher (CEA LIST) - bug 541686 (duplicated replationships)
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.tools.tests.tests;
+
+import static org.hamcrest.CoreMatchers.both;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Arrays;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
+import org.eclipse.papyrus.junit.utils.rules.ModelSetFixture;
+import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.papyrus.junit.utils.rules.ServiceRegistryModelSetFixture;
+import org.eclipse.papyrus.views.modelexplorer.handler.CopyHandler;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Interface;
+import org.eclipse.uml2.uml.InterfaceRealization;
+import org.eclipse.uml2.uml.Package;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Test cases for the copy command from the model explorer (hence ME in test name).
+ * The CopyHandler from the modelexplorer view is used. Thus, the test corresponds
+ * to the behavior experienced by the user, it complements class UMLCopyTest that
+ * tests the underlying copier.
+ */
+@PluginResource("resources/uml/copy.di")
+public class UMLCopyTestME extends AbstractPapyrusTest {
+
+
+ @Rule
+ public final HouseKeeper houseKeeper = new HouseKeeper();
+
+ @Rule
+ public final ModelSetFixture modelSet = new ServiceRegistryModelSetFixture();
+
+ @Rule
+ public final PapyrusEditorFixture editor = new PapyrusEditorFixture();
+
+ /**
+ * Name of model elements
+ */
+ private static final String PKG = "pkg"; //$NON-NLS-1$
+ private static final String BAR = "Bar"; //$NON-NLS-1$
+ private static final String FOO = "Foo"; //$NON-NLS-1$
+
+ /**
+ * Initializes me.
+ */
+ public UMLCopyTestME() {
+ super();
+ }
+
+ @Test
+ public void copyingInterfaceRealizationDoesNotCorruptTheModel() {
+ Package pkg = editor.getModel().getNestedPackage(PKG);
+
+ Command cmd = CopyHandler.buildCopyCommand(editor.getEditingDomain(), Arrays.asList(pkg));
+ cmd.execute();
+
+ PapyrusClipboard<Object> papyrusClipboard = PapyrusClipboard.getInstance();
+ Package pkgCopy = (Package) papyrusClipboard.getCopyFromSource(pkg);
+
+ Interface fooCopy = (Interface) pkgCopy.getOwnedType(FOO);
+ Class barCopy = (Class) pkgCopy.getOwnedType(BAR);
+ InterfaceRealization rlzCopy = barCopy.getInterfaceRealization(null, fooCopy);
+
+ // Verify the copy
+ assertNotNull(rlzCopy);
+ assertThat(rlzCopy.getImplementingClassifier(), both(notNullValue()).and(is(barCopy)));
+ assertThat(rlzCopy.getContract(), both(notNullValue()).and(is(fooCopy)));
+
+ // Verify the non-corruption
+ assertThat(rlzCopy.getClients().size(), is(1));
+ }
+}

Back to the top