Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrschnekenbu2013-04-22 15:54:33 +0000
committerrschnekenbu2013-04-22 15:54:33 +0000
commite14ce3097bd532e46ada74b7714189d7eb043226 (patch)
treeb040e1660f03660080fefb2eb923ba53a471bdb6 /tests/junit
parentd4851db92a63aa008cb7d1063b9b253853cb77a2 (diff)
downloadorg.eclipse.papyrus-e14ce3097bd532e46ada74b7714189d7eb043226.tar.gz
org.eclipse.papyrus-e14ce3097bd532e46ada74b7714189d7eb043226.tar.xz
org.eclipse.papyrus-e14ce3097bd532e46ada74b7714189d7eb043226.zip
348521: [Class Diagram] Can only add Class in Class nested classifier compartment
https://bugs.eclipse.org/bugs/show_bug.cgi?id=348521
Diffstat (limited to 'tests/junit')
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/ProjectUtils.java3
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/org.eclipse.papyrus.uml.diagram.activity.tests.launch (renamed from tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/Activity.launch)3
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityChildNode.java33
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AllCanonicalTests.java14
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java139
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildWithOtherCreationNode.java9
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/org.eclipse.papyrus.diagram.clazz.test.launch1
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/AllCanonicalTests.java2
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildLabel.java126
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildNode.java34
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramNestedClassifier.java162
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramTopNode.java37
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractPapyrusTestCase.java23
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractTestNode.java379
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestChildNode.java263
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestNested.java192
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestTopNode.java247
17 files changed, 1064 insertions, 603 deletions
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/ProjectUtils.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/ProjectUtils.java
index 6868dac868e..58772a76ac1 100644
--- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/ProjectUtils.java
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/ProjectUtils.java
@@ -43,6 +43,9 @@ public class ProjectUtils {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProject testProject = workspace.getRoot().getProject(projectName);
+ if(testProject.exists()) {
+ testProject.delete(true, new NullProgressMonitor());
+ }
testProject.create(new NullProgressMonitor());
testProject.open(new NullProgressMonitor());
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/Activity.launch b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/org.eclipse.papyrus.uml.diagram.activity.tests.launch
index 7de17edd64a..74ca739ac54 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/Activity.launch
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/org.eclipse.papyrus.uml.diagram.activity.tests.launch
@@ -23,6 +23,7 @@
<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.uml.diagram.activity.tests.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.uml.diagram.activity.tests"/>
@@ -30,7 +31,7 @@
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms256m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m"/>
<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="run_in_ui_thread" value="false"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityChildNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityChildNode.java
index 97c3fc6a42d..3780a15e8b1 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityChildNode.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityChildNode.java
@@ -14,18 +14,6 @@
package org.eclipse.papyrus.uml.diagram.activity.tests.canonical;
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- *****************************************************************************/
-
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
@@ -58,9 +46,16 @@ public abstract class AbstractTestActivityChildNode extends TestChildNode {
}
index++;
}
-
}
-
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isSemanticTest() {
+ return true;
+ }
+
/**
* Test change container.
*
@@ -72,20 +67,20 @@ public abstract class AbstractTestActivityChildNode extends TestChildNode {
@Override
public void testChangeContainer(IElementType type, IElementType containerType) {
//CHANGE CONTAINER
- assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getRootCompartment().getChildren().size() == 1);
+ assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getContainerEditPart().getChildren().size() == 1);
assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
- Request requestcreation = CreateViewRequestFactory.getCreateShapeRequest(containerType, getRootCompartment().getDiagramPreferencesHint());
- Command command = getRootCompartment().getCommand(requestcreation);
+ Request requestcreation = CreateViewRequestFactory.getCreateShapeRequest(containerType, getContainerEditPart().getDiagramPreferencesHint());
+ Command command = getContainerEditPart().getCommand(requestcreation);
assertNotNull(CONTAINER_CREATION + COMMAND_NULL, command);
assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
assertTrue(CONTAINER_CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 2);
- GraphicalEditPart containerEditPart = (GraphicalEditPart)getRootCompartment().getChildren().get(1);
+ GraphicalEditPart containerEditPart = (GraphicalEditPart)getContainerEditPart().getChildren().get(1);
ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_ADD);
- changeBoundsRequest.setEditParts((EditPart)getRootCompartment().getChildren().get(0));
+ changeBoundsRequest.setEditParts((EditPart)getContainerEditPart().getChildren().get(0));
changeBoundsRequest.setLocation(new Point(30, 30));
ShapeCompartmentEditPart compartment = null;
int index = 0;
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AllCanonicalTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AllCanonicalTests.java
index 4df211c6411..38f13691390 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AllCanonicalTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AllCanonicalTests.java
@@ -21,18 +21,10 @@ import org.junit.runners.Suite.SuiteClasses;
*/
@RunWith(Suite.class)
@SuiteClasses({
-
// child nodes
-TestActivityDiagramChildNode.class, TestActivityDiagramChildWithOtherCreationNode.class, TestActivityChildNodeInStructuredActivity.class
-//Nodes in structured Activity
-//TestActivityChildNodeInStructuredActivity.class,
-//test links
-//TestActivityDiagramLink.class,
-//test links owned by source
-//TestClassDiagramLinkOwnedBySource.class,
-//containmentLink
-//TestClassDiagramContainment.class,
-
+TestActivityDiagramChildNode.class,
+TestActivityDiagramChildWithOtherCreationNode.class,
+TestActivityChildNodeInStructuredActivity.class
})
public class AllCanonicalTests {
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java
index b384c8c8f5b..30560f8325b 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java
@@ -17,61 +17,69 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.uml.diagram.activity.CreateActivityDiagramCommand;
import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Ignore;
import org.junit.Test;
-
/**
* The Class TestClassDiagramChildNode.
*/
public class TestActivityDiagramChildNode extends AbstractTestActivityChildNode {
-
+ /**
+ * Test to manageDecision Node.
+ */
+ @Test
+ public void testToManageCentralBufferNode() {
+ testToManageChildNode(UMLElementTypes.CentralBufferNode_3104, UMLPackage.eINSTANCE.getCentralBufferNode(), UMLElementTypes.StructuredActivityNode_3065, true);
+ }
+
/**
* Test to manage component.
*/
@Test
public void testToManageOpaqueAction() {
- testToManageChildNode(UMLElementTypes.OpaqueAction_3007, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.OpaqueAction_3007, UMLPackage.eINSTANCE.getOpaqueAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
-
+
/**
* Test to manage initialNode.
*/
@Test
public void testToManageinitialNode() {
- testToManageChildNode(UMLElementTypes.InitialNode_3004, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.InitialNode_3004, UMLPackage.eINSTANCE.getInitialNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manage finalNode.
*/
@Test
public void testToManagefinalNode() {
- testToManageChildNode(UMLElementTypes.ActivityFinalNode_3005, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.ActivityFinalNode_3005, UMLPackage.eINSTANCE.getFinalNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
-
+
/**
* Test to manage flow final.
*/
@Test
public void testToManageflowfinal() {
- testToManageChildNode(UMLElementTypes.FlowFinalNode_3006, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.FlowFinalNode_3006, UMLPackage.eINSTANCE.getFlowFinalNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
-
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageDecisionNode() {
- testToManageChildNode(UMLElementTypes.DecisionNode_3038, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.DecisionNode_3038, UMLPackage.eINSTANCE.getDecisionNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
-
-
+
/**
* Test to manage MergeNode
*/
@Test
public void testToManageMergeNode() {
- testToManageChildNode(UMLElementTypes.MergeNode_3039, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.MergeNode_3039, UMLPackage.eINSTANCE.getMergeNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
/**
@@ -79,129 +87,129 @@ public class TestActivityDiagramChildNode extends AbstractTestActivityChildNode
*/
@Test
public void testToManageJoinNode() {
- testToManageChildNode(UMLElementTypes.JoinNode_3041, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.JoinNode_3041, UMLPackage.eINSTANCE.getJoinNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manage ForkNode_3040
*/
@Test
public void testToManageForkNode() {
- testToManageChildNode(UMLElementTypes.ForkNode_3040, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.ForkNode_3040, UMLPackage.eINSTANCE.getForkNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageDataStoreNode() {
- testToManageChildNode(UMLElementTypes.DataStoreNode_3078, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.DataStoreNode_3078, UMLPackage.eINSTANCE.getDataStoreNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
-
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageSendObjectAction() {
- testToManageChildNode(UMLElementTypes.SendObjectAction_3042, UMLElementTypes.StructuredActivityNode_3065, true);
- }
- /**
- * Test to manageDecision Node.
- */
- @Test
- public void testToManageSendSignalAction() {
- testToManageChildNode(UMLElementTypes.SendSignalAction_3052, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.SendObjectAction_3042, UMLPackage.eINSTANCE.getSendObjectAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageAcceptEventAction() {
- testToManageChildNode(UMLElementTypes.AcceptEventAction_3063, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.AcceptEventAction_3063, UMLPackage.eINSTANCE.getAcceptEventAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageValueSpecificationAction() {
- testToManageChildNode(UMLElementTypes.ValueSpecificationAction_3076, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.ValueSpecificationAction_3076, UMLPackage.eINSTANCE.getValueSpecificationAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageActivityPartition() {
- testToManageChildNode(UMLElementTypes.ActivityPartition_3067, UMLElementTypes.StructuredActivityNode_3065, false);
+ testToManageChildNode(UMLElementTypes.ActivityPartition_3067, UMLPackage.eINSTANCE.getActivityPartition(), UMLElementTypes.StructuredActivityNode_3065, false);
}
+
/**
* Test to manageInteruptibleActivityRegion.
*/
@Test
public void testToManageInteruptibleActivityRegion() {
- testToManageChildNode(UMLElementTypes.InterruptibleActivityRegion_3068, UMLElementTypes.StructuredActivityNode_3065, false);
+ testToManageChildNode(UMLElementTypes.InterruptibleActivityRegion_3068, UMLPackage.eINSTANCE.getInterruptibleActivityRegion(), UMLElementTypes.StructuredActivityNode_3065, false);
}
+
/**
* Test to manageStructuredActivity.
*/
@Test
public void testToManageStructuredActivity() {
- testToManageChildNode(UMLElementTypes.StructuredActivityNode_3065, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.StructuredActivityNode_3065, UMLPackage.eINSTANCE.getStructuredActivityNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manage ReadSelfAction.
*/
@Test
public void testToManageReadSelfAction() {
- testToManageChildNode(UMLElementTypes.ReadSelfAction_3081, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.ReadSelfAction_3081, UMLPackage.eINSTANCE.getReadSelfAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageConditionalNode() {
- testToManageChildNode(UMLElementTypes.ConditionalNode_3069, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.ConditionalNode_3069, UMLPackage.eINSTANCE.getConditionalNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageExpansionRegion() {
- testToManageChildNode(UMLElementTypes.ExpansionRegion_3070, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.ExpansionRegion_3070, UMLPackage.eINSTANCE.getExpansionRegion(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageloopNode() {
- testToManageChildNode(UMLElementTypes.LoopNode_3071, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.LoopNode_3071, UMLPackage.eINSTANCE.getLoopNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageSequenceNode() {
- testToManageChildNode(UMLElementTypes.SequenceNode_3073, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.SequenceNode_3073, UMLPackage.eINSTANCE.getSequenceNode(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manage Activity
*/
@Test
public void testToManageActivity() {
- testToManageChildNode(UMLElementTypes.Activity_3083, UMLElementTypes.StructuredActivityNode_3065, false);
- }
- //Create ObjectAction
- /**
- * Test to manageDecision Node.
- */
- @Test
- public void testToManageObjectAction() {
- testToManageChildNode(UMLElementTypes.CreateObjectAction_3086, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.Activity_3083, UMLPackage.eINSTANCE.getActivity(), UMLElementTypes.StructuredActivityNode_3065, false);
}
+
/**
* Test to manage readStructuralFeatureAction
*/
@Test
public void testToManagereadStructuralFeatureAction() {
- testToManageChildNode(UMLElementTypes.ReadStructuralFeatureAction_3088, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.ReadStructuralFeatureAction_3088, UMLPackage.eINSTANCE.getReadStructuralFeatureAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
//readStructuralfeatureValueAction
/**
* Test to manageDecision Node.
@@ -210,69 +218,72 @@ public class TestActivityDiagramChildNode extends AbstractTestActivityChildNode
public void testToManagereadStructuralfeatureValueAction() {
//testToManageChildNode(UMLElementTypes.r, UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manage DestroyObjectAction
*/
@Test
public void testToManageDestroyObjectAction() {
- testToManageChildNode(UMLElementTypes.DestroyObjectAction_3095, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.DestroyObjectAction_3095, UMLPackage.eINSTANCE.getDestroyObjectAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manage ReadVariableAction.
*/
@Test
public void testToManageReadVariableAction() {
- testToManageChildNode(UMLElementTypes.ReadVariableAction_3097, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.ReadVariableAction_3097, UMLPackage.eINSTANCE.getReadVariableAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
+
//ReadVariableValueAction
/**
* Test to manageReadVariableValueAction.
*/
+ @Ignore
@Test
public void testToManageReadVariableValueAction() {
- // testToManageChildNode(UMLElementTypes.ReadVariable, UMLElementTypes.StructuredActivityNode_3065, true);
+ // testToManageChildNode(UMLElementTypes.ReadVariable, UMLElementTypes.StructuredActivityNode_3065, true);
}
+
/**
* Test to manageDecision Node.
*/
@Test
public void testToManageBroadCastSignalAction() {
- testToManageChildNode(UMLElementTypes.BroadcastSignalAction_3102, UMLElementTypes.StructuredActivityNode_3065, true);
- }
- /**
- * Test to manageDecision Node.
- */
- @Test
- public void testToManageCentralBufferNode() {
- testToManageChildNode(UMLElementTypes.CentralBufferNode_3104, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.BroadcastSignalAction_3102, UMLPackage.eINSTANCE.getBroadcastSignalAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
-
+
/**
* Test to manage CreateObjectAction.
*/
@Test
public void testToManageCreateObjectAction() {
- testToManageChildNode(UMLElementTypes.CreateObjectAction_3086, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.CreateObjectAction_3086, UMLPackage.eINSTANCE.getCreateObjectAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
-
+
/**
* Test to manage AddVariableValueAction
*/
@Test
public void testToManageAddVariableValueAction() {
- testToManageChildNode(UMLElementTypes.AddVariableValueAction_3099, UMLElementTypes.StructuredActivityNode_3065, true);
+ testToManageChildNode(UMLElementTypes.AddVariableValueAction_3099, UMLPackage.eINSTANCE.getAddVariableValueAction(), UMLElementTypes.Activity_3083, true);
}
-
+
@Override
protected ICreationCommand getDiagramCommandCreation() {
- return new CreateActivityDiagramCommand();
+ return new CreateActivityDiagramCommand();
}
@Override
protected CreateViewRequest createViewRequestShapeContainer() {
- // TODO Auto-generated method stub
return null;
}
-
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isSemanticTest() {
+ return true;
+ }
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildWithOtherCreationNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildWithOtherCreationNode.java
index 0120083760d..044eed782f6 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildWithOtherCreationNode.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildWithOtherCreationNode.java
@@ -17,6 +17,7 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.uml.diagram.activity.CreateActivityDiagramCommand;
import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
+import org.junit.Ignore;
import org.junit.Test;
@@ -41,6 +42,14 @@ public class TestActivityDiagramChildWithOtherCreationNode extends AbstractTestA
testToManageChildNode(UMLElementTypes.CallOperationAction_3010, UMLElementTypes.StructuredActivityNode_3065, false);
}
+ /**
+ * Test to manageDecision Node.
+ */
+ @Test
+ public void testToManageSendSignalAction() {
+ testToManageChildNode(UMLElementTypes.SendSignalAction_3052, UMLElementTypes.StructuredActivityNode_3065, false);
+ }
+
@Override
protected ICreationCommand getDiagramCommandCreation() {
return new CreateActivityDiagramCommand();
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/org.eclipse.papyrus.diagram.clazz.test.launch b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/org.eclipse.papyrus.diagram.clazz.test.launch
index b204f2081bb..4cd713ab674 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/org.eclipse.papyrus.diagram.clazz.test.launch
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/org.eclipse.papyrus.diagram.clazz.test.launch
@@ -23,6 +23,7 @@
<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.clazz.test.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.clazz.tests"/>
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/AllCanonicalTests.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/AllCanonicalTests.java
index d80a94c07f1..9ea98c09a23 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/AllCanonicalTests.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/AllCanonicalTests.java
@@ -39,6 +39,8 @@ TestClassDiagramContainment.class,
TestDropfunction.class,
//test is a static operation is underlined
TestStaticFeatureRepresentation.class,
+//test nested classifier
+TestClassDiagramNestedClassifier.class,
})
public class AllCanonicalTests {
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildLabel.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildLabel.java
index 922fa4a5409..031ae60e760 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildLabel.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildLabel.java
@@ -9,6 +9,8 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Nizar GUEDIDI (CEA LIST) - Add tests for Primitive Type properties and operations
+ * Nizar GUEDIDI (CEA LIST) - Add tests for nested classifier compartments
*
*****************************************************************************/
package org.eclipse.papyrus.diagram.clazz.test.canonical;
@@ -22,7 +24,6 @@ import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassOperationCompartmen
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentAttributeCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentNestedClassifierCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.EnumerationEnumerationLiteralCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InstanceSpecificationSlotCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceAttributeCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceNestedClassifierCompartmentEditPart;
@@ -33,7 +34,6 @@ import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.SignalAttributeCompartme
import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
import org.junit.Test;
-
// TODO: Auto-generated Javadoc
/**
* The Class TestClassDiagramChildLabel.
@@ -46,7 +46,7 @@ public class TestClassDiagramChildLabel extends TestChildLabel {
}
@Test
- public void testToManageinstanceSlot() {
+ public void testToManageInstanceSlot() {
//instance specification
testToManageTopNode(UMLElementTypes.InstanceSpecification_2001, UMLElementTypes.Slot_3030, InstanceSpecificationSlotCompartmentEditPart.VISUAL_ID);
}
@@ -59,11 +59,46 @@ public class TestClassDiagramChildLabel extends TestChildLabel {
@Test
public void testToManageComponentNestedClass() {
- //instance specification
+ //Class
testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Class_3004, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID);
}
@Test
+ public void testToManageComponentNestedInterface() {
+ //Interface
+ testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Interface_3037, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageComponentNestedSignal() {
+ //Signal
+ testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Signal_3051, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageComponentNestedDataType() {
+ //Data Type
+ testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.DataType_3045, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageComponentNestedEnumeration() {
+ //Enumeration
+ testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Enumeration_3053, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageComponentNestedPrimitiveType() {
+ //primitive Type
+ testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.PrimitiveType_3046, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
public void testToManageComponentOperation() {
//instance specification
testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Operation_3003, ComponentOperationCompartmentEditPart.VISUAL_ID);
@@ -89,14 +124,50 @@ public class TestClassDiagramChildLabel extends TestChildLabel {
@Test
public void testToManageInterfaceNestedClass() {
- //interface
+ //Class
testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.Class_3008, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedInterface() {
+ //Interface
+ testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.Interface_3038, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedSignal() {
+ //Signal
+ testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.Signal_3049, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedDataType() {
+ //Data Type
+ testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.DataType_3043, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedEnumeration() {
+ //Enumeration
+ testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.Enumeration_3054, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedPrimitiveType() {
+ //Primitive Type
+ testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.PrimitiveType_3048, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID);
+
}
@Test
public void testToManageEnumerationLiteralEnumeration() {
//Enumeration
- testToManageTopNode(UMLElementTypes.Enumeration_2006, UMLElementTypes.EnumerationLiteral_3017, EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID);
+ //testToManageTopNode(UMLElementTypes.Enumeration_2006, UMLElementTypes.EnumerationLiteral_3017, EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID);
}
@Test
@@ -121,8 +192,43 @@ public class TestClassDiagramChildLabel extends TestChildLabel {
public void testToManageClassNestedClass() {
//class
testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.Class_3014, ClassNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageClassNestedInetrface() {
+ //Interface
+ testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.Interface_3036, ClassNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageClassNestedSignal() {
+ //Signal
+ testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.Signal_3050, ClassNestedClassifierCompartmentEditPart.VISUAL_ID);
+
}
+ @Test
+ public void testToManageClassNestedDataType() {
+ //Data Type
+ testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.DataType_3044, ClassNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageClassNestedEnumeration() {
+ //Enumeration
+ testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.Enumeration_3052, ClassNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageClassNestedPrimitiveType() {
+ //Primitive Type
+ testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.PrimitiveType_3047, ClassNestedClassifierCompartmentEditPart.VISUAL_ID);
+
+ }
@Test
public void testToManageComponentReception() {
@@ -135,16 +241,16 @@ public class TestClassDiagramChildLabel extends TestChildLabel {
//class
testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.Reception_3039, InterfaceOperationCompartmentEditPart.VISUAL_ID);
}
-
+
@Test
public void testToManagePrimitiveTypeProperty() {
//class
- testToManageTopNode(UMLElementTypes.PrimitiveType_2009, UMLElementTypes.Property_3041,PrimitiveTypeAttributeCompartmentEditPart.VISUAL_ID );
+ testToManageTopNode(UMLElementTypes.PrimitiveType_2009, UMLElementTypes.Property_3041, PrimitiveTypeAttributeCompartmentEditPart.VISUAL_ID);
}
-
+
@Test
public void testToManagePrimitiveTypeOperation() {
//class
- testToManageTopNode(UMLElementTypes.PrimitiveType_2009, UMLElementTypes.Operation_3042,PrimitiveTypeOperationCompartmentEditPart.VISUAL_ID);
+ testToManageTopNode(UMLElementTypes.PrimitiveType_2009, UMLElementTypes.Operation_3042, PrimitiveTypeOperationCompartmentEditPart.VISUAL_ID);
}
}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildNode.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildNode.java
index 3831858ed21..448d8e5f576 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildNode.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildNode.java
@@ -19,10 +19,10 @@ import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.diagram.tests.canonical.TestChildNode;
import org.eclipse.papyrus.uml.diagram.clazz.CreateClassDiagramCommand;
import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.UMLPackage;
import org.junit.Test;
-// TODO: Auto-generated Javadoc
/**
* The Class TestClassDiagramChildNode.
*/
@@ -35,11 +35,19 @@ public class TestClassDiagramChildNode extends TestChildNode {
}
/**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isSemanticTest() {
+ return true;
+ }
+
+ /**
* Test to manage component.
*/
@Test
public void testToManageComponent() {
- testToManageChildNode(UMLElementTypes.Component_3021, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.Component_3021, UMLPackage.eINSTANCE.getComponent(), UMLElementTypes.Package_3009, true);
}
/**
@@ -47,7 +55,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManageInstanceSpecification() {
- testToManageChildNode(UMLElementTypes.InstanceSpecification_3020, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.InstanceSpecification_3020, UMLPackage.eINSTANCE.getInstanceSpecification(), UMLElementTypes.Package_3009, true);
}
/**
@@ -55,7 +63,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManageSignal() {
- testToManageChildNode(UMLElementTypes.Signal_3022, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.Signal_3022, UMLPackage.eINSTANCE.getSignal(), UMLElementTypes.Package_3009, true);
}
/**
@@ -63,7 +71,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManageModel() {
- testToManageChildNode(UMLElementTypes.Model_3024, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.Model_3024, UMLPackage.eINSTANCE.getModel(), UMLElementTypes.Package_3009, true);
}
/**
@@ -71,7 +79,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManageEnumeration() {
- testToManageChildNode(UMLElementTypes.Enumeration_3025, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.Enumeration_3025, UMLPackage.eINSTANCE.getEnumeration(), UMLElementTypes.Package_3009, true);
}
/**
@@ -79,7 +87,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManageIPackage() {
- testToManageChildNode(UMLElementTypes.Package_3009, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.Package_3009, UMLPackage.eINSTANCE.getPackage(), UMLElementTypes.Package_3009, true);
}
/**
@@ -87,7 +95,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManageClass() {
- testToManageChildNode(UMLElementTypes.Class_3010, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.Class_3010, UMLPackage.eINSTANCE.getClass_(), UMLElementTypes.Package_3009, true);
}
/**
@@ -95,7 +103,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManageInformationItem() {
- testToManageChildNode(UMLElementTypes.InformationItem_3040, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.InformationItem_3040, UMLPackage.eINSTANCE.getInformationItem(), UMLElementTypes.Package_3009, true);
}
/**
@@ -103,7 +111,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManagePrimitiveType() {
- testToManageChildNode(UMLElementTypes.PrimitiveType_3026, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.PrimitiveType_3026, UMLPackage.eINSTANCE.getPrimitiveType(), UMLElementTypes.Package_3009, true);
}
/**
@@ -111,7 +119,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManageDataType() {
- testToManageChildNode(UMLElementTypes.DataType_3027, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.DataType_3027, UMLPackage.eINSTANCE.getDataType(), UMLElementTypes.Package_3009, true);
}
/**
@@ -119,7 +127,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManageConstraint() {
- testToManageChildNode(UMLElementTypes.Constraint_3029, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.Constraint_3029, UMLPackage.eINSTANCE.getConstraint(), UMLElementTypes.Package_3009, true);
}
/**
@@ -127,7 +135,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
*/
@Test
public void testToManageComment() {
- testToManageChildNode(UMLElementTypes.Comment_3028, UMLElementTypes.Package_3009, true);
+ testToManageChildNode(UMLElementTypes.Comment_3028, UMLPackage.eINSTANCE.getComment(), UMLElementTypes.Package_3009, true);
}
@Override
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramNestedClassifier.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramNestedClassifier.java
new file mode 100644
index 00000000000..99d8fa19196
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramNestedClassifier.java
@@ -0,0 +1,162 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Nizar GUEDIDI (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.clazz.test.canonical;
+
+import org.eclipse.papyrus.commands.ICreationCommand;
+import org.eclipse.papyrus.diagram.tests.canonical.TestNested;
+import org.eclipse.papyrus.uml.diagram.clazz.CreateClassDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassNestedClassifierCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentNestedClassifierCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceNestedClassifierCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackagePackageableElementCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
+import org.junit.Test;
+
+/**
+ * The Class TestClassDiagramNestedClassifier.
+ */
+public class TestClassDiagramNestedClassifier extends TestNested {
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateClassDiagramCommand();
+ }
+
+ @Test
+ public void testToManageComponentNestedClass() {
+ //Class
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Component_3021, UMLElementTypes.Class_3004, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageComponentNestedInterface() {
+ //Interface
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Component_3021, UMLElementTypes.Interface_3037, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageComponentNestedSignal() {
+ //Signal
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Component_3021, UMLElementTypes.Signal_3051, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageComponentNestedDataType() {
+ //Data Type
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Component_3021, UMLElementTypes.DataType_3045, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageComponentNestedEnumeration() {
+ //Enumeration
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Component_3021, UMLElementTypes.Enumeration_3053, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageComponentNestedPrimitiveType() {
+ //primitive Type
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Component_3021, UMLElementTypes.PrimitiveType_3046, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedClass() {
+ //Class
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Interface_3023, UMLElementTypes.Class_3008, PackagePackageableElementCompartmentEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedInterface() {
+ //Interface
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Interface_3023, UMLElementTypes.Interface_3038, PackagePackageableElementCompartmentEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedSignal() {
+ //Signal
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Interface_3023, UMLElementTypes.Signal_3049, PackagePackageableElementCompartmentEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedDataType() {
+ //Data Type
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Interface_3023, UMLElementTypes.DataType_3043, PackagePackageableElementCompartmentEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedEnumeration() {
+ //Enumeration
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Interface_3023, UMLElementTypes.Enumeration_3054, PackagePackageableElementCompartmentEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageInterfaceNestedPrimitiveType() {
+ //Primitive Type
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Interface_3023, UMLElementTypes.PrimitiveType_3048, PackagePackageableElementCompartmentEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageClassNestedClass() {
+ //class
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Class_3010, UMLElementTypes.Class_3014, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageClassNestedInetrface() {
+ //Interface
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Class_3010, UMLElementTypes.Interface_3036, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageClassNestedSignal() {
+ //Signal
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Class_3010, UMLElementTypes.Signal_3050, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageClassNestedDataType() {
+ //Data Type
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Class_3010, UMLElementTypes.DataType_3044, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageclassNestedEnumeration() {
+ //Enumeration
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Class_3010, UMLElementTypes.Enumeration_3052, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+ @Test
+ public void testToManageClassNestedPrimitiveType() {
+ //Primitive Type
+ testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Class_3010, UMLElementTypes.PrimitiveType_3047, PackagePackageableElementCompartmentEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPartCN.VISUAL_ID);
+
+ }
+
+}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramTopNode.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramTopNode.java
index aeb8a48038d..820dc2d3312 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramTopNode.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramTopNode.java
@@ -13,10 +13,13 @@
*****************************************************************************/
package org.eclipse.papyrus.diagram.clazz.test.canonical;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.diagram.tests.canonical.TestTopNode;
import org.eclipse.papyrus.uml.diagram.clazz.CreateClassDiagramCommand;
import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.UMLPackage;
import org.junit.Test;
@@ -25,6 +28,8 @@ import org.junit.Test;
* The Class TestClassDiagramTopNode.
*/
public class TestClassDiagramTopNode extends TestTopNode {
+
+
@Override
protected ICreationCommand getDiagramCommandCreation() {
return new CreateClassDiagramCommand();
@@ -35,7 +40,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageComponent() {
- testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.Component_2002, UMLPackage.eINSTANCE.getComponent(), UMLElementTypes.Package_2007, true);
}
/**
@@ -43,7 +48,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageInstanceSpecification() {
- testToManageTopNode(UMLElementTypes.InstanceSpecification_2001, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.InstanceSpecification_2001, UMLPackage.eINSTANCE.getInstanceSpecification(), UMLElementTypes.Package_2007, true);
}
/**
@@ -51,7 +56,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageSignal() {
- testToManageTopNode(UMLElementTypes.Signal_2003, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.Signal_2003, UMLPackage.eINSTANCE.getSignal(), UMLElementTypes.Package_2007, true);
}
/**
@@ -59,7 +64,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageModel() {
- testToManageTopNode(UMLElementTypes.Model_2005, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.Model_2005, UMLPackage.eINSTANCE.getModel(), UMLElementTypes.Package_2007, true);
}
/**
@@ -67,7 +72,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageEnumeration() {
- testToManageTopNode(UMLElementTypes.Enumeration_2006, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.Enumeration_2006, UMLPackage.eINSTANCE.getEnumeration(), UMLElementTypes.Package_2007, true);
}
/**
@@ -75,7 +80,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageIPackage() {
- testToManageTopNode(UMLElementTypes.Package_2007, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.Package_2007, UMLPackage.eINSTANCE.getPackage(), UMLElementTypes.Package_2007, true);
}
/**
@@ -83,7 +88,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageClass() {
- testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.Class_2008, UMLPackage.eINSTANCE.getClass_(), UMLElementTypes.Package_2007, true);
}
/**
@@ -91,7 +96,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManagePrimitiveType() {
- testToManageTopNode(UMLElementTypes.PrimitiveType_2009, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.PrimitiveType_2009, UMLPackage.eINSTANCE.getPrimitiveType(), UMLElementTypes.Package_2007, true);
}
/**
@@ -99,7 +104,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageDataType() {
- testToManageTopNode(UMLElementTypes.DataType_2010, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.DataType_2010, UMLPackage.eINSTANCE.getDataType(), UMLElementTypes.Package_2007, true);
}
/**
@@ -107,7 +112,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageConstraint() {
- testToManageTopNode(UMLElementTypes.Constraint_2011, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.Constraint_2011, UMLPackage.eINSTANCE.getConstraint(), UMLElementTypes.Package_2007, true);
}
/**
@@ -115,7 +120,7 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageComment() {
- testToManageTopNode(UMLElementTypes.Comment_2012, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.Comment_2012, UMLPackage.eINSTANCE.getComment(), UMLElementTypes.Package_2007, true);
}
/**
@@ -123,7 +128,15 @@ public class TestClassDiagramTopNode extends TestTopNode {
*/
@Test
public void testToManageInformationItem() {
- testToManageTopNode(UMLElementTypes.InformationItem_2099, UMLElementTypes.Package_2007);
+ testToManageNode(UMLElementTypes.InformationItem_2099, UMLPackage.eINSTANCE.getInformationItem(), UMLElementTypes.Package_2007, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CreateViewRequest createViewRequestShapeContainer() {
+ return CreateViewRequestFactory.getCreateShapeRequest(UMLElementTypes.Package_2007, getDiagramEditPart().getDiagramPreferencesHint());
}
}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractPapyrusTestCase.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractPapyrusTestCase.java
index cea6df5820a..c6b358acb28 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractPapyrusTestCase.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractPapyrusTestCase.java
@@ -42,7 +42,9 @@ import org.eclipse.papyrus.uml.diagram.common.part.UmlGmfDiagramEditor;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.IntroPart;
import org.eclipse.uml2.uml.Element;
import org.junit.After;
import org.junit.Assert;
@@ -207,6 +209,26 @@ public abstract class AbstractPapyrusTestCase extends TestCase {
* Project creation.
*/
protected void projectCreation() {
+
+ // assert the intro is not visible
+ Runnable closeIntroRunnable = new Runnable() {
+
+ public void run() {
+ try {
+ IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
+ if(introPart!=null) {
+ PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ fail(ex.getMessage());
+ }
+ }
+ };
+
+ Display.getDefault().syncExec(closeIntroRunnable);
+
+
IWorkspace workspace = ResourcesPlugin.getWorkspace();
root = workspace.getRoot();
project = root.getProject("ClazzDiagramTestProject");
@@ -250,6 +272,7 @@ public abstract class AbstractPapyrusTestCase extends TestCase {
page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
papyrusEditor = (IMultiDiagramEditor)page.openEditor(new FileEditorInput(file), PapyrusMultiDiagramEditor.EDITOR_ID);
} catch (Exception ex) {
+ fail(ex.getMessage());
ex.printStackTrace(System.out);
}
}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractTestNode.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractTestNode.java
new file mode 100644
index 00000000000..92463c70012
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractTestNode.java
@@ -0,0 +1,379 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.tests.canonical;
+
+import java.util.ArrayList;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Element;
+import org.junit.Before;
+
+
+/**
+ * Abstract class to test nodes
+ */
+public abstract class AbstractTestNode extends org.eclipse.papyrus.diagram.tests.canonical.AbstractPapyrusTestCase{
+
+ /** <code>true</code> if semantic tests should be run on graphical manipulation */
+ private boolean testSemantic;
+
+ /** command computed on the ui thread */
+ private Command command;
+
+ /**
+ * @see org.eclipse.papyrus.diagram.clazz.test.canonical.AbstractPapyrusTestCase#setUp()
+ *
+ * @throws Exception
+ */
+ @Before
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ testSemantic = isSemanticTest();
+ }
+
+ /**
+ * Returns <code>true</code> if semantic tests should be also performed
+ *
+ * @return <code>true</code> if semantic tests should be also performed
+ */
+ protected boolean isSemanticTest() {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.diagram.clazz.test.canonical.AbstractPapyrusTestCase#getRootView()
+ *
+ * @return
+ */
+
+ protected abstract View getRootView();
+
+ /**
+ * Returns the container edit part
+ */
+ protected abstract IGraphicalEditPart getContainerEditPart();
+
+ /**
+ * Test to manage child node.
+ *
+ * @param type
+ * the type
+ * @param containerType
+ * the container type
+ */
+ public void testToManageNode(IElementType type, EClass eClass, IElementType containerType, boolean containerMove) {
+ // create a node
+ testToCreateANode(type);
+ // creates a second one
+ testToCreateANode(type, 1, 1, 1, 1);
+ // destroy the first element
+ testDestroy(type, 2, 2, 1, 1);
+ // destroy the second one
+ testDestroy(type, 1, 1, 1, 1);
+ // the node has been destroyed, the UML element also. restore one element
+ undoOnUIThread();
+
+ // the node and the UML element are present
+ testViewDeletion(type);
+ // The node has been deleted, the uml element is still present
+ testDrop(type, eClass);
+ // the node and element are present
+ if(containerMove) {
+ testChangeContainer(type, containerType);
+ }
+ }
+
+
+ /**
+ * Test to manage child node.
+ *
+ * @param type
+ * the type
+ * @param containerType
+ * the container type
+ * @deprecated, @use {@link AbstractTestNode#testToManageNode(IElementType, EClass, IElementType, boolean)}
+ */
+ @Deprecated
+ public void testToManageChildNode(IElementType type, EClass eClass, IElementType containerType, boolean containerMove) {
+ testToManageNode(type, eClass, containerType, containerMove);
+ }
+
+ /**
+ * Test destroy.
+ *
+ * @param type
+ * the type
+ */
+ public void testDestroy(IElementType type) {
+ testDestroy(type, 1, 1, 1, 1);
+ }
+
+ /**
+ * Test destroy.
+ *
+ * @param type
+ * the type
+ */
+ public void testDestroy(IElementType type, int expectedGraphicalChildren, int expectedSemanticChildren, int removedGraphicalChildren, int removedSemanticChildren) {
+ // DESTROY SEMANTIC + VIEW
+ assertEquals(DESTROY_DELETION + INITIALIZATION_TEST, expectedGraphicalChildren, getContainerEditPart().getChildren().size());
+ if(testSemantic) {
+ assertEquals(DESTROY_DELETION + INITIALIZATION_TEST, expectedSemanticChildren, getRootSemanticModel().getOwnedElements().size());
+ }
+
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command command = ((GraphicalEditPart)getContainerEditPart().getChildren().get(0)).getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
+ executeOnUIThread(command);
+ assertEquals(DESTROY_DELETION + TEST_THE_EXECUTION, expectedGraphicalChildren - removedGraphicalChildren, getContainerEditPart().getChildren().size());
+ if(testSemantic) {
+ assertEquals(DESTROY_DELETION + INITIALIZATION_TEST, expectedSemanticChildren - removedSemanticChildren, getRootSemanticModel().getOwnedElements().size());
+ }
+
+ undoOnUIThread();
+ assertEquals(DESTROY_DELETION + TEST_THE_UNDO, expectedGraphicalChildren, getContainerEditPart().getChildren().size());
+ if(testSemantic) {
+ assertEquals(DESTROY_DELETION + TEST_THE_UNDO, expectedSemanticChildren, getRootSemanticModel().getOwnedElements().size());
+ }
+
+ redoOnUIThread();
+ assertEquals(DESTROY_DELETION + TEST_THE_REDO, expectedGraphicalChildren - removedGraphicalChildren, getContainerEditPart().getChildren().size());
+ if(testSemantic) {
+ assertEquals(DESTROY_DELETION + TEST_THE_UNDO, expectedSemanticChildren - removedSemanticChildren, getRootSemanticModel().getOwnedElements().size());
+ }
+ }
+
+ /**
+ * Test drop.
+ *
+ * @param type
+ * the type
+ */
+ public void testDrop(IElementType type, EClass eClass) {
+ //DROP
+ assertEquals(DROP + INITIALIZATION_TEST, 0, getContainerEditPart().getChildren().size());
+ if(testSemantic) {
+ assertEquals(DROP + INITIALIZATION_TEST, 1, getRootSemanticModel().getOwnedElements().size());
+ }
+
+ DropObjectsRequest dropObjectsRequest = new DropObjectsRequest();
+ ArrayList<Element> list = new ArrayList<Element>();
+ for(Element element : getRootSemanticModel().getOwnedElements()) {
+ if(element != null && element.eClass().equals(eClass)) {
+ list.add(element);
+ }
+ }
+ dropObjectsRequest.setObjects(list);
+ dropObjectsRequest.setLocation(new Point(40, 40));
+ Command command = getContainerEditPart().getCommand(dropObjectsRequest);
+ assertNotNull(DROP + COMMAND_NULL, command);
+ assertTrue(DROP + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DROP + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
+
+ // execute the drop
+ executeOnUIThread(command);
+ assertTrue(DROP + TEST_THE_EXECUTION, getContainerEditPart().getChildren().size() != 0);
+ assertTrue(DROP + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() != 0);
+
+ // undo the drop
+ undoOnUIThread();
+ assertEquals(DROP + TEST_THE_UNDO, 0, getContainerEditPart().getChildren().size());
+ assertTrue(DROP + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() != 0);
+
+ // redo the drop
+ redoOnUIThread();
+ assertTrue(DROP + TEST_THE_REDO, getContainerEditPart().getChildren().size() != 0);
+ assertTrue(DROP + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() != 0);
+ }
+
+ /**
+ * Test change container.
+ *
+ * @param type
+ * the type
+ * @param containerType
+ * the container type
+ */
+ public void testChangeContainer(IElementType type, IElementType containerType) {
+ //CHANGE CONTAINER
+ assertEquals(CHANGE_CONTAINER + INITIALIZATION_TEST, 1, getContainerEditPart().getChildren().size());
+ assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
+
+ Request requestcreation = CreateViewRequestFactory.getCreateShapeRequest(containerType, getContainerEditPart().getDiagramPreferencesHint());
+ Command command = getContainerEditPart().getCommand(requestcreation);
+ assertNotNull(CONTAINER_CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
+ executeOnUIThread(command);
+ assertTrue(CONTAINER_CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 2);
+ GraphicalEditPart containerEditPart = (GraphicalEditPart)getContainerEditPart().getChildren().get(1);
+ ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_ADD);
+ changeBoundsRequest.setEditParts((EditPart)getContainerEditPart().getChildren().get(0));
+ changeBoundsRequest.setLocation(new Point(30, 30));
+ ShapeCompartmentEditPart compartment = null;
+ int index = 0;
+ while(compartment == null && index < containerEditPart.getChildren().size()) {
+ if((containerEditPart.getChildren().get(index)) instanceof ShapeCompartmentEditPart) {
+ compartment = (ShapeCompartmentEditPart)(containerEditPart.getChildren().get(index));
+ }
+ index++;
+ }
+ assertTrue("Container not found", compartment != null);
+
+ command = compartment.getCommand(changeBoundsRequest);
+ assertNotNull(CHANGE_CONTAINER, command);
+ assertTrue(CHANGE_CONTAINER + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(CHANGE_CONTAINER + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
+
+ // execute change container
+ executeOnUIThread(command);
+ assertEquals(CHANGE_CONTAINER + TEST_THE_EXECUTION, 1, getRootView().getChildren().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_EXECUTION, 1, getRootSemanticModel().getOwnedElements().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_EXECUTION, 1, compartment.getChildren().size());
+
+ // undo change container
+ undoOnUIThread();
+ assertEquals(CHANGE_CONTAINER + TEST_THE_UNDO, 2, getRootView().getChildren().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_UNDO, 2, getRootSemanticModel().getOwnedElements().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_EXECUTION, 0, compartment.getChildren().size());
+
+ // redo change container
+ redoOnUIThread();
+ assertEquals(CHANGE_CONTAINER + TEST_THE_REDO, 1, getRootView().getChildren().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_REDO, 1, getRootSemanticModel().getOwnedElements().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_EXECUTION, 1, compartment.getChildren().size());
+
+ }
+
+ /**
+ * Test to create a node.
+ *
+ * @param type
+ * the type
+ */
+ public void testToCreateANode(IElementType type, int expectedGraphicalChildren, int expectedSemanticChildren, int addedGraphicalChildren, int addedSemanticChildren) {
+ command = null;
+ //CREATION
+ assertEquals(CREATION + INITIALIZATION_TEST, expectedGraphicalChildren, getContainerEditPart().getChildren().size());
+ assertEquals(CREATION + INITIALIZATION_TEST, expectedSemanticChildren, getRootSemanticModel().getOwnedElements().size());
+
+ final CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getContainerEditPart().getDiagramPreferencesHint());
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ command = getContainerEditPart().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());
+
+ // execute the creation
+ executeOnUIThread(command);
+ assertEquals(CREATION + TEST_THE_EXECUTION, expectedGraphicalChildren + addedGraphicalChildren, getRootView().getChildren().size());
+ if(testSemantic) {
+ assertEquals(CREATION + TEST_THE_EXECUTION, expectedSemanticChildren + addedSemanticChildren, getRootSemanticModel().getOwnedElements().size());
+ }
+
+ // undo the creation
+ undoOnUIThread();
+ assertEquals(CREATION + TEST_THE_UNDO, expectedGraphicalChildren, getRootView().getChildren().size());
+ if(testSemantic) {
+ assertEquals(CREATION + TEST_THE_UNDO, expectedSemanticChildren, getRootSemanticModel().getOwnedElements().size());
+ }
+
+ // redo the creation test
+ redoOnUIThread();
+ assertEquals(CREATION + TEST_THE_REDO, expectedGraphicalChildren + addedGraphicalChildren, getRootView().getChildren().size());
+ if(testSemantic) {
+ assertEquals(CREATION + TEST_THE_REDO, expectedSemanticChildren + addedSemanticChildren, getRootSemanticModel().getOwnedElements().size());
+ }
+
+ }
+
+ /**
+ * Test to create a node.
+ *
+ * @param type
+ * the type
+ */
+ public void testToCreateANode(IElementType type) {
+ testToCreateANode(type, 0, 0, 1, 1);
+ }
+
+ /**
+ * Test view deletion.
+ *
+ * @param type
+ * the type
+ */
+ public void testViewDeletion(IElementType type) {
+ //DELETION OF THE VIEW
+ assertEquals(VIEW_DELETION + INITIALIZATION_TEST, 1, getContainerEditPart().getChildren().size());
+ if(testSemantic) {
+
+ }
+
+ Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
+ Command command = ((IGraphicalEditPart)getContainerEditPart().getChildren().get(0)).getCommand(deleteViewRequest);
+ assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
+
+ // execute hide the view
+ executeOnUIThread(command);
+ assertEquals(VIEW_DELETION + TEST_THE_EXECUTION, 0, getContainerEditPart().getChildren().size());
+ if(testSemantic) {
+ //assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() == numberOfRelatedSemanticElement);
+ }
+
+ // undo hide the view
+ undoOnUIThread();
+ assertEquals(VIEW_DELETION + TEST_THE_UNDO, 1, getContainerEditPart().getChildren().size());
+ if(testSemantic) {
+ //assertTrue(VIEW_DELETION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == numberOfRelatedSemanticElement);
+ }
+
+ // redo hide the view
+ redoOnUIThread();
+ assertEquals(VIEW_DELETION + TEST_THE_REDO, 0, getContainerEditPart().getChildren().size());
+ if(testSemantic) {
+ //assertTrue(VIEW_DELETION + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() == numberOfRelatedSemanticElement);
+ }
+
+ }
+
+ protected abstract CreateViewRequest createViewRequestShapeContainer();
+}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestChildNode.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestChildNode.java
index a96248de4ef..a1244d2839d 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestChildNode.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestChildNode.java
@@ -13,234 +13,27 @@
*****************************************************************************/
package org.eclipse.papyrus.diagram.tests.canonical;
-import java.util.ArrayList;
-
import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gef.requests.GroupRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
-import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.uml2.uml.Element;
import org.junit.Before;
-
-
-// TODO: Auto-generated Javadoc
/**
* The Class TestChildNode.
+ * Semantic tests shall be executed apart from the graphical test has one view may be related to a different number of UML elements
+ * in different diagram
*/
-public abstract class TestChildNode extends org.eclipse.papyrus.diagram.tests.canonical.AbstractPapyrusTestCase {
-
- // Semantic tests shall be executed apart from the graphical test has one view may be related to a different number of UML elements
- // in different diagram
-
+public abstract class TestChildNode extends AbstractTestNode {
/** The root compartment. */
protected ShapeCompartmentEditPart rootCompartment = null;
/**
- * Test view deletion.
- *
- * @param type
- * the type
- */
- public void testViewDeletion(IElementType type) {
- //DELETION OF THE VIEW
- assertTrue(VIEW_DELETION + INITIALIZATION_TEST, getRootCompartment().getChildren().size() == 1);
- //assertTrue(VIEW_DELETION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == numberOfRelatedSemanticElement);
-
- Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
- Command command = ((GraphicalEditPart)getRootCompartment().getChildren().get(0)).getCommand(deleteViewRequest);
- assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
- assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- executeOnUIThread(command);
- assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, getRootCompartment().getChildren().size() == 0);
- //assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() == numberOfRelatedSemanticElement);
- undoOnUIThread();
- assertTrue(VIEW_DELETION + TEST_THE_UNDO, getRootCompartment().getChildren().size() == 1);
- //assertTrue(VIEW_DELETION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == numberOfRelatedSemanticElement);
- redoOnUIThread();
- assertTrue(VIEW_DELETION + TEST_THE_REDO, getRootCompartment().getChildren().size() == 0);
- //assertTrue(VIEW_DELETION + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() == numberOfRelatedSemanticElement);
-
- }
-
- /**
- * Gets the root compartment.
- *
- * @return the root compartment
- */
- protected ShapeCompartmentEditPart getRootCompartment() {
- assertNotNull(rootCompartment);
- return rootCompartment;
- }
-
- /**
- * Test destroy.
- *
- * @param type
- * the type
- */
- public void testDestroy(IElementType type) {
- //DESTROY SEMANTIC+ VIEW
- assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, getRootCompartment().getChildren().size() == 1);
- //assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
-
- Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
- Command command = ((GraphicalEditPart)getRootCompartment().getChildren().get(0)).getCommand(deleteViewRequest);
- assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
- assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- executeOnUIThread(command);
- assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, getRootCompartment().getChildren().size() == 0);
- //assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() == 0);
- undoOnUIThread();
- assertTrue(DESTROY_DELETION + TEST_THE_UNDO, getRootCompartment().getChildren().size() == 1);
- //assertTrue(DESTROY_DELETION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 1);
- redoOnUIThread();
- assertTrue(DESTROY_DELETION + TEST_THE_REDO, getRootCompartment().getChildren().size() == 0);
- //assertTrue(DESTROY_DELETION + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() == 0);
- }
-
-
- /**
- * Test drop.
- *
- * @param type
- * the type
- */
- public void testDrop(IElementType type, EClass eClass) {
- //DROP
- assertTrue(DROP + INITIALIZATION_TEST, getRootCompartment().getChildren().size() == 0);
- //assertTrue(DROP + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
-
-
- DropObjectsRequest dropObjectsRequest = new DropObjectsRequest();
- ArrayList<Element> list = new ArrayList<Element>();
- for (Element element : getRootSemanticModel().getOwnedElements()) {
- if( element != null && element.eClass().equals(eClass)){
- list.add(element);
- }
- }
-
- dropObjectsRequest.setObjects(list);
- dropObjectsRequest.setLocation(new Point(40, 40));
- Command command = getRootCompartment().getCommand(dropObjectsRequest);
- assertNotNull(DROP + COMMAND_NULL, command);
- assertTrue(DROP + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(DROP + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- executeOnUIThread(command);
- assertTrue(DROP + TEST_THE_EXECUTION, getRootCompartment().getChildren().size() != 0);
- assertTrue(DROP + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() != 0);
- undoOnUIThread();
- assertTrue(DROP + TEST_THE_UNDO, getRootCompartment().getChildren().size() == 0);
- assertTrue(DROP + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() != 0);
- redoOnUIThread();
- assertTrue(DROP + TEST_THE_REDO, getRootCompartment().getChildren().size() != 0);
- assertTrue(DROP + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() != 0);
- }
-
-
- /**
- * Test change container.
- *
- * @param type
- * the type
- * @param containerType
- * the container type
- */
- public void testChangeContainer(IElementType type, IElementType containerType) {
- //CHANGE CONTAINER
- assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getRootCompartment().getChildren().size() == 1);
- assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
-
-
- Request requestcreation = CreateViewRequestFactory.getCreateShapeRequest(containerType, getRootCompartment().getDiagramPreferencesHint());
- Command command = getRootCompartment().getCommand(requestcreation);
- assertNotNull(CONTAINER_CREATION + COMMAND_NULL, command);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- executeOnUIThread(command);
- assertTrue(CONTAINER_CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 2);
- GraphicalEditPart containerEditPart = (GraphicalEditPart)getRootCompartment().getChildren().get(1);
- ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_ADD);
- changeBoundsRequest.setEditParts((EditPart)getRootCompartment().getChildren().get(0));
- changeBoundsRequest.setLocation(new Point(30, 30));
- ShapeCompartmentEditPart compartment = null;
- int index = 0;
- while(compartment == null && index < containerEditPart.getChildren().size()) {
- if((containerEditPart.getChildren().get(index)) instanceof ShapeCompartmentEditPart) {
- compartment = (ShapeCompartmentEditPart)(containerEditPart.getChildren().get(index));
- }
- index++;
- }
- assertTrue("Container not found", compartment != null);
-
-
- command = compartment.getCommand(changeBoundsRequest);
- assertNotNull(CHANGE_CONTAINER, command);
- assertTrue(CHANGE_CONTAINER + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(CHANGE_CONTAINER + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- executeOnUIThread(command);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, getRootView().getChildren().size() == 1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() == 1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, compartment.getChildren().size() == 1);
- undoOnUIThread();
- assertTrue(CHANGE_CONTAINER + TEST_THE_UNDO, getRootView().getChildren().size() == 2);
- assertTrue(CHANGE_CONTAINER + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 2);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, compartment.getChildren().size() == 0);
- redoOnUIThread();
- assertTrue(CHANGE_CONTAINER + TEST_THE_REDO, getRootView().getChildren().size() == 1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() == 1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, compartment.getChildren().size() == 1);
-
- }
-
- /**
- * Test to create a node.
- *
- * @param type
- * the type
- */
- public void testToCreateANode(IElementType type) {
-
- //CREATION
- assertTrue(CREATION + INITIALIZATION_TEST, getRootCompartment().getChildren().size() == 0);
- assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 0);
-
- CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootCompartment().getDiagramPreferencesHint());
- Command command = getRootCompartment().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);
- executeOnUIThread(command);
- assertTrue(CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 1);
- undoOnUIThread();
- assertTrue(CREATION + TEST_THE_UNDO, getRootView().getChildren().size() == 0);
- assertTrue(CREATION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 0);
- redoOnUIThread();
- assertTrue("CREATION: " + TEST_THE_REDO, getRootCompartment().getChildren().size() == 1);
-
- }
-
- protected abstract CreateViewRequest createViewRequestShapeContainer();
-
- /**
* @see org.eclipse.papyrus.diagram.clazz.test.canonical.AbstractPapyrusTestCase#setUp()
*
* @throws Exception
@@ -253,10 +46,11 @@ public abstract class TestChildNode extends org.eclipse.papyrus.diagram.tests.ca
requestcreation.setSize(new Dimension(500, 500));
Command command = getDiagramEditPart().getCommand(requestcreation);
assertNotNull(CONTAINER_CREATION + COMMAND_NULL, command);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ assertNotSame(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, UnexecutableCommand.INSTANCE, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
executeOnUIThread(command);
- assertTrue(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 1);
+ assertEquals(CREATION + INITIALIZATION_TEST, 1, getDiagramEditPart().getChildren().size());
+
GraphicalEditPart containerEditPart = (GraphicalEditPart)getDiagramEditPart().getChildren().get(0);
rootCompartment = null;
int index = 0;
@@ -266,9 +60,19 @@ public abstract class TestChildNode extends org.eclipse.papyrus.diagram.tests.ca
}
index++;
}
-
+
+ assertNotNull("There should be at least one container for the node tests", rootCompartment);
}
-
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected IGraphicalEditPart getContainerEditPart() {
+ return rootCompartment;
+ }
+
/**
* @see org.eclipse.papyrus.diagram.clazz.test.canonical.AbstractPapyrusTestCase#getRootView()
*
@@ -277,31 +81,6 @@ public abstract class TestChildNode extends org.eclipse.papyrus.diagram.tests.ca
@Override
protected View getRootView() {
- return (View)getRootCompartment().getModel();
- }
-
- /**
- * Test to manage child node.
- *
- * @param type
- * the type
- * @param containerType
- * the container type
- */
- public void testToManageChildNode(IElementType type, EClass eClass, IElementType containerType, boolean containerMove) {
- testToCreateANode(type);
- // the node is still present
- testDestroy(type);
- // the node has been destroyed, the UML element also
- undoOnUIThread();
- // the node and the UML element are present
- testViewDeletion(type);
- // The node has been deleted, the uml element is still present
- testDrop(type, eClass);
- // the node and element are present
- if(containerMove) {
- testChangeContainer(type, containerType);
- }
+ return (View)rootCompartment.getModel();
}
-
}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestNested.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestNested.java
new file mode 100644
index 00000000000..7d29dc5cac5
--- /dev/null
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestNested.java
@@ -0,0 +1,192 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Nizar GUEDIDI (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.diagram.tests.canonical;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart;
+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.uml2.uml.Element;
+
+public abstract class TestNested extends org.eclipse.papyrus.diagram.tests.canonical.AbstractPapyrusTestCase {
+
+ /** The top node. */
+ protected GraphicalEditPart topNode;
+
+ /** The Child node. */
+ protected GraphicalEditPart childNode;
+
+ /**
+ * Test to create a nested classifier node.
+ *
+ * @param type
+ * the type
+ * @param containerType
+ * the container type
+ */
+ public void testToCreateAChildLabel(IElementType type, int containerType) {
+ ListCompartmentEditPart compartment = null;
+ int index = 0;
+
+ while(compartment == null && index < getChildEditPart().getChildren().size()) {
+ if((getChildEditPart().getChildren().get(index)) instanceof ListCompartmentEditPart && (((View)((ListCompartmentEditPart)(getChildEditPart().getChildren().get(index))).getModel()).getType().equals("" + containerType))) {
+ compartment = (ListCompartmentEditPart)(getChildEditPart().getChildren().get(index));
+ }
+ index++;
+ }
+ assertTrue("Container not found", compartment != null);
+ //CREATION
+ assertTrue(CREATION + INITIALIZATION_TEST, compartment.getChildren().size() == 0);
+ assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModelchild().getOwnedElements().size() == 0);
+
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getDiagramEditPart().getDiagramPreferencesHint());
+ Command command = compartment.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, compartment.getChildren().size() == 1);
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, compartment.getChildren().size() == 0);
+ assertTrue(CREATION + TEST_THE_UNDO, ((Element)((View)getChildEditPart().getModel()).getElement()).getOwnedElements().size() == 0);
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
+ assertTrue("CREATION: " + TEST_THE_REDO, compartment.getChildren().size() == 1);
+
+ }
+
+ /**
+ * Test to create a node.
+ *
+ * @param type
+ * the type
+ * @param containerType
+ * the container type
+ */
+ public void testToCreateANode(IElementType type, int containerType) {
+ ResizableCompartmentEditPart compartment = null;
+ int index = 0;
+ while(compartment == null && index < getTopEditPart().getChildren().size()) {
+ if((getTopEditPart().getChildren().get(index)) instanceof ResizableCompartmentEditPart) {
+ if((((View)((ResizableCompartmentEditPart)(getTopEditPart().getChildren().get(index))).getModel()).getType().equals("" + containerType))) {
+ compartment = (ResizableCompartmentEditPart)(getTopEditPart().getChildren().get(index));
+ }
+ }
+ index++;
+ }
+ assertTrue("Container not found", compartment != null);
+ //CREATION
+ assertTrue(CREATION + INITIALIZATION_TEST, compartment.getChildren().size() == 0);
+ assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 0);
+
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getDiagramEditPart().getDiagramPreferencesHint());
+ Command command = compartment.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, compartment.getChildren().size() == 1);
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, compartment.getChildren().size() == 0);
+ assertTrue(CREATION + TEST_THE_UNDO, ((Element)((View)getTopEditPart().getModel()).getElement()).getOwnedElements().size() == 0);
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
+ assertTrue("CREATION: " + TEST_THE_REDO, compartment.getChildren().size() == 1);
+ childNode = (GraphicalEditPart)compartment.getChildren().get(0);
+
+ }
+
+ /**
+ * Gets the root semantic modelchild.
+ *
+ * @return the root semantic modelchild
+ */
+ private Element getRootSemanticModelchild() {
+ return (Element)((View)getChildEditPart().getModel()).getElement();
+ }
+
+ /**
+ * Test to create a top node.
+ *
+ * @param type
+ * the type
+ */
+ public void testToCreateATopNode(IElementType type) {
+
+ //CREATION
+ assertTrue(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 0);
+ assertTrue(CREATION + INITIALIZATION_TEST, ((Element)((View)getDiagramEditPart().getModel()).getElement()).getOwnedElements().size() == 0);
+
+ 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);
+ topNode = (GraphicalEditPart)getDiagramEditPart().getChildren().get(0);
+ }
+
+ /**
+ * Gets the top edit part.
+ *
+ * @return the top edit part
+ */
+ public GraphicalEditPart getTopEditPart() {
+ return topNode;
+ }
+
+ /**
+ * Gets the Child edit part.
+ *
+ * @return the Child edit part
+ */
+ public GraphicalEditPart getChildEditPart() {
+ return childNode;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.diagram.clazz.test.canonical.AbstractPapyrusTestCase#getRootSemanticModel()
+ *
+ * @return
+ */
+
+ @Override
+ protected Element getRootSemanticModel() {
+ return (Element)((View)getTopEditPart().getModel()).getElement();
+ }
+
+ /**
+ * Test to manage top node.
+ *
+ * @param type
+ * the type
+ * @param containerType
+ * the container type
+ */
+ public void testToManageTopNode(IElementType parentNodeType, IElementType topNodeType, IElementType type, int containerChilType, int containerType) {
+
+ //Parent Node
+ testToCreateATopNode(parentNodeType);
+ //Top Node
+ testToCreateANode(topNodeType, containerChilType);
+ //Nested classifier
+ testToCreateAChildLabel(type, containerType);
+
+ }
+
+}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestTopNode.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestTopNode.java
index 81ce9cb3685..809d0dc4812 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestTopNode.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/TestTopNode.java
@@ -13,250 +13,35 @@
*****************************************************************************/
package org.eclipse.papyrus.diagram.tests.canonical;
-import java.util.ArrayList;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
-import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
-import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.uml2.uml.Element;
-
-
-
-// TODO: Auto-generated Javadoc
/**
* The Class TestTopNode.
*/
-public abstract class TestTopNode extends org.eclipse.papyrus.diagram.tests.canonical.AbstractPapyrusTestCase {
-
+public abstract class TestTopNode extends AbstractTestNode {
/**
- * Test view deletion.
- *
- * @param type
- * the type
+ * {@inheritDoc}
*/
- public void testViewDeletion(IElementType type) {
- //DELETION OF THE VIEW
- assertTrue(VIEW_DELETION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 1);
- assertTrue(VIEW_DELETION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
-
- Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
- Command command = ((GraphicalEditPart)getDiagramEditPart().getChildren().get(0)).getCommand(deleteViewRequest);
- assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
- assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
- assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, getDiagramEditPart().getChildren().size() == 0);
- assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() == 1);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
- assertTrue(VIEW_DELETION + TEST_THE_UNDO, getDiagramEditPart().getChildren().size() == 1);
- assertTrue(VIEW_DELETION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 1);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
- assertTrue(VIEW_DELETION + TEST_THE_REDO, getDiagramEditPart().getChildren().size() == 0);
- assertTrue(VIEW_DELETION + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() == 1);
-
+ @Override
+ protected IGraphicalEditPart getContainerEditPart() {
+ return getDiagramEditPart();
}
/**
- * Retrieves the TransactionalEditingDomain
- *
- * @return the editing domain (can be null)
+ * {@inheritDoc}
*/
- protected TransactionalEditingDomain getEditingDomain() {
- ServiceUtilsForActionHandlers serviceUtils = ServiceUtilsForActionHandlers.getInstance();
- TransactionalEditingDomain editingDomain = null;
- try {
- editingDomain = serviceUtils.getTransactionalEditingDomain();
-
- } catch (ServiceException e) {
- Activator.log.error(e);
- }
-
- return editingDomain;
+ @Override
+ protected View getRootView() {
+ return (View)getContainerEditPart().getModel();
}
-
+
/**
- * Test destroy.
- *
- * @param type
- * the type
+ * {@inheritDoc}
*/
- public void testDestroy(IElementType type) {
-
-
- //DESTROY SEMANTIC+ VIEW
- assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 1);
- assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
-
- Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
- Command command = ((GraphicalEditPart)getDiagramEditPart().getChildren().get(0)).getCommand(deleteViewRequest);
- assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
- assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- getDiagramEditPart().getDiagramEditDomain().getDiagramCommandStack().execute(command);
- assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, getDiagramEditPart().getChildren().size() == 0);
- assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() == 0);
-
-
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
- assertTrue(DESTROY_DELETION + TEST_THE_UNDO, getDiagramEditPart().getChildren().size() == 1);
- assertTrue(DESTROY_DELETION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 1);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
- assertTrue(DESTROY_DELETION + TEST_THE_REDO, getDiagramEditPart().getChildren().size() == 0);
- assertTrue(DESTROY_DELETION + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() == 0);
+ @Override
+ protected boolean isSemanticTest() {
+ return true;
}
-
-
- /**
- * Test drop.
- *
- * @param type
- * the type
- */
- public void testDrop(IElementType type) {
- //DROP
- assertTrue(DROP + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 0);
- assertTrue(DROP + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
-
-
- DropObjectsRequest dropObjectsRequest = new DropObjectsRequest();
- ArrayList<Element> list = new ArrayList<Element>();
- list.add(getRootSemanticModel().getOwnedElements().get(0));
- dropObjectsRequest.setObjects(list);
- dropObjectsRequest.setLocation(new Point(20, 20));
- Command command = getDiagramEditPart().getCommand(dropObjectsRequest);
- assertNotNull(DROP + COMMAND_NULL, command);
- assertTrue(DROP + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(DROP + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
- assertTrue(DROP + TEST_THE_EXECUTION, getDiagramEditPart().getChildren().size() != 0);
- assertTrue(DROP + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() != 0);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
- assertTrue(DROP + TEST_THE_UNDO, getDiagramEditPart().getChildren().size() == 0);
- assertTrue(DROP + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() != 0);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
- assertTrue(DROP + TEST_THE_REDO, getDiagramEditPart().getChildren().size() != 0);
- assertTrue(DROP + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() != 0);
- }
-
-
- /**
- * Test change container.
- *
- * @param type
- * the type
- * @param containerType
- * the container type
- */
- public void testChangeContainer(IElementType type, IElementType containerType) {
- //CHANGE CONTAINER
- assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 1);
- assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
-
-
- Request requestcreation = CreateViewRequestFactory.getCreateShapeRequest(containerType, getDiagramEditPart().getDiagramPreferencesHint());
- Command command = getDiagramEditPart().getCommand(requestcreation);
- assertNotNull(CONTAINER_CREATION + COMMAND_NULL, command);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
- assertTrue(CONTAINER_CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 2);
- GraphicalEditPart containerEditPart = (GraphicalEditPart)getDiagramEditPart().getChildren().get(1);
- ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_ADD);
- changeBoundsRequest.setEditParts((EditPart)getDiagramEditPart().getChildren().get(0));
- changeBoundsRequest.setLocation(new Point(30, 30));
- ShapeCompartmentEditPart compartment = null;
- int index = 0;
- while(compartment == null && index < containerEditPart.getChildren().size()) {
- if((containerEditPart.getChildren().get(index)) instanceof ShapeCompartmentEditPart) {
- compartment = (ShapeCompartmentEditPart)(containerEditPart.getChildren().get(index));
- }
- index++;
- }
- assertTrue("Container not found", compartment != null);
-
-
- command = compartment.getCommand(changeBoundsRequest);
- assertNotNull(CHANGE_CONTAINER, command);
- assertTrue(CHANGE_CONTAINER + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(CHANGE_CONTAINER + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, getRootView().getChildren().size() == 1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() == 1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, compartment.getChildren().size() == 1);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
- assertTrue(CHANGE_CONTAINER + TEST_THE_UNDO, getRootView().getChildren().size() == 2);
- assertTrue(CHANGE_CONTAINER + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 2);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, compartment.getChildren().size() == 0);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
- assertTrue(CHANGE_CONTAINER + TEST_THE_REDO, getRootView().getChildren().size() == 1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() == 1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, compartment.getChildren().size() == 1);
-
- }
-
- /**
- * Test to create a node.
- *
- * @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() == 0);
-
- 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);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
- assertTrue(CREATION + TEST_THE_UNDO, getRootView().getChildren().size() == 0);
- assertTrue(CREATION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 0);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
-
- assertTrue("CREATION: " + TEST_THE_REDO, getDiagramEditPart().getChildren().size() == 1);
-
- }
-
- /**
- * Test to manage top node.
- *
- * @param type
- * the type
- * @param containerType
- * the container type
- */
- public void testToManageTopNode(IElementType type, IElementType containerType) {
- int i = 0;
- testToCreateANode(type);
- testDestroy(type);
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
- testViewDeletion(type);
- testDrop(type);
- testChangeContainer(type, containerType);
- }
-
-
}

Back to the top