Skip to main content
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorptessier2014-04-01 15:28:51 +0000
committerptessier2014-04-01 15:28:51 +0000
commitaa8fe3c74d0e20ad56edab6678f4b41862c5216a (patch)
treea2b43ce94e22befcde98cc9803d64e5366a3e9b1 /tests
parent2753321f21e52fc143bda2b58b47b51586316b88 (diff)
downloadorg.eclipse.papyrus-aa8fe3c74d0e20ad56edab6678f4b41862c5216a.tar.gz
org.eclipse.papyrus-aa8fe3c74d0e20ad56edab6678f4b41862c5216a.tar.xz
org.eclipse.papyrus-aa8fe3c74d0e20ad56edab6678f4b41862c5216a.zip
431723: [Test] property of stereotypes must be tested with a Junit
https://bugs.eclipse.org/bugs/show_bug.cgi?id=431723
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/org.eclipse.papyrus.diagram.stereotypeproperty.tests.launch41
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java140
3 files changed, 147 insertions, 37 deletions
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF
index 8d1ccf97e11..52651ab4549 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF
@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.0.0",
org.eclipse.papyrus.infra.widgets;bundle-version="1.0.0",
org.eclipse.papyrus.uml.diagram.stereotype.edition;bundle-version="1.0.0",
- org.junit;bundle-version="4.10.0"
+ org.junit;bundle-version="4.10.0",
+ org.eclipse.papyrus.uml.appearance
Export-Package: org.eclipse.papyrus.diagram.stereotypeproperty
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/org.eclipse.papyrus.diagram.stereotypeproperty.tests.launch b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/org.eclipse.papyrus.diagram.stereotypeproperty.tests.launch
new file mode 100644
index 00000000000..26ddda66cda
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/org.eclipse.papyrus.diagram.stereotypeproperty.tests.launch
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
+<booleanAttribute key="append.args" value="true"/>
+<booleanAttribute key="askclear" value="false"/>
+<booleanAttribute key="automaticAdd" value="true"/>
+<booleanAttribute key="automaticValidate" value="false"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="true"/>
+<booleanAttribute key="clearws" value="true"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
+<booleanAttribute key="default" value="true"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/AllTests.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.papyrus.diagram.stereotypeproperty.AllTests"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.papyrus.diagram.stereotypeproperty.tests"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms1024m -Xmx4086m -XX:MaxPermSize=1024M"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.eclipse.platform.ide"/>
+<booleanAttribute key="run_in_ui_thread" value="true"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useCustomFeatures" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="false"/>
+<booleanAttribute key="useProduct" value="true"/>
+</launchConfiguration>
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 5189172d88e..0c3f999eef3 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
@@ -18,22 +18,36 @@ import java.util.ArrayList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
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.figures.BorderedNodeFigure;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.draw2d.ui.text.TextFlowEx;
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.ServiceUtils;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IShapeCompartmentEditPart;
+import org.eclipse.papyrus.uml.appearance.commands.AddAppliedStereotypePropertiesToDisplayCommand;
+import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
+import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
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.figure.node.ClassifierFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.EditingFlowPage;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeConpartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeMultilinePropertyEditPart;
import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile;
import org.eclipse.papyrus.uml.extensionpoints.utils.Util;
import org.eclipse.papyrus.uml.tools.commands.ApplyStereotypeCommand;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.Profile;
@@ -61,6 +75,23 @@ public class TestStereotypeApplication extends AbstractPapyrusTestCase {
*/
public void testToCreateANode(IElementType type) {
+ //VARIABLES
+ org.eclipse.uml2.uml.Class class1=null;
+ //stereotype that is applied on class1
+ Stereotype stereotypeTest=null;
+ //view of the class
+ View NotationClass1=null;
+ //editpart of class1
+ GraphicalEditPart classEditPart=null;
+ //compartment of stereotype
+ View appliedStereotypeCompartmentNotation = null;
+ //compartment Shape
+ View shapeCompartmentView=null;
+ //the view of the applied stereotype property
+ View stereotypePropertyView=null;
+ GraphicalEditPart stereotypeCompartmentEdipart=null;
+ GraphicalEditPart stereotypePropertyEdipart=null;
+
//CREATION
assertTrue(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 0);
@@ -69,45 +100,82 @@ public class TestStereotypeApplication extends AbstractPapyrusTestCase {
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>();
- stereotypeslist.add(element.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1));
-
- 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;
+ {//execution of the command
+ 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);
+ }
+
+ //get the created Class
+ class1 = (org.eclipse.uml2.uml.Class)((org.eclipse.uml2.uml.Package)getRootSemanticModel()).getPackagedElement("Class1");
+ assertNotNull("created class must be not null", class1 );
+ //look for the editpart that the class
+ classEditPart = (ClassEditPart)getDiagramEditPart().getChildren().get(0);
+ //test if stereotype can be applied
+ assertTrue("stereotype1 must be applicable on class1", class1.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1) != null);
+
+ {// execution of the application of the stereotype
+ ArrayList<Stereotype> stereotypeslist = new ArrayList<Stereotype>();
+ stereotypeslist.add(class1.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1));
+ ApplyStereotypeCommand applyStereotypeCommand = new ApplyStereotypeCommand(((Element)classEditPart.resolveSemanticElement()), stereotypeslist, diagramEditor.getEditingDomain());
+ diagramEditor.getEditingDomain().getCommandStack().execute(applyStereotypeCommand);
+ assertTrue("No applied stereotype found on the element ", class1.getAppliedStereotypes().size() != 0);
+ }
+
+ //look for the applied stereotype compartment
+ NotationClass1=classEditPart.getNotationView();
+
+ for(int i = 0; i < NotationClass1.getTransientChildren().size(); i++) {
+ View view = (View) NotationClass1.getTransientChildren().get(i);
+ if(view.getType().equals(AppliedStereotypeConpartmentEditPart.ID)) {
+ appliedStereotypeCompartmentNotation = view;
}
+ if(view.getType().equals(IShapeCompartmentEditPart.VIEW_TYPE)) {
+ shapeCompartmentView= view;
+ }
+ }
+ // the mechanism of stereotype display is running.
+ //the thread is synchronous
+ assertTrue( "No stereotype Compartment found in the notation", appliedStereotypeCompartmentNotation != null);
+ assertTrue( "No stereotype shape Compartment found in the notation", shapeCompartmentView != null);
+
+ //now display stereotypes
+ stereotypeTest=class1.getAppliedStereotypes().get(0);
+
+ {//display stereotype1
+ RecordingCommand displayStereotypeCommand= AppliedStereotypeHelper.getAppliedStereotypeToDisplayCommand(diagramEditor.getEditingDomain(), NotationClass1,stereotypeTest.getQualifiedName() , UMLVisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION);
+
+ diagramEditor.getEditingDomain().getCommandStack().execute(displayStereotypeCommand);
+ org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)classEditPart.getFigure()).getChildren().get(0);
+
+ //get the label
+ org.eclipse.draw2d.Label stereotypeLabel=((ClassifierFigure)nodePlate.getChildren().get(0)).getStereotypesLabel();
+ assertTrue( "stereotype label must be not null" ,stereotypeLabel!=null);
+ assertTrue( "text of stereotype label be equals to «stereotype1» " ,stereotypeLabel.getText().equals("«stereotype1»"));
+ }
+
+ {//test display of property of stereotype in compartment
+ RecordingCommand displayPropertyStereotypeCommand= AppliedStereotypeHelper.getAddAppliedStereotypePropertiesCommand(diagramEditor.getEditingDomain(), NotationClass1,stereotypeTest.getQualifiedName()+".testInt");
+ diagramEditor.getEditingDomain().getCommandStack().execute(displayPropertyStereotypeCommand);
+
+ //the compartment must be visible
+ assertTrue( "the compartment must be visible", appliedStereotypeCompartmentNotation.isVisible()==true);
+ //look for view that represents the property of the applied stereotype
+ stereotypePropertyView=(View)appliedStereotypeCompartmentNotation.getChildren().get(0);
+ assertNotNull( "the view of the applied stereotype property must be created", stereotypePropertyView);
+ //look for the editpart that represents the property of applied stereotype
+ stereotypeCompartmentEdipart=(GraphicalEditPart)classEditPart.getChildBySemanticHint(AppliedStereotypeConpartmentEditPart.ID);
+ stereotypePropertyEdipart=(GraphicalEditPart)stereotypeCompartmentEdipart.getChildBySemanticHint(AppliedStereotypeMultilinePropertyEditPart.ID);
+ assertNotNull( "the editpart of the applied stereotype compartment must be created", stereotypeCompartmentEdipart);
+ assertNotNull( "the editpart of the applied stereotype property must be created", stereotypePropertyEdipart);
+ EditingFlowPage textarea=(EditingFlowPage)stereotypePropertyEdipart.getFigure();
+ assertTrue( "text of stereotype label be equals to «stereotype1» " ,((TextFlowEx)textarea.getChildren().get(0)).getText().equals("testInt=0"));
}
- //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);
}
@Before

Back to the top