Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-09-19 07:59:18 +0000
committercletavernie2012-09-19 07:59:18 +0000
commit5deb96c512f611bd667f133b18b0dc9c2598f550 (patch)
tree8cace531771aef84af71100f62b54def77348aec
parent7c71eb917aaae478ad8a7c8ca4dfdf3f9a503b0a (diff)
downloadorg.eclipse.papyrus-5deb96c512f611bd667f133b18b0dc9c2598f550.tar.gz
org.eclipse.papyrus-5deb96c512f611bd667f133b18b0dc9c2598f550.tar.xz
org.eclipse.papyrus-5deb96c512f611bd667f133b18b0dc9c2598f550.zip
389865: [Profiles] Invalid implementation of the profile/stereotype application commands
https://bugs.eclipse.org/bugs/show_bug.cgi?id=389865 Update the tests
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java108
1 files changed, 52 insertions, 56 deletions
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java
index 02292db62b9..17e3ff3bf91 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java
@@ -14,7 +14,6 @@
package org.eclipse.papyrus.diagram.stereotypeproperty;
import java.util.ArrayList;
-import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
@@ -22,20 +21,16 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.common.editparts.AppliedStereotypeConpartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editparts.AppliedStereotypeMultilinePropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.common.service.ApplyStereotypeRequest;
import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile;
import org.eclipse.papyrus.uml.extensionpoints.utils.Util;
import org.eclipse.papyrus.uml.tools.commands.ApplyStereotypeCommand;
@@ -48,86 +43,87 @@ import org.junit.Test;
public class TestStereotypeApplication extends AbstractPapyrusTestCase {
-
+
private static final String TEST_PROFILE_STEREOTYPE1 = "testProfile::Stereotype1";
@Test
public void testToManageModel() {
testToCreateANode(UMLElementTypes.Class_2008);
-
+
}
-
+
/**
* Test to create a node.
*
- * @param type the type
+ * @param type
+ * the type
*/
public void testToCreateANode(IElementType type) {
//CREATION
- assertTrue(CREATION +INITIALIZATION_TEST,getDiagramEditPart().getChildren().size()==0);
-
- assertTrue(CREATION +INITIALIZATION_TEST,getRootSemanticModel().getOwnedElements().size()==1);
+ assertTrue(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 0);
+
+ assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
//1 element element due to the reference to the profile
- EList<Profile> list=((Model)getRootSemanticModel()).getAllAppliedProfiles();
- assertTrue(CREATION +INITIALIZATION_TEST, ((Model)getRootSemanticModel()).getAllAppliedProfiles().size()==1);
-
- CreateViewRequest requestcreation=CreateViewRequestFactory.getCreateShapeRequest(type, getDiagramEditPart().getDiagramPreferencesHint());
- Command command=getDiagramEditPart().getCommand(requestcreation);
- assertNotNull(CREATION+COMMAND_NULL,command);
- assertTrue(CREATION+TEST_IF_THE_COMMAND_IS_CREATED,command!=UnexecutableCommand.INSTANCE);
- assertTrue("CREATION: "+TEST_IF_THE_COMMAND_CAN_BE_EXECUTED,command.canExecute()==true);
+ EList<Profile> list = ((Model)getRootSemanticModel()).getAllAppliedProfiles();
+ assertTrue(CREATION + INITIALIZATION_TEST, ((Model)getRootSemanticModel()).getAllAppliedProfiles().size() == 1);
+
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getDiagramEditPart().getDiagramPreferencesHint());
+ Command command = getDiagramEditPart().getCommand(requestcreation);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue("CREATION: " + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
- assertTrue(CREATION+TEST_THE_EXECUTION,getRootView().getChildren().size()==1);
- Element element=getRootSemanticModel().getOwnedElements().get(1);
- GraphicalEditPart classEditPart=(ClassEditPart)getDiagramEditPart().getChildren().get(0);
- assertTrue(CREATION+TEST_THE_EXECUTION,element.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1)!=null);
- ArrayList<Stereotype> stereotypeslist= new ArrayList<Stereotype>();
+ assertTrue(CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 1);
+ Element element = getRootSemanticModel().getOwnedElements().get(1);
+ GraphicalEditPart classEditPart = (ClassEditPart)getDiagramEditPart().getChildren().get(0);
+ assertTrue(CREATION + TEST_THE_EXECUTION, element.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1) != null);
+ ArrayList<Stereotype> stereotypeslist = new ArrayList<Stereotype>();
stereotypeslist.add(element.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1));
-
-
-
- ApplyStereotypeCommand applyStereotypeCommand= new ApplyStereotypeCommand(((Element)classEditPart.resolveSemanticElement()),stereotypeslist );
+
+
+
+ ApplyStereotypeCommand applyStereotypeCommand = new ApplyStereotypeCommand(((Element)classEditPart.resolveSemanticElement()), stereotypeslist, diagramEditor.getEditingDomain());
diagramEditor.getEditingDomain().getCommandStack().execute(applyStereotypeCommand);
//diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy(new EMFtoGMFCommandWrapper(applyStereotypeCommand)));
- Element semanticElement=(Element) classEditPart.resolveSemanticElement();
- assertTrue(CREATION+TEST_THE_EXECUTION+ "No applied stereotype found on the element ",semanticElement.getAppliedStereotypes().size()!=0);
-
- View appliedStereotypeMultilinePropertyView=null;
- for(int i=0; i<classEditPart.getNotationView().getChildren().size();i++){
- View view= ((View)classEditPart.getNotationView().getChildren().get(i));
- if (view.getType().equals(AppliedStereotypeConpartmentEditPart.ID)){
- appliedStereotypeMultilinePropertyView=view;
-
+ Element semanticElement = (Element)classEditPart.resolveSemanticElement();
+ assertTrue(CREATION + TEST_THE_EXECUTION + "No applied stereotype found on the element ", semanticElement.getAppliedStereotypes().size() != 0);
+
+ View appliedStereotypeMultilinePropertyView = null;
+ for(int i = 0; i < classEditPart.getNotationView().getChildren().size(); i++) {
+ View view = ((View)classEditPart.getNotationView().getChildren().get(i));
+ if(view.getType().equals(AppliedStereotypeConpartmentEditPart.ID)) {
+ appliedStereotypeMultilinePropertyView = view;
+
}
}
//the thread is asynchronous
- assertTrue(CREATION+TEST_THE_EXECUTION +"No stereotype Compartment found in the notation",appliedStereotypeMultilinePropertyView==null);
-
-// AppliedStereotypeMultilinePropertyEditPart appliedStereotypeMultilinePropertyEditPart=null;
-// for(int i=0; i<classEditPart.getChildren().size();i++){
-// GraphicalEditPart editPart= ((GraphicalEditPart)classEditPart.getChildren().get(i));
-// if (editPart.getNotationView().getType().equals(AppliedStereotypeMultilinePropertyEditPart.ID)){
-// appliedStereotypeMultilinePropertyEditPart=(AppliedStereotypeMultilinePropertyEditPart)editPart;
-//
-// }
-// }
-// assertTrue(CREATION+TEST_THE_EXECUTION,appliedStereotypeMultilinePropertyEditPart!=null);
+ assertTrue(CREATION + TEST_THE_EXECUTION + "No stereotype Compartment found in the notation", appliedStereotypeMultilinePropertyView == null);
+
+ // AppliedStereotypeMultilinePropertyEditPart appliedStereotypeMultilinePropertyEditPart=null;
+ // for(int i=0; i<classEditPart.getChildren().size();i++){
+ // GraphicalEditPart editPart= ((GraphicalEditPart)classEditPart.getChildren().get(i));
+ // if (editPart.getNotationView().getType().equals(AppliedStereotypeMultilinePropertyEditPart.ID)){
+ // appliedStereotypeMultilinePropertyEditPart=(AppliedStereotypeMultilinePropertyEditPart)editPart;
+ //
+ // }
+ // }
+ // assertTrue(CREATION+TEST_THE_EXECUTION,appliedStereotypeMultilinePropertyEditPart!=null);
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
- RegisteredProfile registeredProfile=RegisteredProfile.getRegisteredProfile("TestProfile");
- final Model root=((Model)getDiagramEditPart().resolveSemanticElement());
+ RegisteredProfile registeredProfile = RegisteredProfile.getRegisteredProfile("TestProfile");
+ final Model root = ((Model)getDiagramEditPart().resolveSemanticElement());
URI modelUri = registeredProfile.uri;
final Resource modelResource = Util.getResourceSet(root).getResource(modelUri, true);
- final Profile profile=(Profile) modelResource.getContents().get(0);
+ final Profile profile = (Profile)modelResource.getContents().get(0);
// PackageUtil.applyProfile(root,profile, false);
- final TransactionalEditingDomain domain=EditorUtils.getTransactionalEditingDomain();
- AppliedProfileCommand appliedProfileCommand= new AppliedProfileCommand(domain, root, profile);
+ final TransactionalEditingDomain domain = EditorUtils.getTransactionalEditingDomain();
+ AppliedProfileCommand appliedProfileCommand = new AppliedProfileCommand(domain, root, profile);
domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(appliedProfileCommand));
-
+
}
}

Back to the top