diff options
author | Benoit Maggi | 2014-12-15 09:55:14 +0000 |
---|---|---|
committer | Benoit Maggi | 2014-12-15 09:55:14 +0000 |
commit | 413e78428162600eb5685248ab5ba7eb1f1dafc4 (patch) | |
tree | 69a63af1f806f019d007551f277b64533bb55a03 | |
parent | d8749d6135abd54e1a9d7d1dddbe455854d56417 (diff) | |
download | org.eclipse.papyrus-413e78428162600eb5685248ab5ba7eb1f1dafc4.tar.gz org.eclipse.papyrus-413e78428162600eb5685248ab5ba7eb1f1dafc4.tar.xz org.eclipse.papyrus-413e78428162600eb5685248ab5ba7eb1f1dafc4.zip |
Bug 438511 - Copy/paste should copy property values for applied
stereotype
- add a test for the model explorer use case
Change-Id: Iaa1415a6bcd6d31b0d424bde2a547404491ef9c4
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
5 files changed, 200 insertions, 1 deletions
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/modelWithStereotype.di b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/modelWithStereotype.di new file mode 100644 index 00000000000..bf9abab340f --- /dev/null +++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/modelWithStereotype.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/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/modelWithStereotype.notation b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/modelWithStereotype.notation new file mode 100644 index 00000000000..ded42180fb6 --- /dev/null +++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/modelWithStereotype.notation @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:css="http://www.eclipse.org/papyrus/infra/gmfdiag/css" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <notation:Diagram xmi:id="_CcJ10AHyEeSRtoqJfclOXQ" type="PapyrusUMLClassDiagram" name="NewDiagram" measurementUnit="Pixel"> + <children xmi:type="notation:Shape" xmi:id="_C07iMAHyEeSRtoqJfclOXQ" type="2008"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_HcNPUAHyEeSRtoqJfclOXQ" source="Stereotype_Annotation"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_HxUqEAH6EeSdD4OLwBjBKA" key="StereotypeWithQualifiedNameList" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_HxUqEQH6EeSdD4OLwBjBKA" key="StereotypeList" value="SysML::Requirements::Requirement"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_HxUqEgH6EeSdD4OLwBjBKA" key="PropStereoDisplay" value="SysML::Requirements::Requirement.text,SysML::Requirements::Requirement.id"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_HxVRIAH6EeSdD4OLwBjBKA" key="Stereotype_Presentation_Kind" value="HorizontalStereo"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_HxVRIQH6EeSdD4OLwBjBKA" key="StereotypePropertyLocation" value="Compartment"/> + </eAnnotations> + <children xmi:type="notation:DecorationNode" xmi:id="_C08JQAHyEeSRtoqJfclOXQ" type="5029"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_C08JQQHyEeSRtoqJfclOXQ" type="7017"> + <styles xmi:type="notation:TitleStyle" xmi:id="_C08JQgHyEeSRtoqJfclOXQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_C08JQwHyEeSRtoqJfclOXQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_C08JRAHyEeSRtoqJfclOXQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_C08JRQHyEeSRtoqJfclOXQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_C08JRgHyEeSRtoqJfclOXQ" type="7018"> + <styles xmi:type="notation:TitleStyle" xmi:id="_C08JRwHyEeSRtoqJfclOXQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_C08JSAHyEeSRtoqJfclOXQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_C08JSQHyEeSRtoqJfclOXQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_C08JSgHyEeSRtoqJfclOXQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_C08JSwHyEeSRtoqJfclOXQ" type="7019"> + <styles xmi:type="notation:TitleStyle" xmi:id="_C08JTAHyEeSRtoqJfclOXQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_C08JTQHyEeSRtoqJfclOXQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_C08JTgHyEeSRtoqJfclOXQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_C08JTwHyEeSRtoqJfclOXQ"/> + </children> + <element xmi:type="uml:Class" href="modelWithStereotype.uml#_C067IAHyEeSRtoqJfclOXQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_C07iMQHyEeSRtoqJfclOXQ" x="294" y="51"/> + </children> + <styles xmi:type="notation:StringValueStyle" xmi:id="_CcJ10QHyEeSRtoqJfclOXQ" name="diagram_compatibility_version" stringValue="1.0.0"/> + <styles xmi:type="notation:DiagramStyle" xmi:id="_CcJ10gHyEeSRtoqJfclOXQ"/> + <styles xmi:type="style:PapyrusViewStyle" xmi:id="_CcJ10wHyEeSRtoqJfclOXQ"> + <owner xmi:type="uml:Model" href="modelWithStereotype.uml#_CcJOwAHyEeSRtoqJfclOXQ"/> + </styles> + <element xmi:type="uml:Model" href="modelWithStereotype.uml#_CcJOwAHyEeSRtoqJfclOXQ"/> + </notation:Diagram> + <css:ModelStyleSheets xmi:id="_H5cEQAH6EeSdD4OLwBjBKA"/> +</xmi:XMI> diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/modelWithStereotype.uml b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/modelWithStereotype.uml new file mode 100644 index 00000000000..6a03393ba70 --- /dev/null +++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/modelWithStereotype.uml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Requirements="http://www.eclipse.org/papyrus/0.7.0/SysML/Requirements" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/0.7.0/SysML/Requirements http://www.eclipse.org/papyrus/0.7.0/SysML#//requirements"> + <uml:Model xmi:id="_CcJOwAHyEeSRtoqJfclOXQ" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_C067IAHyEeSRtoqJfclOXQ" name="Class1"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_QHe5MAH5EeSdD4OLwBjBKA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_QICS0AH5EeSdD4OLwBjBKA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//requirements"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_OOJC4LX8EduFmqQsrNB9lw"/> + </profileApplication> + </uml:Model> + <Requirements:Requirement xmi:id="_Qz1o4AH5EeSdD4OLwBjBKA" text="description" id="1" base_Class="_C067IAHyEeSRtoqJfclOXQ"/> +</xmi:XMI> diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java index 3193cc874fa..9f0de804068 100644 --- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java +++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java @@ -22,6 +22,7 @@ package org.eclipse.papyrus.uml.modelexplorer.tests; import org.eclipse.papyrus.uml.modelexplorer.tests.paste.CopyPasteModelExplorerTest; import org.eclipse.papyrus.uml.modelexplorer.tests.paste.CutPasteModelExplorerTest; import org.eclipse.papyrus.uml.modelexplorer.tests.paste.DiagramCopyPasteModelExplorerTest; +import org.eclipse.papyrus.uml.modelexplorer.tests.paste.StereotypeCopyPasteModelExplorerTest; import org.eclipse.papyrus.uml.modelexplorer.tests.paste.TableCopyPasteModelExplorerTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -30,7 +31,7 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({ // DeleteModelExplorerTest.class, RenameHandlerTest.class, ModelExplorerViewTests.class, CutPasteModelExplorerTest.class, CopyPasteModelExplorerTest.class, // -DiagramCopyPasteModelExplorerTest.class, TableCopyPasteModelExplorerTest.class, // +DiagramCopyPasteModelExplorerTest.class, TableCopyPasteModelExplorerTest.class, StereotypeCopyPasteModelExplorerTest.class, // AdvancedModeTest.class }) public class AllTests { // JUnit for test suite diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/StereotypeCopyPasteModelExplorerTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/StereotypeCopyPasteModelExplorerTest.java new file mode 100644 index 00000000000..d6ca19c8f1c --- /dev/null +++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/StereotypeCopyPasteModelExplorerTest.java @@ -0,0 +1,141 @@ +/***************************************************************************** + * Copyright (c) 2014 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: + * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.modelexplorer.tests.paste; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.junit.utils.HandlerUtils; +import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest; +import org.eclipse.papyrus.uml.modelexplorer.tests.Activator; +import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; +import org.eclipse.ui.ISelectionService; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.Stereotype; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Sample test for cut in model explorer + * + * @author bmaggi + */ +public class StereotypeCopyPasteModelExplorerTest extends AbstractEditorTest { + + public static final String COPY_COMMAND_ID = "org.eclipse.ui.edit.copy"; //$NON-NLS-1$ + + public static final String PASTE_COMMAND_ID = "org.eclipse.ui.edit.paste"; //$NON-NLS-1$ + + public static final String RESOURCES_PATH = "resources/"; //$NON-NLS-1$ + + public static final String MODEL_NAME = "modelWithStereotype"; //$NON-NLS-1$ + + public static final String PROJECT_NAME = "modelWithStereotype"; //$NON-NLS-1$ + + public final static String CLASS1_NAME = "Class1"; //$NON-NLS-1$ + + // information on the stereotype + public final static String REQUIREMENT = "SysML::Requirements::Requirement"; //$NON-NLS-1$ + + public final static String REQUIREMENT_TEXT = "text"; //$NON-NLS-1$ + + public final static String REQUIREMENT_TEXT_VALUE = "description"; //$NON-NLS-1$ + + public final static String REQUIREMENT_ID = "id"; //$NON-NLS-1$ + + public final static String REQUIREMENT_ID_VALUE = "1"; //$NON-NLS-1$ + + + + @Before + public void initModelForCopyPasteTest() { + try { + initModel(PROJECT_NAME, MODEL_NAME, Activator.getDefault().getBundle()); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (Exception e) { + Assert.fail(e.getMessage()); + } + } + + @Override + protected String getSourcePath() { + return RESOURCES_PATH; + } + + + + + /** + * Simple copy paste of a class1 with <<requirememt>> stereotype + * + * @throws Exception + */ + @Test + public void copyPasteofClass1Test() throws Exception { + //get the rootModel + Assert.assertNotNull("RootModel is null", getRootUMLModel()); //$NON-NLS-1$ + //get all semantic element that will handled + Model model = (Model)getRootUMLModel(); + + IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + ISelectionService selectionService = activeWorkbenchWindow.getSelectionService(); + modelExplorerView = getModelExplorerView(); + modelExplorerView.setFocus(); + List<Object> elements = new ArrayList<Object>(); + elements.add(getRootUMLModel()); + modelExplorerView.revealSemanticElement(elements); + + org.eclipse.uml2.uml.Class class1 = (org.eclipse.uml2.uml.Class)model.getPackagedElement(CLASS1_NAME); + + elements.clear(); + elements.add(class1); + modelExplorerView.revealSemanticElement(elements); + Object class1TreeObject = ((IStructuredSelection)selectionService.getSelection()).getFirstElement(); + Assert.assertNotNull("Class1 TreeElement is null", class1TreeObject); //$NON-NLS-1$ + + IHandler copyHandler = HandlerUtils.getActiveHandlerFor(COPY_COMMAND_ID); + Assert.assertTrue("Copy not available", copyHandler.isEnabled()); //$NON-NLS-1$ + copyHandler.execute(new ExecutionEvent()); + + // select root + + elements.clear(); + elements.add(getRootUMLModel()); + modelExplorerView.revealSemanticElement(elements); + + // paste + IHandler pasteHandler = HandlerUtils.getActiveHandlerFor(PASTE_COMMAND_ID); + Assert.assertTrue("Paste not available", pasteHandler.isEnabled()); //$NON-NLS-1$ + pasteHandler.execute(new ExecutionEvent()); + + // check that there is a Class1 + org.eclipse.uml2.uml.Class copyOfClass1 = (org.eclipse.uml2.uml.Class)model.getPackagedElement(NamedElementUtil.COPY_OF + "_" + CLASS1_NAME + "_1"); + Assert.assertNotNull("The copy is missing", copyOfClass1); //$NON-NLS-1$ + + Stereotype stereotype = copyOfClass1.getAppliedStereotype(REQUIREMENT); + EObject stereotypeApplication = copyOfClass1.getStereotypeApplication(stereotype); + Assert.assertEquals("Wrong copied id", stereotypeApplication.eGet(stereotypeApplication.eClass().getEStructuralFeature(REQUIREMENT_ID)), REQUIREMENT_ID_VALUE); + Assert.assertEquals("Wrong copied text", stereotypeApplication.eGet(stereotypeApplication.eClass().getEStructuralFeature(REQUIREMENT_TEXT)), REQUIREMENT_TEXT_VALUE); + + } + + + +} |