Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoratischenko2014-07-19 15:18:22 +0000
committerAnatoliy Tischenko2014-07-21 16:47:34 +0000
commit8e8e946fc91e77bac899a8cccd4aae717e609ee8 (patch)
tree6234edc50ebc72ce38f4dd8f971ca3eb42b4a98e /tests
parent7afbb8822952bcbf955fed6e138a64470cc930a7 (diff)
downloadorg.eclipse.papyrus-8e8e946fc91e77bac899a8cccd4aae717e609ee8.tar.gz
org.eclipse.papyrus-8e8e946fc91e77bac899a8cccd4aae717e609ee8.tar.xz
org.eclipse.papyrus-8e8e946fc91e77bac899a8cccd4aae717e609ee8.zip
[425853] Cannot create input/output expansion nodes in borders of
Expansion Regions Signed-off-by: atischenko <ticher777@gmail.com> Change-Id: I42d344fdfed5a4f23ae1f32118e449c24fb23fdd
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/META-INF/MANIFEST.MF4
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/content/UMLActivityTestModel.uml6
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/AllTests.java4
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/edit/helper/ExpansionRegionHelperTest.java126
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/edit/part/ExpansionRegionCompartmentEPTest.java110
5 files changed, 249 insertions, 1 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/META-INF/MANIFEST.MF
index cbda3200461..f95c35a2132 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/META-INF/MANIFEST.MF
@@ -14,7 +14,9 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.0.0",
org.junit;bundle-version="4.10.0",
org.eclipse.papyrus.junit.utils;bundle-version="1.0.0",
- org.eclipse.gmf.tooling.runtime
+ org.eclipse.gmf.tooling.runtime,
+ org.eclipse.papyrus.uml.service.types,
+ org.eclipse.uml2.uml.editor
Export-Package: org.eclipse.papyrus.uml.diagram.activity.tests
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/content/UMLActivityTestModel.uml b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/content/UMLActivityTestModel.uml
new file mode 100644
index 00000000000..f45714db6fe
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/content/UMLActivityTestModel.uml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model 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="_GcwzAA7AEeSzbqt4C6pm3Q">
+ <packagedElement xmi:type="uml:Activity" xmi:id="_JoZBgA7AEeSzbqt4C6pm3Q" node="_M_2FgA7AEeSzbqt4C6pm3Q">
+ <node xmi:type="uml:ExpansionRegion" xmi:id="_M_2FgA7AEeSzbqt4C6pm3Q"/>
+ </packagedElement>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/AllTests.java
index ef14d9dea23..6609b4300c6 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/AllTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/AllTests.java
@@ -14,6 +14,8 @@
package org.eclipse.papyrus.uml.diagram.activity.tests;
import org.eclipse.papyrus.uml.diagram.activity.tests.canonical.AllCanonicalTests;
+import org.eclipse.papyrus.uml.diagram.activity.tests.edit.helper.ExpansionRegionHelperTest;
+import org.eclipse.papyrus.uml.diagram.activity.tests.edit.part.ExpansionRegionCompartmentEPTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@@ -25,6 +27,8 @@ import org.junit.runners.Suite.SuiteClasses;
@SuiteClasses({
// canonical
AllCanonicalTests.class,
+ExpansionRegionHelperTest.class,
+ExpansionRegionCompartmentEPTest.class
})
public class AllTests {
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/edit/helper/ExpansionRegionHelperTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/edit/helper/ExpansionRegionHelperTest.java
new file mode 100644
index 00000000000..0439bfbe6ff
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/edit/helper/ExpansionRegionHelperTest.java
@@ -0,0 +1,126 @@
+package org.eclipse.papyrus.uml.diagram.activity.tests.edit.helper;
+
+import static org.junit.Assert.assertNotEquals;
+
+import java.rmi.UnexpectedException;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.service.types.command.CreateEditBasedElementCommand;
+import org.eclipse.papyrus.uml.service.types.helper.ExpansionNodeHelper;
+import org.eclipse.papyrus.uml.service.types.helper.ExpansionRegionHelper;
+import org.eclipse.uml2.uml.ExpansionRegion;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.editor.presentation.UMLEditor;
+
+
+public class ExpansionRegionHelperTest extends TestCase {
+
+ public final static String TEST_UML_MODEL = "platform:/plugin/org.eclipse.papyrus.uml.diagram.activity.tests/content/UMLActivityTestModel.uml";
+
+ private MockExpansionRegionHelper myHelperInstance;
+
+ private UMLEditor myUMLEditor;
+
+ private TransactionalEditingDomain myEditingDomain;
+
+ public ExpansionRegionHelperTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myHelperInstance = new MockExpansionRegionHelper();
+ myUMLEditor = new UMLEditor();
+ myEditingDomain = new TransactionalEditingDomainImpl(myUMLEditor.getAdapterFactory()) {
+
+ @Override
+ public boolean isReadOnly(Resource resource) {
+ return false;
+ }
+ };
+ }
+
+ public void testExpansionNodeCreateCommand() throws Exception {
+ CreateElementRequest expansionNodeCreateRequest = initCreateElementRequest(UMLElementTypes.ExpansionNode_3074, UMLPackage.eINSTANCE.getExpansionRegion_InputElement());
+ ICommand command = myHelperInstance.getCreateCommand(expansionNodeCreateRequest);
+ commonExpansionRegionCreateChildTest(command);
+ CreateEditBasedElementCommand createCommand = (CreateEditBasedElementCommand)command;
+ assertNotEquals(expansionNodeCreateRequest, createCommand.getCreateRequest());
+ CreateElementRequest changedRequest = createCommand.getCreateRequest();
+ assertEquals(changedRequest.getContainer(), expansionNodeCreateRequest.getContainer());
+ assertEquals(changedRequest.getContainmentFeature(), UMLPackage.eINSTANCE.getStructuredActivityNode_Node());
+ assertEquals(changedRequest.getParameter(ExpansionNodeHelper.IN_EXPANSION_REGION), changedRequest.getContainer());
+ assertEquals(changedRequest.getParameter(ExpansionNodeHelper.EXPANSION_REGION_FEATURE), UMLPackage.eINSTANCE.getExpansionRegion_InputElement());
+ }
+
+ public void testExpansionRegionContainmentChildCreateCommand() throws Exception {
+ CreateElementRequest expansionRegionContainmentCreateRequest = initCreateElementRequest(UMLElementTypes.StructuredActivityNode_3065, UMLPackage.eINSTANCE.getStructuredActivityNode_Node());
+ ICommand command = myHelperInstance.getCreateCommand(expansionRegionContainmentCreateRequest);
+ commonExpansionRegionCreateChildTest(command);
+ CreateEditBasedElementCommand createCommand = (CreateEditBasedElementCommand)command;
+ assertEquals(expansionRegionContainmentCreateRequest, createCommand.getCreateRequest());
+ }
+
+ public void testExpansionRegionBadCreateCommand() throws Exception {
+ CreateElementRequest badCreateCommandRequest = initCreateElementRequest(UMLElementTypes.ExpansionNode_3074, UMLPackage.eINSTANCE.getStructuredActivityNode_Edge());
+ ICommand command = myHelperInstance.getCreateCommand(badCreateCommandRequest);
+ assertFalse(command.canExecute());
+ }
+
+ private void commonExpansionRegionCreateChildTest(ICommand command) throws Exception {
+ assertNotNull(command);
+ assertTrue(command.canExecute());
+ assertEquals(CreateEditBasedElementCommand.class, command.getClass());
+ }
+
+ private CreateElementRequest initCreateElementRequest(IElementType childType, EReference feature) throws UnexpectedException {
+ CreateElementRequest req = new CreateElementRequest(childType);
+ req.setContainer(loadExpansionRegion());
+ req.setContainmentFeature(feature);
+ req.setEditingDomain(myEditingDomain);
+ return req;
+ }
+
+ private ExpansionRegion loadExpansionRegion() throws UnexpectedException {
+ ResourceSet resourceSet = myUMLEditor.getEditingDomain().getResourceSet();
+ Resource resource = resourceSet.getResource(URI.createURI(TEST_UML_MODEL), true);
+ for(Iterator<EObject> i = resource.getAllContents(); i.hasNext();) {
+ EObject content = i.next();
+ if(content instanceof ExpansionRegion) {
+ return (ExpansionRegion)content;
+ }
+ }
+ throw new UnexpectedException("ExpansionRegion element was not fount in " + TEST_UML_MODEL);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ myEditingDomain = null;
+ myUMLEditor = null;
+ myHelperInstance = null;
+ super.tearDown();
+ }
+
+ private static class MockExpansionRegionHelper extends ExpansionRegionHelper {
+
+ @Override
+ public ICommand getCreateCommand(CreateElementRequest req) {
+ return super.getCreateCommand(req);
+ }
+
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/edit/part/ExpansionRegionCompartmentEPTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/edit/part/ExpansionRegionCompartmentEPTest.java
new file mode 100644
index 00000000000..09a1be16c1a
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/edit/part/ExpansionRegionCompartmentEPTest.java
@@ -0,0 +1,110 @@
+package org.eclipse.papyrus.uml.diagram.activity.tests.edit.part;
+
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.activity.edit.part.ActivityGroup.CustomExpansionRegionStructuredActivityNodeContentCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ExpansionRegionEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ExpansionRegionStructuredActivityNodeContentCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeCreationTool;
+import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeCreationTool.CreateAspectUnspecifiedTypeRequest;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.junit.Test;
+
+public class ExpansionRegionCompartmentEPTest extends TestCase {
+
+ private MockExpansionRegionEditPart myParentEP;
+
+ private MockCustomExpansionRegionCompartmentEditPart myCompartmentEP;
+
+ public ExpansionRegionCompartmentEPTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myParentEP = createParentEditPart();
+ myCompartmentEP = createCompartmentEP(myParentEP);
+ myParentEP.createDefaultEditPolicies();
+ myCompartmentEP.createDefaultEditPolicies();
+ }
+
+ private MockExpansionRegionEditPart createParentEditPart() {
+ EObject expansionRegionView = UMLFactory.eINSTANCE.createExpansionRegion();
+ View nodeView = NotationFactory.eINSTANCE.createShape();
+ nodeView.setElement(expansionRegionView);
+ nodeView.setType("" + ExpansionRegionEditPart.VISUAL_ID);
+ return new MockExpansionRegionEditPart(nodeView);
+ }
+
+ private MockCustomExpansionRegionCompartmentEditPart createCompartmentEP(ExpansionRegionEditPart parentEP) {
+ View decoratorView = NotationFactory.eINSTANCE.createDecorationNode();
+ decoratorView.setType("" + ExpansionRegionStructuredActivityNodeContentCompartmentEditPart.VISUAL_ID);
+ parentEP.getNotationView().insertChild(decoratorView);
+ MockCustomExpansionRegionCompartmentEditPart compartment = new MockCustomExpansionRegionCompartmentEditPart(decoratorView);
+ compartment.setParent(parentEP);
+ return compartment;
+ }
+
+ @Test
+ public void testExpansionNodeCreationRequest() {
+ assertEquals(myParentEP, getTestTargetEditPart(UMLElementTypes.ExpansionNode_3074, UMLElementTypes.ExpansionNode_3075));
+ }
+
+ @Test
+ public void testMixedElementTypesCreationRequest() {
+ assertNotNull(getTestTargetEditPart(UMLElementTypes.ExpansionNode_3074, UMLElementTypes.LoopNode_3071));
+ }
+
+ @Test
+ public void testAlienCreationRequest() {
+ assertEquals(myCompartmentEP, getTestTargetEditPart(UMLElementTypes.StructuredActivityNode_3065));
+ }
+
+ private EditPart getTestTargetEditPart(IElementType... types) {
+ List<IElementType> typesList = Arrays.asList(types);
+ CreateAspectUnspecifiedTypeRequest req = new AspectUnspecifiedTypeCreationTool(typesList).new CreateAspectUnspecifiedTypeRequest(typesList, PreferencesHint.USE_DEFAULTS);
+ return myCompartmentEP.getTargetEditPart(req);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ myCompartmentEP = null;
+ myParentEP = null;
+ super.tearDown();
+ }
+
+ private static class MockCustomExpansionRegionCompartmentEditPart extends CustomExpansionRegionStructuredActivityNodeContentCompartmentEditPart {
+
+ public MockCustomExpansionRegionCompartmentEditPart(View view) {
+ super(view);
+ }
+
+ @Override
+ public void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ }
+ }
+
+ private static class MockExpansionRegionEditPart extends ExpansionRegionEditPart {
+
+ public MockExpansionRegionEditPart(View view) {
+ super(view);
+ }
+
+ @Override
+ public void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ }
+ }
+}

Back to the top