diff options
author | Ansgar Radermacher | 2019-01-16 12:34:10 +0000 |
---|---|---|
committer | vincent lorenzo | 2019-01-27 10:06:46 +0000 |
commit | 17cb516fffb57b2968860900469d4987f5936500 (patch) | |
tree | f5d85fb5f96fd476a3cd02c92a834b210ec9f78f /tests/junit/plugins | |
parent | 84f851475dbcae5030c99bd3c762157551c37d62 (diff) | |
download | org.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
Diffstat (limited to 'tests/junit/plugins')
6 files changed, 186 insertions, 9 deletions
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)); + } +} |