diff options
author | Francois Le Fevre - CEA | 2015-06-26 15:05:34 +0000 |
---|---|---|
committer | Patrick Tessier | 2015-07-03 08:10:18 +0000 |
commit | bebeaa8d022ca1687ba3378debc0eb1b75ece613 (patch) | |
tree | 758d8db27ee483842a18d2974d943c24a94c4323 | |
parent | 6379bc1cc60c6d7ece710255f2509abfd44bc60a (diff) | |
download | org.eclipse.papyrus-bebeaa8d022ca1687ba3378debc0eb1b75ece613.tar.gz org.eclipse.papyrus-bebeaa8d022ca1687ba3378debc0eb1b75ece613.tar.xz org.eclipse.papyrus-bebeaa8d022ca1687ba3378debc0eb1b75ece613.zip |
Bug 471140 - [Test]: create a junit test for covering unapplication of
profile for closed diagram to undisplay associated comment
Change-Id: I6ee86155fffbd9b55d044a55d65858504f937a6f
Signed-off-by: Francois Le Fevre - CEA <francois.le-fevre@cea.fr>
Reviewed-on: https://git.eclipse.org/r/50960
Tested-by: Hudson CI
Reviewed-by: Patrick Tessier <Patrick.Tessier@cea.fr>
5 files changed, 159 insertions, 27 deletions
diff --git a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.appliedstereotypecommend.recipetest/resources/deletion/UnapplyProfileDiagramClosed.di b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/resource/UnapplyProfileDiagramClosed.di index 0bda9d9838d..dae5e022900 100644 --- a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.appliedstereotypecommend.recipetest/resources/deletion/UnapplyProfileDiagramClosed.di +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/resource/UnapplyProfileDiagramClosed.di @@ -1,13 +1,13 @@ -<?xml version="1.0" encoding="ASCII"?>
-<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi">
- <pageList>
- <availablePage>
- <emfPageIdentifier href="UnapplyProfileDiagramClosed.notation#_9fRS0BwfEeKYb8ts8yUAsw"/>
- </availablePage>
- </pageList>
- <sashModel currentSelection="//@sashModel/@windows.0/@children.0">
- <windows>
- <children xsi:type="di:TabFolder"/>
- </windows>
- </sashModel>
-</di:SashWindowsMngr>
+<?xml version="1.0" encoding="UTF-8"?> +<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi"> + <pageList> + <availablePage> + <emfPageIdentifier href="UnapplyProfileDiagramClosed.notation#_9fRS0BwfEeKYb8ts8yUAsw"/> + </availablePage> + </pageList> + <sashModel currentSelection="//@sashModel/@windows.0/@children.0"> + <windows> + <children xsi:type="di:TabFolder"/> + </windows> + </sashModel> +</di:SashWindowsMngr> diff --git a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.appliedstereotypecommend.recipetest/resources/deletion/UnapplyProfileDiagramClosed.notation b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/resource/UnapplyProfileDiagramClosed.notation index 91d64548ca2..91d64548ca2 100644 --- a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.appliedstereotypecommend.recipetest/resources/deletion/UnapplyProfileDiagramClosed.notation +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/resource/UnapplyProfileDiagramClosed.notation diff --git a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.appliedstereotypecommend.recipetest/resources/deletion/UnapplyProfileDiagramClosed.uml b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/resource/UnapplyProfileDiagramClosed.uml index 82d128822e3..a404dfa6ef9 100644 --- a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.appliedstereotypecommend.recipetest/resources/deletion/UnapplyProfileDiagramClosed.uml +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/resource/UnapplyProfileDiagramClosed.uml @@ -1,5 +1,5 @@ <?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:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http:///schemas/testProfile/_dg9pAM0tEeKjW9KkdY00_w/4" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http:///schemas/testProfile/_dg9pAM0tEeKjW9KkdY00_w/4 pathmap://Test_PROFILES/testProfile.profile.uml#_dqAQQM0tEeKjW9KkdY00_w"> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http:///schemas/testProfile/_dg9pAM0tEeKjW9KkdY00_w/4" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http:///schemas/testProfile/_dg9pAM0tEeKjW9KkdY00_w/4 testProfile.profile.uml#_dqAQQM0tEeKjW9KkdY00_w"> <uml:Model xmi:id="_6wmGEBwfEeKYb8ts8yUAsw" name="model"> <ownedComment xmi:type="uml:Comment" xmi:id="_Mfd7kBwgEeKYb8ts8yUAsw"> <body>Unapply Profile. The comments have to disappear.</body> @@ -7,18 +7,11 @@ <packagedElement xmi:type="uml:Class" xmi:id="_BPjGgBwgEeKYb8ts8yUAsw" name="StereotypedClass"/> <packagedElement xmi:type="uml:Class" xmi:id="_EmOucBwgEeKYb8ts8yUAsw" name="Class1"/> <packagedElement xmi:type="uml:Dependency" xmi:id="_FcrOQBwgEeKYb8ts8yUAsw" name="StereotypedLink" client="_EmOucBwgEeKYb8ts8yUAsw" supplier="_BPjGgBwgEeKYb8ts8yUAsw"/> - <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_ARp64BwgEeKYb8ts8yUAsw"> - <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_34070PiYEeSxko_tWvdMlw" source="PapyrusVersion"> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_34070fiYEeSxko_tWvdMlw" key="Version" value="0.0.5"/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_34070viYEeSxko_tWvdMlw" key="Comment" value="update profile for multi evaluation"/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_34070_iYEeSxko_tWvdMlw" key="Copyright" value="CEA LIST"/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_34071PiYEeSxko_tWvdMlw" key="Date" value="2013-06-04"/> - <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_34071fiYEeSxko_tWvdMlw" key="Author" value="P. Tessier"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_lcxrMBwOEeWCXpPpR63ucQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_lcySQBwOEeWCXpPpR63ucQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="testProfile.profile.uml#_dqAQQM0tEeKjW9KkdY00_w"/> </eAnnotations> - <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_AR810BwgEeKYb8ts8yUAsw" source="http://www.eclipse.org/uml2/2.0.0/UML"> - <references xmi:type="ecore:EPackage" href="pathmap://Test_PROFILES/testProfile.profile.uml#_dqAQQM0tEeKjW9KkdY00_w"/> - </eAnnotations> - <appliedProfile xmi:type="uml:Profile" href="pathmap://Test_PROFILES/testProfile.profile.uml#_UVrRoGkdEeGGJOTenKBKAg"/> + <appliedProfile xmi:type="uml:Profile" href="testProfile.profile.uml#_UVrRoGkdEeGGJOTenKBKAg"/> </profileApplication> </uml:Model> <testProfile:Stereotype1 xmi:id="_J8_-0BwgEeKYb8ts8yUAsw" base_Element="_BPjGgBwgEeKYb8ts8yUAsw"/> diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/uml/diagram/stereotypeproperty/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/uml/diagram/stereotypeproperty/AllTests.java index 85ca237d1af..87caa861400 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/uml/diagram/stereotypeproperty/AllTests.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/uml/diagram/stereotypeproperty/AllTests.java @@ -25,8 +25,8 @@ import org.junit.runners.Suite.SuiteClasses; // canonical
TestProfileApplication.class,
TestStereotypeApplication.class,
-TestLayoutWithStereotype.class
-
+TestLayoutWithStereotype.class,
+TestUnapplyProfile2ClosedDiagComment.class
})
public class AllTests {
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/uml/diagram/stereotypeproperty/TestUnapplyProfile2ClosedDiagComment.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/uml/diagram/stereotypeproperty/TestUnapplyProfile2ClosedDiagComment.java new file mode 100644 index 00000000000..2923e746ec1 --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/uml/diagram/stereotypeproperty/TestUnapplyProfile2ClosedDiagComment.java @@ -0,0 +1,139 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * CEA LIST - Initial API and implementation + * Francois Le Fevre - francois.le-fevre@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.stereotypeproperty; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.EditPart; +import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; +import org.eclipse.papyrus.junit.framework.classification.InvalidTest; +import org.eclipse.papyrus.junit.utils.rules.ActiveDiagram; +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.uml.diagram.stereotype.edition.editpart.AppliedStereotypeEmptyEditPart; +import org.eclipse.papyrus.uml.tools.commands.UnapplyProfileCommand; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Profile; +import org.junit.Rule; +import org.junit.Test; + +/** + * Unapply Profile. The comments have to disappear. + * + */ +@PluginResource({TestUnapplyProfile2ClosedDiagComment.MODEL_DI }) +public class TestUnapplyProfile2ClosedDiagComment extends AbstractPapyrusTestCase { + + final static String MODEL_DI = "resource/UnapplyProfileDiagramClosed.di"; //$NON-NLS-1$ + + final static String STEREOTYPEDCLASS = "StereotypedClass"; //$NON-NLS-1$ + final static String CLASS1 = "Class1"; //$NON-NLS-1$ + final static String STEREOTYPEDLINK = "StereotypedLink"; //$NON-NLS-1$ + + final static String PROFILE = "testProfile"; //$NON-NLS-1$ + + //@Rule + //public final ModelSetFixture fixture = new ModelSetFixture(); + + //FIXME may I have multiple rules + @Rule + public final PapyrusEditorFixture fixture = new PapyrusEditorFixture(); + + @Test + @InvalidTest + public void testUnApplyStereotypeApplication() { + + fixture.openDiagram("ClassDiagram"); + + //Check initial model + NamedElement stereotypedClass = fixture.getModel().getOwnedMember(STEREOTYPEDCLASS); + assertNotNull("stereotypedClass is null", stereotypedClass); + + NamedElement stereotypedLink = fixture.getModel().getOwnedMember(STEREOTYPEDLINK); + assertNotNull("stereotypedLink is null", stereotypedLink); + + //Check initial model + EditPart stereotypedClassEditPart = fixture.findEditPart(stereotypedClass); + for(Object o : stereotypedClassEditPart.getChildren()){ + if(o instanceof AppliedStereotypeEmptyEditPart){ + assertTrue(STEREOTYPEDCLASS+" do not refer to any AppliedStereotypeEmptyEditPart comment", true); //$NON-NLS-1$ + } + } + //List of EditPart + //ClassNameEditPart + //ClassAttributeCompartmentEditPart + //ClassOperationCompartmentEditPart + //ClassNestedclassifierCompartemtnEditPart + //ClassFloatingNameEditPart + //AppliedStereotypeEmptyEditPart + assertEquals(STEREOTYPEDCLASS + " has not the right number of children", 6, stereotypedClassEditPart.getChildren().size()); //$NON-NLS-1$ + + EditPart stereotypedLinkEditPart = fixture.findEditPart(stereotypedLink); + for(Object o : stereotypedLinkEditPart.getChildren()){ + if(o instanceof AppliedStereotypeEmptyEditPart){ + assertTrue(STEREOTYPEDLINK+" do not refer to any AppliedStereotypeEmptyEditPart comment", true); //$NON-NLS-1$ + } + } + //List of EditPart + //DependencyNameEditPart + //AppliedStereotypeDependencyEditPart + //AppliedStereotypeEmptyEditPart + assertEquals(STEREOTYPEDLINK + " has not the right number of children", 3, stereotypedLinkEditPart.getChildren().size()); //$NON-NLS-1$ + + fixture.closeDiagram("ClassDiagram"); + + //Remove the stereotypes + TransactionalEditingDomain domain = fixture.getEditingDomain(); + EList<Profile> profiles= fixture.getModel().getAllAppliedProfiles(); + for(Profile profile : profiles){ + if(PROFILE.equals(profile.getName())){ + fixture.execute(new UnapplyProfileCommand(fixture.getModel(), profile, domain)); + } + } + + fixture.openDiagram("ClassDiagram"); + //check the final model + //List of EditPart + //ClassNameEditPart + //ClassAttributeCompartmentEditPart + //ClassOperationCompartmentEditPart + //ClassNestedclassifierCompartemtnEditPart + //ClassFloatingNameEditPart + //AppliedStereotypeEmptyEditPart --> should be removed + assertEquals(STEREOTYPEDCLASS + " has not the right number of children", 5, stereotypedClassEditPart.getChildren().size()); //$NON-NLS-1$ + for(Object ee : stereotypedClassEditPart.getChildren()){ + EditPart a = (EditPart)ee; + if(a instanceof AppliedStereotypeEmptyEditPart){ + assertTrue(STEREOTYPEDCLASS+" still refer to a AppliedStereotypeEmptyEditPart comment", false); //$NON-NLS-1$ + } + } + //List of EditPart + //DependencyNameEditPart + //AppliedStereotypeDependencyEditPart + //AppliedStereotypeEmptyEditPart --> should be removed + assertEquals(STEREOTYPEDLINK + " has not the right number of children", 2, stereotypedLinkEditPart.getChildren().size()); //$NON-NLS-1$ + for(Object ee : stereotypedLinkEditPart.getChildren()){ + EditPart a = (EditPart)ee; + if(a instanceof AppliedStereotypeEmptyEditPart){ + assertTrue(STEREOTYPEDLINK+" still refer to a AppliedStereotypeEmptyEditPart comment", false); //$NON-NLS-1$ + } + } + } +} |