Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2015-01-19 09:11:46 +0000
committerGerrit Code Review @ Eclipse.org2015-01-19 09:11:46 +0000
commita2e0c824fb46f158dbd5b9ca5f1ca043712ced22 (patch)
treed2d633161ffa4c951faf318a2b700f4806f7222b
parent1543a0cb11cb4dd779108a394b6f9fa245116b1b (diff)
parent315b52b5a41d07e502a77545d7a17327bf59fb18 (diff)
downloadorg.eclipse.papyrus-a2e0c824fb46f158dbd5b9ca5f1ca043712ced22.tar.gz
org.eclipse.papyrus-a2e0c824fb46f158dbd5b9ca5f1ca043712ced22.tar.xz
org.eclipse.papyrus-a2e0c824fb46f158dbd5b9ca5f1ca043712ced22.zip
Merge "Bug 457351 - [All Diagrams] The behavior rules for all list compartments"
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/AllCanonicalTests.java5
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/ClassDiagramListCompartmentTestHelper.java56
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentIllegalElements.java173
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentNodesChildDuplicates.java159
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentPropertiesOperationsDrop.java193
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/AllCanonicalTests.java9
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/ComponentDiagramListCompartmentTestHelper.java55
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentIllegalElements.java61
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentNodeChildDuplicates.java62
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentPropertiesOperationsDrop.java66
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestListCompartmentHelper.java201
11 files changed, 919 insertions, 121 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/AllCanonicalTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/AllCanonicalTests.java
index 93b1d879550..c57ba43bb14 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/AllCanonicalTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/AllCanonicalTests.java
@@ -40,8 +40,11 @@ TestDropfunction.class,
TestStaticFeatureRepresentation.class,
//test nested classifier
TestClassDiagramNestedClassifier.class,
-//test list-compartment child duplicates
+//List Compartment child duplicates
TestListCompartmentNodesChildDuplicates.class,
+//List Compartment illegal elements
+TestListCompartmentIllegalElements.class,
+TestListCompartmentPropertiesOperationsDrop.class
})
public class AllCanonicalTests {
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/ClassDiagramListCompartmentTestHelper.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/ClassDiagramListCompartmentTestHelper.java
new file mode 100644
index 00000000000..1d89cc52db7
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/ClassDiagramListCompartmentTestHelper.java
@@ -0,0 +1,56 @@
+package org.eclipse.papyrus.uml.diagram.clazz.test.canonical;
+
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DefaultNamedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.common.part.UmlGmfDiagramEditor;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.TestListCompartmentHelper;
+
+public class ClassDiagramListCompartmentTestHelper extends TestListCompartmentHelper {
+
+ /**
+ * Constructor.
+ *
+ * @param diagramEditPart
+ * @param diagramEditor
+ */
+ public ClassDiagramListCompartmentTestHelper(DiagramEditPart diagramEditPart, UmlGmfDiagramEditor diagramEditor) {
+ super(diagramEditPart, diagramEditor);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.ListCompartmentTestHelper#getDefaultNamedElementVisualId()
+ *
+ * @return
+ */
+ @Override
+ protected int getDefaultNamedElementVisualId() {
+ return DefaultNamedElementEditPart.VISUAL_ID;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.ListCompartmentTestHelper#getElementType(int)
+ *
+ * @param childVID
+ * @return
+ */
+ @Override
+ protected IElementType getElementType(int childVID) {
+ return UMLElementTypes.getElementType(childVID);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.ListCompartmentTestHelper#getVisualID(org.eclipse.gmf.runtime.notation.View)
+ *
+ * @param view
+ * @return
+ */
+ @Override
+ protected int getVisualID(View view) {
+ return UMLVisualIDRegistry.getVisualID(view);
+ }
+
+} \ No newline at end of file
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentIllegalElements.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentIllegalElements.java
new file mode 100644
index 00000000000..096e038fd64
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentIllegalElements.java
@@ -0,0 +1,173 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.clazz.test.canonical;
+
+import org.eclipse.papyrus.junit.framework.classification.FailingTest;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassNestedClassifierCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentEditPart;
+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.DataTypeAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceNestedClassifierCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.OperationForClassEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.OperationForComponentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.OperationForDataTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.OperationForInterfaceEditpart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.OperationForPrimitiveTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForClassEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForComponentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyforDataTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyforPrimitiveTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.test.IClassDiagramTestsConstants;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.TestListCompartmentHelper;
+import org.junit.Test;
+
+/**
+ *
+ *
+ */
+public class TestListCompartmentIllegalElements extends AbstractPapyrusTestCase {
+
+ private TestListCompartmentHelper myHelper;
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getProjectName()
+ *
+ * @return
+ */
+ @Override
+ protected String getProjectName() {
+ return IClassDiagramTestsConstants.PROJECT_NAME;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getFileName()
+ *
+ * @return
+ */
+ @Override
+ protected String getFileName() {
+ return IClassDiagramTestsConstants.FILE_NAME;
+ }
+
+ @FailingTest
+ public void testClassInClassAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop(ClassEditPart.VISUAL_ID, ClassAttributeCompartmentEditPart.VISUAL_ID, ClassEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testClassInClassOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop(ClassEditPart.VISUAL_ID, ClassOperationCompartmentEditPart.VISUAL_ID, ClassEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInClassOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(ClassEditPart.VISUAL_ID, ClassOperationCompartmentEditPart.VISUAL_ID, PropertyForClassEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInClassAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(ClassEditPart.VISUAL_ID, ClassAttributeCompartmentEditPart.VISUAL_ID, OperationForClassEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInClassNestedCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, OperationForClassEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInClassNestedCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, PropertyForClassEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInInterfaceOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(InterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, PropertyForInterfaceEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInInterfaceAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(InterfaceEditPart.VISUAL_ID, InterfaceAttributeCompartmentEditPart.VISUAL_ID, OperationForInterfaceEditpart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInInterfaceNestedCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, OperationForInterfaceEditpart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInInterfaceNestedCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, PropertyForInterfaceEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInComponentOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(ComponentEditPart.VISUAL_ID, ComponentOperationCompartmentEditPart.VISUAL_ID, PropertyForComponentEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInComponentAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(ComponentEditPart.VISUAL_ID, ComponentAttributeCompartmentEditPart.VISUAL_ID, OperationForComponentEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInComponentNestedCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, OperationForComponentEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInComponentNestedCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, PropertyForComponentEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInDataTypeOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(DataTypeEditPart.VISUAL_ID, DataTypeOperationCompartmentEditPart.VISUAL_ID, PropertyforDataTypeEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInDataTypeAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(DataTypeEditPart.VISUAL_ID, DataTypeAttributeCompartmentEditPart.VISUAL_ID, OperationForDataTypeEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInPrimitiveTypeOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(PrimitiveTypeEditPart.VISUAL_ID, PrimitiveTypeOperationCompartmentEditPart.VISUAL_ID, PropertyforPrimitiveTypeEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInPrimitiveTypeAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(PrimitiveTypeEditPart.VISUAL_ID, PrimitiveTypeAttributeCompartmentEditPart.VISUAL_ID, OperationForPrimitiveTypeEditPart.VISUAL_ID);
+ }
+
+ private TestListCompartmentHelper getHelper() {
+ if (myHelper == null) {
+ myHelper = new ClassDiagramListCompartmentTestHelper(getDiagramEditPart(), diagramEditor);
+ }
+ return myHelper;
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentNodesChildDuplicates.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentNodesChildDuplicates.java
index 45018ff32c5..d3e227826b9 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentNodesChildDuplicates.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentNodesChildDuplicates.java
@@ -13,23 +13,7 @@
package org.eclipse.papyrus.uml.diagram.clazz.test.canonical;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-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.papyrus.commands.ICreationCommand;
-import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
import org.eclipse.papyrus.junit.framework.classification.FailingTest;
-import org.eclipse.papyrus.uml.diagram.clazz.CreateClassDiagramCommand;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassAttributeCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassOperationCompartmentEditPart;
@@ -44,7 +28,6 @@ import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentOperationCompar
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeAttributeCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DefaultNamedElementEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.EnumerationEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.EnumerationEnumerationLiteralCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.EnumerationLiteralEditPart;
@@ -88,10 +71,8 @@ import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ReceptionEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ReceptionInInterfaceEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.SignalAttributeCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.SignalEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.clazz.test.IClassDiagramTestsConstants;
-import org.junit.Assert;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.TestListCompartmentHelper;
import org.junit.Test;
/**
@@ -99,6 +80,8 @@ import org.junit.Test;
*/
public class TestListCompartmentNodesChildDuplicates extends AbstractPapyrusTestCase {
+ private TestListCompartmentHelper myHelper;
+
/**
* @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getProjectName()
*
@@ -119,243 +102,185 @@ public class TestListCompartmentNodesChildDuplicates extends AbstractPapyrusTest
return IClassDiagramTestsConstants.FILE_NAME;
}
- @Override
- protected ICreationCommand getDiagramCommandCreation() {
- return new CreateClassDiagramCommand();
- }
-
@Test
public void testAssociationClassVsProperty() throws Exception {
- checkDuplicate(AssociationClassEditPart.VISUAL_ID, AssociationClassAttributeCompartmentEditPart.VISUAL_ID, PropertyForComponentEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(AssociationClassEditPart.VISUAL_ID, AssociationClassAttributeCompartmentEditPart.VISUAL_ID, PropertyForComponentEditPart.VISUAL_ID);
}
@Test
public void testAssociationClassVsOperation() throws Exception {
- checkDuplicate(AssociationClassEditPart.VISUAL_ID, AssociationClassOperationCompartmentEditPart.VISUAL_ID, OperationForComponentEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(AssociationClassEditPart.VISUAL_ID, AssociationClassOperationCompartmentEditPart.VISUAL_ID, OperationForComponentEditPart.VISUAL_ID);
}
@Test
public void testClassVsProperty() throws Exception {
- checkDuplicate(ClassEditPart.VISUAL_ID, ClassAttributeCompartmentEditPart.VISUAL_ID, PropertyForClassEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ClassEditPart.VISUAL_ID, ClassAttributeCompartmentEditPart.VISUAL_ID, PropertyForClassEditPart.VISUAL_ID);
}
@Test
public void testClassVsOperation() throws Exception {
- checkDuplicate(ClassEditPart.VISUAL_ID, ClassOperationCompartmentEditPart.VISUAL_ID, OperationForClassEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ClassEditPart.VISUAL_ID, ClassOperationCompartmentEditPart.VISUAL_ID, OperationForClassEditPart.VISUAL_ID);
}
@Test
public void testClassVsClass() throws Exception {
- checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, ClassEditPart.VISUAL_ID, NestedClassForClassEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, ClassEditPart.VISUAL_ID, NestedClassForClassEditPart.VISUAL_ID);
}
@Test
public void testClassVsDataType() throws Exception {
- checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, DataTypeEditPart.VISUAL_ID, NestedDataTypeForClassEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, DataTypeEditPart.VISUAL_ID, NestedDataTypeForClassEditPart.VISUAL_ID);
}
@Test
public void testClassVsEnumeration() throws Exception {
- checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, EnumerationEditPart.VISUAL_ID, NestedEnumerationForClassEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, EnumerationEditPart.VISUAL_ID, NestedEnumerationForClassEditPart.VISUAL_ID);
}
@Test
public void testClassVsInterface() throws Exception {
- checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, InterfaceEditPart.VISUAL_ID, NestedInterfaceForClassEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, InterfaceEditPart.VISUAL_ID, NestedInterfaceForClassEditPart.VISUAL_ID);
}
@Test
public void testClassVsReception() throws Exception {
- checkDuplicate(ClassEditPart.VISUAL_ID, ClassOperationCompartmentEditPart.VISUAL_ID, ReceptionEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ClassEditPart.VISUAL_ID, ClassOperationCompartmentEditPart.VISUAL_ID, ReceptionEditPart.VISUAL_ID);
}
@Test
public void testClassVsPrimitiveType() throws Exception {
- checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, PrimitiveTypeEditPart.VISUAL_ID, NestedPrimitiveTypeForClassEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, PrimitiveTypeEditPart.VISUAL_ID, NestedPrimitiveTypeForClassEditPart.VISUAL_ID);
}
@Test
public void testClassVsSignal() throws Exception {
- checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, SignalEditPart.VISUAL_ID, NestedSignalForClassEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ClassEditPart.VISUAL_ID, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, SignalEditPart.VISUAL_ID, NestedSignalForClassEditPart.VISUAL_ID);
}
@Test
public void testComponentVsClass() throws Exception {
- checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, ClassEditPart.VISUAL_ID, NestedClassForComponentEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, ClassEditPart.VISUAL_ID, NestedClassForComponentEditPart.VISUAL_ID);
}
@Test
public void testComponentVsDataType() throws Exception {
- checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, DataTypeEditPart.VISUAL_ID, NestedDataTypeForComponentEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, DataTypeEditPart.VISUAL_ID, NestedDataTypeForComponentEditPart.VISUAL_ID);
}
@Test
public void testComponentVsEnumeration() throws Exception {
- checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, EnumerationEditPart.VISUAL_ID, NestedEnumerationForComponentEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, EnumerationEditPart.VISUAL_ID, NestedEnumerationForComponentEditPart.VISUAL_ID);
}
@Test
public void testComponentVsInterface() throws Exception {
- checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, InterfaceEditPart.VISUAL_ID, NestedInterfaceForComponentEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, InterfaceEditPart.VISUAL_ID, NestedInterfaceForComponentEditPart.VISUAL_ID);
}
@Test
public void testComponentVsPrimitiveType() throws Exception {
- checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, PrimitiveTypeEditPart.VISUAL_ID, NestedPrimitiveTypeForComponentEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, PrimitiveTypeEditPart.VISUAL_ID, NestedPrimitiveTypeForComponentEditPart.VISUAL_ID);
}
@Test
public void testComponentVsSignal() throws Exception {
- checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, SignalEditPart.VISUAL_ID, NestedSignalForComponentEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, SignalEditPart.VISUAL_ID, NestedSignalForComponentEditPart.VISUAL_ID);
}
@Test
public void testComponentVsOperation() throws Exception {
- checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentOperationCompartmentEditPart.VISUAL_ID, OperationForComponentEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentOperationCompartmentEditPart.VISUAL_ID, OperationForComponentEditPart.VISUAL_ID);
}
@Test
public void testComponentVsReception() throws Exception {
- checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentOperationCompartmentEditPart.VISUAL_ID, ReceptionEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentOperationCompartmentEditPart.VISUAL_ID, ReceptionEditPart.VISUAL_ID);
}
@Test
public void testComponentVsProperty() throws Exception {
- checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentAttributeCompartmentEditPart.VISUAL_ID, PropertyForComponentEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(ComponentEditPart.VISUAL_ID, ComponentAttributeCompartmentEditPart.VISUAL_ID, PropertyForComponentEditPart.VISUAL_ID);
}
@Test
public void testDataTypeVsProperty() throws Exception {
- checkDuplicate(DataTypeEditPart.VISUAL_ID, DataTypeAttributeCompartmentEditPart.VISUAL_ID, PropertyforDataTypeEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(DataTypeEditPart.VISUAL_ID, DataTypeAttributeCompartmentEditPart.VISUAL_ID, PropertyforDataTypeEditPart.VISUAL_ID);
}
@Test
public void testDataTypeVsOperation() throws Exception {
- checkDuplicate(DataTypeEditPart.VISUAL_ID, DataTypeOperationCompartmentEditPart.VISUAL_ID, OperationForDataTypeEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(DataTypeEditPart.VISUAL_ID, DataTypeOperationCompartmentEditPart.VISUAL_ID, OperationForDataTypeEditPart.VISUAL_ID);
}
@Test
public void testInterfaceVsOperation() throws Exception {
- checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, OperationForInterfaceEditpart.VISUAL_ID);
+ getHelper().checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, OperationForInterfaceEditpart.VISUAL_ID);
}
@Test
public void testInterfaceVsReception() throws Exception {
- checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, ReceptionInInterfaceEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, ReceptionInInterfaceEditPart.VISUAL_ID);
}
@Test
public void testInterfaceVsClass() throws Exception {
- checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, ClassEditPart.VISUAL_ID, NestedClassForInterfaceEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, ClassEditPart.VISUAL_ID, NestedClassForInterfaceEditPart.VISUAL_ID);
}
@Test
public void testInterfaceVsDataType() throws Exception {
- checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, DataTypeEditPart.VISUAL_ID, NestedDataTypeForInterfaceEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, DataTypeEditPart.VISUAL_ID, NestedDataTypeForInterfaceEditPart.VISUAL_ID);
}
@Test
public void testInterfaceVsEnumeration() throws Exception {
- checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, EnumerationEditPart.VISUAL_ID, NestedEnumerationForInterfaceEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, EnumerationEditPart.VISUAL_ID, NestedEnumerationForInterfaceEditPart.VISUAL_ID);
}
@Test
public void testInterfaceVsInterface() throws Exception {
- checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, InterfaceEditPart.VISUAL_ID, NestedInterfaceForInterfaceEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, InterfaceEditPart.VISUAL_ID, NestedInterfaceForInterfaceEditPart.VISUAL_ID);
}
@Test
public void testInterfaceVsPrimitiveType() throws Exception {
- checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, PrimitiveTypeEditPart.VISUAL_ID, NestedPrimitiveTypeForInterfaceEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, PrimitiveTypeEditPart.VISUAL_ID, NestedPrimitiveTypeForInterfaceEditPart.VISUAL_ID);
}
@Test
public void testInterfaceVsSignal() throws Exception {
- checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, SignalEditPart.VISUAL_ID, NestedSignalForInterfaceEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, SignalEditPart.VISUAL_ID, NestedSignalForInterfaceEditPart.VISUAL_ID);
}
@Test
public void testInterfaceVsProperty() throws Exception {
- checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceAttributeCompartmentEditPart.VISUAL_ID, PropertyForInterfaceEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(InterfaceEditPart.VISUAL_ID, InterfaceAttributeCompartmentEditPart.VISUAL_ID, PropertyForInterfaceEditPart.VISUAL_ID);
}
@Test
public void testPrimitiveTypeVsProperty() throws Exception {
- checkDuplicate(PrimitiveTypeEditPart.VISUAL_ID, PrimitiveTypeAttributeCompartmentEditPart.VISUAL_ID, PropertyforPrimitiveTypeEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(PrimitiveTypeEditPart.VISUAL_ID, PrimitiveTypeAttributeCompartmentEditPart.VISUAL_ID, PropertyforPrimitiveTypeEditPart.VISUAL_ID);
}
@Test
public void testPrimitiveTypeVsOperation() throws Exception {
- checkDuplicate(PrimitiveTypeEditPart.VISUAL_ID, PrimitiveTypeOperationCompartmentEditPart.VISUAL_ID, OperationForPrimitiveTypeEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(PrimitiveTypeEditPart.VISUAL_ID, PrimitiveTypeOperationCompartmentEditPart.VISUAL_ID, OperationForPrimitiveTypeEditPart.VISUAL_ID);
}
@Test
public void testSignalVsProperty() throws Exception {
- checkDuplicate(SignalEditPart.VISUAL_ID, SignalAttributeCompartmentEditPart.VISUAL_ID, PropertyForSignalEditPart.VISUAL_ID);
+ getHelper().checkDuplicate(SignalEditPart.VISUAL_ID, SignalAttributeCompartmentEditPart.VISUAL_ID, PropertyForSignalEditPart.VISUAL_ID);
}
@FailingTest
- @Test
public void testEnumerationVsEnumerationLiteral() throws Exception {
- checkDuplicate(EnumerationEditPart.VISUAL_ID, EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID, EnumerationLiteralEditPart.VISUAL_ID);
- }
-
- private void checkDuplicate(int parent, int parentContainer, int child) {
- checkDuplicate(parent, parentContainer, child, 0);
+ getHelper().checkDuplicate(EnumerationEditPart.VISUAL_ID, EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID, EnumerationLiteralEditPart.VISUAL_ID);
}
- private void checkDuplicate(int parent, int parentContainer, int child, int nestedChild) {
- IGraphicalEditPart parentEP = createChild(parent, getDiagramEditPart(), 0);
- IGraphicalEditPart targetEP = findChildBySemanticHint(parentEP, parentContainer);
- IGraphicalEditPart dndEP = createChild(nestedChild > 0 ? nestedChild : child, targetEP, 0);
- {
- Command ddCommand = createDropCommand(dndEP, getDiagramEditPart());
- Assert.assertTrue(ddCommand.canExecute());
- executeOnUIThread(ddCommand);
+ private TestListCompartmentHelper getHelper() {
+ if (myHelper == null) {
+ myHelper = new ClassDiagramListCompartmentTestHelper(getDiagramEditPart(), diagramEditor);
}
- IGraphicalEditPart canvasDnDEP = findChildBySemanticHint(getDiagramEditPart(), nestedChild > 0 ? child : DefaultNamedElementEditPart.VISUAL_ID);
- {
- Command ddCommand = createDropCommand(canvasDnDEP, targetEP);
- Assert.assertFalse(canvasDnDEP.getClass().getName() + " can't be dropped to the " + targetEP.getClass().getName() + " due the duplication behavior rule.", ddCommand.canExecute());
- }
- }
-
- private Command createDropCommand(IGraphicalEditPart child, IGraphicalEditPart newParent) {
- CompoundCommand c = new CompoundCommand();
- ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DRAG);
- changeBoundsRequest.setEditParts(child);
- changeBoundsRequest.setLocation(new Point(15, 15));
- c.add(child.getCommand(changeBoundsRequest));
- getDiagramEditPart().getEditingDomain().getCommandStack().execute(new GEFtoEMFCommandWrapper(c));
- changeBoundsRequest.setType(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DROP);
- c.add(newParent.getCommand(changeBoundsRequest));
- return c;
- }
-
- private IGraphicalEditPart createChild(int childVID, IGraphicalEditPart container, int number) {
- final IElementType childType = UMLElementTypes.getElementType(childVID);
- final CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(childType, container.getDiagramPreferencesHint());
- requestcreation.setSize(new Dimension(1, 1));
- requestcreation.setLocation(new Point(10, 10));
- Command cmd = container.getCommand(requestcreation);
- executeOnUIThread(cmd);
- return findChild(container, childVID, number);
- }
-
- private IGraphicalEditPart findChild(IGraphicalEditPart parent, int vid, int number) {
- List<?> children = parent.getChildren();
- if (number > children.size() - 1) {
- Assert.fail("Parent " + parent + ", type " + parent.getNotationView() + " hasn't less children then " + number);
- }
- IGraphicalEditPart childEP = (IGraphicalEditPart) children.get(number);
- assertNotNull("Parent " + parent + ", type " + parent.getNotationView() + " looking for: " + vid, childEP);
- Assert.assertEquals("Parent " + parent + ", type " + parent.getNotationView() + " looking for: " + vid, UMLVisualIDRegistry.getVisualID(childEP.getNotationView()), vid);
- return childEP;
- }
-
- private IGraphicalEditPart findChildBySemanticHint(IGraphicalEditPart parent, int vid) {
- IGraphicalEditPart childEP = parent.getChildBySemanticHint(Integer.toString(vid));
- assertNotNull("Parent " + parent + ", type " + parent.getNotationView() + " looking for: " + vid, childEP);
- return childEP;
+ return myHelper;
}
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentPropertiesOperationsDrop.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentPropertiesOperationsDrop.java
new file mode 100644
index 00000000000..a59c1d1a254
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestListCompartmentPropertiesOperationsDrop.java
@@ -0,0 +1,193 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.clazz.test.canonical;
+
+import org.eclipse.papyrus.junit.framework.classification.FailingTest;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.OperationForClassEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.OperationForComponentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.OperationForDataTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.OperationForInterfaceEditpart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.OperationForPrimitiveTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForClassEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForComponentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForSignalEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyforDataTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyforPrimitiveTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.SignalAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.SignalEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.test.IClassDiagramTestsConstants;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.TestListCompartmentHelper;
+import org.junit.Test;
+
+/**
+ *
+ *
+ */
+public class TestListCompartmentPropertiesOperationsDrop extends AbstractPapyrusTestCase {
+
+ private TestListCompartmentHelper myHelper;
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getProjectName()
+ *
+ * @return
+ */
+ @Override
+ protected String getProjectName() {
+ return IClassDiagramTestsConstants.PROJECT_NAME;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getFileName()
+ *
+ * @return
+ */
+ @Override
+ protected String getFileName() {
+ return IClassDiagramTestsConstants.FILE_NAME;
+ }
+
+ @FailingTest
+ public void testPropertyInClassAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(ClassEditPart.VISUAL_ID, ClassAttributeCompartmentEditPart.VISUAL_ID, PropertyForClassEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testPropertyInInterfaceAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(InterfaceEditPart.VISUAL_ID, InterfaceAttributeCompartmentEditPart.VISUAL_ID, PropertyForInterfaceEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testPropertyInDataTypeAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(DataTypeEditPart.VISUAL_ID, DataTypeAttributeCompartmentEditPart.VISUAL_ID, PropertyforDataTypeEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testPropertyInComponentAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(ComponentEditPart.VISUAL_ID, ComponentAttributeCompartmentEditPart.VISUAL_ID, PropertyForComponentEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testPropertyInPrimitiveTypeAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(PrimitiveTypeEditPart.VISUAL_ID, PrimitiveTypeAttributeCompartmentEditPart.VISUAL_ID, PropertyforPrimitiveTypeEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testPropertyInSignalAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(SignalEditPart.VISUAL_ID, SignalAttributeCompartmentEditPart.VISUAL_ID, PropertyForSignalEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testOperationInClassOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(ClassEditPart.VISUAL_ID, ClassOperationCompartmentEditPart.VISUAL_ID, OperationForClassEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testOperationInInterfaceOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(InterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, OperationForInterfaceEditpart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testOperationInDataTypeOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(DataTypeEditPart.VISUAL_ID, DataTypeOperationCompartmentEditPart.VISUAL_ID, OperationForDataTypeEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testOperationInComponentOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(ComponentEditPart.VISUAL_ID, ComponentOperationCompartmentEditPart.VISUAL_ID, OperationForComponentEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testOperationInPrimitiveTypeOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(PrimitiveTypeEditPart.VISUAL_ID, PrimitiveTypeOperationCompartmentEditPart.VISUAL_ID, OperationForPrimitiveTypeEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInClassDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(ClassEditPart.VISUAL_ID, ClassAttributeCompartmentEditPart.VISUAL_ID, PropertyForClassEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInInterfaceDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(InterfaceEditPart.VISUAL_ID, InterfaceAttributeCompartmentEditPart.VISUAL_ID, PropertyForInterfaceEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInDataTypeDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(DataTypeEditPart.VISUAL_ID, DataTypeAttributeCompartmentEditPart.VISUAL_ID, PropertyforDataTypeEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInComponentDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(ComponentEditPart.VISUAL_ID, ComponentAttributeCompartmentEditPart.VISUAL_ID, PropertyForComponentEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInPrimitiveTypeDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(PrimitiveTypeEditPart.VISUAL_ID, PrimitiveTypeAttributeCompartmentEditPart.VISUAL_ID, PropertyforPrimitiveTypeEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInSignalDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(SignalEditPart.VISUAL_ID, SignalAttributeCompartmentEditPart.VISUAL_ID, PropertyForSignalEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInClassDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(ClassEditPart.VISUAL_ID, ClassOperationCompartmentEditPart.VISUAL_ID, OperationForClassEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInInterfaceDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(InterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, OperationForInterfaceEditpart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInDataTypeDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(DataTypeEditPart.VISUAL_ID, DataTypeOperationCompartmentEditPart.VISUAL_ID, OperationForDataTypeEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInComponentDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(ComponentEditPart.VISUAL_ID, ComponentOperationCompartmentEditPart.VISUAL_ID, OperationForComponentEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInPrimitiveTypeDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(PrimitiveTypeEditPart.VISUAL_ID, PrimitiveTypeOperationCompartmentEditPart.VISUAL_ID, OperationForPrimitiveTypeEditPart.VISUAL_ID);
+ }
+
+ private TestListCompartmentHelper getHelper() {
+ if (myHelper == null) {
+ myHelper = new ClassDiagramListCompartmentTestHelper(getDiagramEditPart(), diagramEditor);
+ }
+ return myHelper;
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/AllCanonicalTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/AllCanonicalTests.java
index 98b0022567b..8a65f6431e2 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/AllCanonicalTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/AllCanonicalTests.java
@@ -36,9 +36,12 @@ TestComponentDiagramLinkOwnedBySource.class,
// CommentLink
TestComponentDiagramCommentLink.class,
// Constraint Link
-TestComponentDiagramConstraintLink.class
-
-
+TestComponentDiagramConstraintLink.class,
+// List compartment duplicates
+TestListCompartmentNodeChildDuplicates.class,
+// List Compartment Illegal Elements
+TestListCompartmentIllegalElements.class,
+TestListCompartmentPropertiesOperationsDrop.class
// End
})
public class AllCanonicalTests {
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/ComponentDiagramListCompartmentTestHelper.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/ComponentDiagramListCompartmentTestHelper.java
new file mode 100644
index 00000000000..98f913a08d7
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/ComponentDiagramListCompartmentTestHelper.java
@@ -0,0 +1,55 @@
+package org.eclipse.papyrus.uml.diagram.component.test.canonical;
+
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.part.UmlGmfDiagramEditor;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.DefaultNamedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.component.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.component.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.TestListCompartmentHelper;
+
+public class ComponentDiagramListCompartmentTestHelper extends TestListCompartmentHelper {
+
+ /**
+ * Constructor.
+ *
+ * @param diagramEditPart
+ * @param diagramEditor
+ */
+ public ComponentDiagramListCompartmentTestHelper(DiagramEditPart diagramEditPart, UmlGmfDiagramEditor diagramEditor) {
+ super(diagramEditPart, diagramEditor);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.ListCompartmentTestHelper#getDefaultNamedElementVisualId()
+ *
+ * @return
+ */
+ @Override
+ protected int getDefaultNamedElementVisualId() {
+ return DefaultNamedElementEditPart.VISUAL_ID;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.ListCompartmentTestHelper#getElementType(int)
+ *
+ * @param childVID
+ * @return
+ */
+ @Override
+ protected IElementType getElementType(int childVID) {
+ return UMLElementTypes.getElementType(childVID);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.ListCompartmentTestHelper#getVisualID(org.eclipse.gmf.runtime.notation.View)
+ *
+ * @param view
+ * @return
+ */
+ @Override
+ protected int getVisualID(View view) {
+ return UMLVisualIDRegistry.getVisualID(view);
+ }
+} \ No newline at end of file
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentIllegalElements.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentIllegalElements.java
new file mode 100644
index 00000000000..e739079b386
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentIllegalElements.java
@@ -0,0 +1,61 @@
+package org.eclipse.papyrus.uml.diagram.component.test.canonical;
+
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.InterfaceAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.InterfaceOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.OperationForInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.PropertyForInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.ReceptionInInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.RectangleInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.test.IComponentDiagramTestsConstants;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.TestListCompartmentHelper;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TestListCompartmentIllegalElements extends AbstractPapyrusTestCase {
+
+ private TestListCompartmentHelper myHelper;
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getProjectName()
+ *
+ * @return
+ */
+ @Override
+ protected String getProjectName() {
+ return IComponentDiagramTestsConstants.PROJECT_NAME;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getFileName()
+ *
+ * @return
+ */
+ @Override
+ protected String getFileName() {
+ return IComponentDiagramTestsConstants.FILE_NAME;
+ }
+
+ @Test
+ public void testPropertyInInterfaceOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(RectangleInterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, PropertyForInterfaceEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInInterfaceAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(RectangleInterfaceEditPart.VISUAL_ID, InterfaceAttributeCompartmentEditPart.VISUAL_ID, OperationForInterfaceEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testReceptionInInterfaceAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableChildCreate(RectangleInterfaceEditPart.VISUAL_ID, InterfaceAttributeCompartmentEditPart.VISUAL_ID, ReceptionInInterfaceEditPart.VISUAL_ID);
+ }
+
+ private TestListCompartmentHelper getHelper() {
+ if (myHelper == null) {
+ myHelper = new ComponentDiagramListCompartmentTestHelper(getDiagramEditPart(), diagramEditor);
+ }
+ return myHelper;
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentNodeChildDuplicates.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentNodeChildDuplicates.java
new file mode 100644
index 00000000000..714a4298c47
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentNodeChildDuplicates.java
@@ -0,0 +1,62 @@
+package org.eclipse.papyrus.uml.diagram.component.test.canonical;
+
+import org.eclipse.papyrus.junit.framework.classification.FailingTest;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.InterfaceAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.InterfaceOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.OperationForInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.PropertyForInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.ReceptionInInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.RectangleInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.test.IComponentDiagramTestsConstants;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.TestListCompartmentHelper;
+
+/**
+ *
+ */
+public class TestListCompartmentNodeChildDuplicates extends AbstractPapyrusTestCase {
+
+ private TestListCompartmentHelper myHelper;
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getProjectName()
+ *
+ * @return
+ */
+ @Override
+ protected String getProjectName() {
+ return IComponentDiagramTestsConstants.PROJECT_NAME;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getFileName()
+ *
+ * @return
+ */
+ @Override
+ protected String getFileName() {
+ return IComponentDiagramTestsConstants.FILE_NAME;
+ }
+
+ @FailingTest
+ public void testInterfaceVsOperation() throws Exception {
+ getHelper().checkDuplicate(RectangleInterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, OperationForInterfaceEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testInterfaceVsProperty() throws Exception {
+ getHelper().checkDuplicate(RectangleInterfaceEditPart.VISUAL_ID, InterfaceAttributeCompartmentEditPart.VISUAL_ID, PropertyForInterfaceEditPart.VISUAL_ID);
+ }
+
+
+ @FailingTest
+ public void testInterfaceVsReception() throws Exception {
+ getHelper().checkDuplicate(RectangleInterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, ReceptionInInterfaceEditPart.VISUAL_ID);
+ }
+
+ private TestListCompartmentHelper getHelper() {
+ if (myHelper == null) {
+ myHelper = new ComponentDiagramListCompartmentTestHelper(getDiagramEditPart(), diagramEditor);
+ }
+ return myHelper;
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentPropertiesOperationsDrop.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentPropertiesOperationsDrop.java
new file mode 100644
index 00000000000..907bf86ae18
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/canonical/TestListCompartmentPropertiesOperationsDrop.java
@@ -0,0 +1,66 @@
+package org.eclipse.papyrus.uml.diagram.component.test.canonical;
+
+import org.eclipse.papyrus.junit.framework.classification.FailingTest;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.InterfaceAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.InterfaceOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.OperationForInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.PropertyForInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.RectangleInterfaceEditPart;
+import org.eclipse.papyrus.uml.diagram.component.test.IComponentDiagramTestsConstants;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.TestListCompartmentHelper;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TestListCompartmentPropertiesOperationsDrop extends AbstractPapyrusTestCase {
+
+ private TestListCompartmentHelper myHelper;
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getProjectName()
+ *
+ * @return
+ */
+ @Override
+ protected String getProjectName() {
+ return IComponentDiagramTestsConstants.PROJECT_NAME;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusTestCase#getFileName()
+ *
+ * @return
+ */
+ @Override
+ protected String getFileName() {
+ return IComponentDiagramTestsConstants.FILE_NAME;
+ }
+
+ @FailingTest
+ public void testPropertyInInterfaceAttributeCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(RectangleInterfaceEditPart.VISUAL_ID, InterfaceAttributeCompartmentEditPart.VISUAL_ID, PropertyForInterfaceEditPart.VISUAL_ID);
+ }
+
+ @FailingTest
+ public void testOperationInInterfaceOperationCompartment() throws Exception {
+ getHelper().checkUnexecutableDrop2Canvas(RectangleInterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, OperationForInterfaceEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testPropertyInInterfaceDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(RectangleInterfaceEditPart.VISUAL_ID, InterfaceAttributeCompartmentEditPart.VISUAL_ID, PropertyForInterfaceEditPart.VISUAL_ID);
+ }
+
+ @Test
+ public void testOperationInInterfaceDropFromModelExplorer() throws Exception {
+ getHelper().checkDropPropertyFromModelExplorer2Canvas(RectangleInterfaceEditPart.VISUAL_ID, InterfaceOperationCompartmentEditPart.VISUAL_ID, OperationForInterfaceEditPart.VISUAL_ID);
+ }
+
+ private TestListCompartmentHelper getHelper() {
+ if (myHelper == null) {
+ myHelper = new ComponentDiagramListCompartmentTestHelper(getDiagramEditPart(), diagramEditor);
+ }
+ return myHelper;
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestListCompartmentHelper.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestListCompartmentHelper.java
new file mode 100644
index 00000000000..58b6d33e5e5
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestListCompartmentHelper.java
@@ -0,0 +1,201 @@
+package org.eclipse.papyrus.uml.diagram.tests.canonical;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+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.RequestConstants;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.uml.diagram.common.part.UmlGmfDiagramEditor;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Property;
+import org.junit.Assert;
+
+/**
+ * ListCompartmentN test helper
+ *
+ */
+public abstract class TestListCompartmentHelper extends AbstractPapyrusTest {
+
+ private boolean myOperationFailed = false;
+
+ private final DiagramEditPart myDiagramEditPart;
+
+ /** The diagram editor. */
+ private final UmlGmfDiagramEditor myDiagramEditor;
+
+ public TestListCompartmentHelper(DiagramEditPart diagramEditPart, UmlGmfDiagramEditor diagramEditor) {
+ myDiagramEditPart = diagramEditPart;
+ myDiagramEditor = diagramEditor;
+ }
+
+ public void checkDuplicate(int parent, int parentContainer, int child) {
+ checkDuplicate(parent, parentContainer, child, 0);
+ }
+
+ public void checkDuplicate(int parent, int parentContainer, int child, int nestedChild) {
+ IGraphicalEditPart parentEP = createChild(parent, myDiagramEditPart, 0);
+ IGraphicalEditPart targetEP = findChildBySemanticHint(parentEP, parentContainer);
+ IGraphicalEditPart dndEP = createChild(nestedChild > 0 ? nestedChild : child, targetEP, 0);
+ {
+ Command ddCommand = createDropCommand(dndEP, myDiagramEditPart);
+ Assert.assertTrue(ddCommand.canExecute());
+ executeOnUIThread(ddCommand);
+ }
+ IGraphicalEditPart canvasDnDEP = findChildBySemanticHint(myDiagramEditPart, nestedChild > 0 ? child : getDefaultNamedElementVisualId());
+ {
+ Command ddCommand = createDropCommand(canvasDnDEP, targetEP);
+ Assert.assertFalse(canvasDnDEP.getClass().getName() + " can't be dropped to the " + targetEP.getClass().getName() + " due the duplication behavior rule.", ddCommand.canExecute());
+ }
+ }
+
+ public void checkUnexecutableChildCreate(int targetVisualId, int targetCompartmentVisualId, int childVisualId) {
+ IGraphicalEditPart targetEP = createChild(targetVisualId, myDiagramEditPart, 0);
+ IGraphicalEditPart targetCompartmentEP = findChildBySemanticHint(targetEP, targetCompartmentVisualId);
+ Command command = getCreateChildCommand(childVisualId, targetCompartmentEP);
+ Assert.assertFalse("The " + childVisualId + "-visualId can't be created in the " + targetCompartmentEP.getClass().getName(), command.canExecute());
+ }
+
+ public void checkUnexecutableDrop2Canvas(int targetVisualId, int targetCompartmentVisualId, int childVisualId) {
+ IGraphicalEditPart targetEP = createChild(targetVisualId, myDiagramEditPart, 0);
+ IGraphicalEditPart targetCompartmentEP = findChildBySemanticHint(targetEP, targetCompartmentVisualId);
+ IGraphicalEditPart childEP = createChild(childVisualId, targetCompartmentEP, 0);
+ EObject semantic = childEP.resolveSemanticElement();
+ Assert.assertTrue(semantic != null && (semantic instanceof Property || semantic instanceof Operation));
+ Command command = createDropCommand(childEP, myDiagramEditPart);
+ Assert.assertFalse("The " + childEP.getClass().getName() + " can't be droped to the Canvas.", command.canExecute());
+ }
+
+ public void checkDropPropertyFromModelExplorer2Canvas(int targetVisualId, int targetCompartmentVisualId, int childVisualId) throws Exception {
+ IGraphicalEditPart targetEP = createChild(targetVisualId, myDiagramEditPart, 0);
+ IGraphicalEditPart targetCompartmentEP = findChildBySemanticHint(targetEP, targetCompartmentVisualId);
+ IGraphicalEditPart childEP = createChild(childVisualId, targetCompartmentEP, 0);
+ EObject semantic = childEP.resolveSemanticElement();
+ Assert.assertTrue(semantic != null && (semantic instanceof Property || semantic instanceof Operation));
+ List<EObject> forDrop = new ArrayList<EObject>();
+ forDrop.add(semantic);
+ Command ddCommand = createDropCommandFromModelExplorer2Canvas(forDrop);
+ Assert.assertTrue(ddCommand.canExecute());
+ }
+
+ private Command createDropCommandFromModelExplorer2Canvas(List<EObject> elements) {
+ DropObjectsRequest req = new DropObjectsRequest();
+ req.setObjects(elements);
+ req.setAllowedDetail(DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK);
+ req.setLocation(new Point(15, 15));
+ req.setRequiredDetail(DND.DROP_COPY);
+ req.setType(RequestConstants.REQ_DROP_OBJECTS);
+ return myDiagramEditPart.getCommand(req);
+ }
+
+ private Command getCreateChildCommand(int childVID, IGraphicalEditPart container) {
+ final IElementType childType = getElementType(childVID);
+ final CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(childType, container.getDiagramPreferencesHint());
+ requestcreation.setSize(new Dimension(1, 1));
+ requestcreation.setLocation(new Point(10, 10));
+ return container.getCommand(requestcreation);
+ }
+
+ public void checkUnexecutableDrop(int targetVisualId, int targetCompartmentVisualId, int dropableVisualId) {
+ IGraphicalEditPart targetEP = createChild(targetVisualId, myDiagramEditPart, 0);
+ IGraphicalEditPart dropableEP = createChild(dropableVisualId, myDiagramEditPart, 1);
+ IGraphicalEditPart targetCompartmentEP = findChildBySemanticHint(targetEP, targetCompartmentVisualId);
+ Command command = createDropCommand(dropableEP, targetCompartmentEP);
+ Assert.assertFalse("The " + dropableEP.getClass().getName() + " can't be droped to the " + targetCompartmentEP.getClass().getName(), command.canExecute());
+ }
+
+ protected abstract int getDefaultNamedElementVisualId();
+
+ protected abstract IElementType getElementType(int childVID);
+
+ protected abstract int getVisualID(View view);
+
+ private void executeOnUIThread(final Command command) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ execute(command);
+ }
+ });
+ }
+
+ private void assertLastOperationSuccessful() {
+ Assert.assertFalse("The operation failed. Look at the log, or put a breakpoint on ExecutionException or DefaultOperationHistory#notifyNotOK to find the cause.", this.myOperationFailed); //$NON-NLS-1$
+ }
+
+ /**
+ * Reset the "operation failed" state. Call this before executing each
+ * operation for which you want to test whether if failed with {@link assertLastOperationSuccessful()}.
+ */
+ private void resetLastOperationFailedState() {
+ myOperationFailed = false;
+ }
+
+ /** Execute the given command in the diagram editor. */
+ private void execute(final Command command) {
+ resetLastOperationFailedState();
+ getCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ assertLastOperationSuccessful();
+ }
+
+ /** The command stack to use to execute commands on the diagram. */
+ private CommandStack getCommandStack() {
+ // not "diagramEditor.getDiagramEditDomain().getDiagramCommandStack()"
+ // because it messes up undo contexts
+ return myDiagramEditor.getEditingDomain().getCommandStack();
+ }
+
+ private Command createDropCommand(IGraphicalEditPart child, IGraphicalEditPart newParent) {
+ CompoundCommand c = new CompoundCommand();
+ ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DRAG);
+ changeBoundsRequest.setEditParts(child);
+ changeBoundsRequest.setLocation(new Point(15, 15));
+ c.add(child.getCommand(changeBoundsRequest));
+ myDiagramEditPart.getEditingDomain().getCommandStack().execute(new GEFtoEMFCommandWrapper(c));
+ changeBoundsRequest.setType(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DROP);
+ c.add(newParent.getCommand(changeBoundsRequest));
+ return c;
+ }
+
+ private IGraphicalEditPart createChild(int childVID, IGraphicalEditPart container, int number) {
+ Command cmd = getCreateChildCommand(childVID, container);
+ executeOnUIThread(cmd);
+ return findChild(container, childVID, number);
+ }
+
+
+ private IGraphicalEditPart findChild(IGraphicalEditPart parent, int vid, int number) {
+ List<?> children = parent.getChildren();
+ if (number > children.size() - 1) {
+ Assert.fail("Parent " + parent + ", type " + parent.getNotationView() + " hasn't less children then " + number);
+ }
+ IGraphicalEditPart childEP = (IGraphicalEditPart) children.get(number);
+ assertNotNull("Parent " + parent + ", type " + parent.getNotationView() + " looking for: " + vid, childEP);
+ Assert.assertEquals("Parent " + parent + ", type " + parent.getNotationView() + " looking for: " + vid, getVisualID(childEP.getNotationView()), vid);
+ return childEP;
+ }
+
+ private IGraphicalEditPart findChildBySemanticHint(IGraphicalEditPart parent, int vid) {
+ IGraphicalEditPart childEP = parent.getChildBySemanticHint(Integer.toString(vid));
+ assertNotNull("Parent " + parent + ", type " + parent.getNotationView() + " looking for: " + vid, childEP);
+ return childEP;
+ }
+}

Back to the top