Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskovalsky2015-05-12 08:08:50 +0000
committerCamille Letavernier2015-06-10 09:06:39 +0000
commit190b936157d70daf0f2c9a9a9eef8cdd8e01a434 (patch)
tree567c50b4527bea78ef15042adf143b02fe164c64
parent3c41025923aa0bd92ad1807b6a4a9c454b4e6b38 (diff)
downloadorg.eclipse.papyrus-190b936157d70daf0f2c9a9a9eef8cdd8e01a434.tar.gz
org.eclipse.papyrus-190b936157d70daf0f2c9a9a9eef8cdd8e01a434.tar.xz
org.eclipse.papyrus-190b936157d70daf0f2c9a9a9eef8cdd8e01a434.zip
[Activity Diagram] Child Node managed tests failed M7 Tests
Change-Id: I2fabc41e657685351d588f43eb1aa37f0ba84861 Signed-off-by: skovalsky <kovalsky@montages.com> Reviewed-on: https://git.eclipse.org/r/47680 Reviewed-by: Michael Golubev <golubev@montages.com> Tested-by: Hudson CI Reviewed-by: Camille Letavernier <camille.letavernier@cea.fr>
-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.java3
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestItemProviderCommand.java86
2 files changed, 88 insertions, 1 deletions
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 0d87f999d37..af55db78d15 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
@@ -30,7 +30,8 @@ TestDropObjects.class,
TestCommentLink.class,
TestSemanticContainerFeature.class,
TestLinks.class,
-TestControlNodesInStructuredActivityNodes.class
+TestControlNodesInStructuredActivityNodes.class,
+TestItemProviderCommand.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/TestItemProviderCommand.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestItemProviderCommand.java
new file mode 100644
index 00000000000..ab67abf352e
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestItemProviderCommand.java
@@ -0,0 +1,86 @@
+package org.eclipse.papyrus.uml.diagram.activity.tests.canonical;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Collections;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.emf.core.util.PackageUtil;
+import org.eclipse.gmf.tooling.runtime.update.DiagramUpdater;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGEFCommandWrapper;
+import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramUpdater;
+import org.eclipse.papyrus.uml.diagram.activity.tests.IActivityDiagramTestsConstants;
+import org.eclipse.uml2.common.edit.command.SubsetAddCommand;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.AddVariableValueAction;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.edit.providers.ActivityItemProvider;
+import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class TestItemProviderCommand extends AbstractPapyrusTestCase {
+
+ @Override
+ protected String getProjectName() {
+ return IActivityDiagramTestsConstants.PROJECT_NAME;
+ }
+
+ @Override
+ protected String getFileName() {
+ return IActivityDiagramTestsConstants.FILE_NAME;
+ }
+
+ public DiagramUpdater getDiagramUpdater() {
+ return UMLDiagramUpdater.INSTANCE;
+ }
+
+ @Test
+ public void testItemProviderCommandUndo() {
+ UMLItemProviderAdapterFactory itemProviderFactory = new UMLItemProviderAdapterFactory();
+ testSubsetAddCommandForItemProvider((ActivityItemProvider) itemProviderFactory.createActivityAdapter());
+ }
+
+ private void testSubsetAddCommandForItemProvider(ActivityItemProvider itemProvider) {
+ Activity owner = (Activity) getActivityCompartmentEditPart().resolveSemanticElement();
+ AddVariableValueAction newElement = UMLFactory.eINSTANCE.createAddVariableValueAction();
+ EReference containmentFeature = PackageUtil.findFeature(owner.eClass(), newElement.eClass());
+ org.eclipse.emf.common.command.Command createCommand = getCreateCommand(itemProvider, owner, newElement, containmentFeature);
+ Assert.assertTrue("Expected SubsetAddCommand not " + createCommand.getClass().getName(), createCommand instanceof SubsetAddCommand);
+ SubsetAddCommand subsetAddCommand = (SubsetAddCommand) createCommand;
+ assertEquals(CREATION + TEST_THE_UNDO, 0, getRootSemanticModel().getOwnedElements().size());
+ executeOnUIThread(EMFtoGEFCommandWrapper.wrap(subsetAddCommand));
+ Assert.assertTrue(subsetAddCommand.getCommandList().size() == 2);
+ assertEquals(CREATION + TEST_THE_UNDO, 1, getRootSemanticModel().getOwnedElements().size());
+ checkFeatures(owner, newElement, containmentFeature, UMLPackage.Literals.ACTIVITY__NODE, true);
+ undoOnUIThread();
+ checkFeatures(owner, newElement, containmentFeature, UMLPackage.Literals.ACTIVITY__NODE, false);
+ assertEquals(CREATION + TEST_THE_UNDO, 0, getRootSemanticModel().getOwnedElements().size());
+ }
+
+ private void checkFeatures(EObject owner, EObject newElement, EStructuralFeature feature, EStructuralFeature supersetFeatures, boolean contains) {
+ Assert.assertTrue(supersetFeatures.isMany());
+ @SuppressWarnings("unchecked")
+ EList<EObject> values = (EList<EObject>) owner.eGet(supersetFeatures);
+ Assert.assertTrue(values.contains(newElement) == contains);
+ }
+
+ private org.eclipse.emf.common.command.Command getCreateCommand(ActivityItemProvider itemProvider, EObject owner, EObject newElement, EStructuralFeature feature) {
+ // setup diagramEditor
+ getDiagramEditPart();
+ EditingDomain domain = diagramEditor.getEditingDomain();
+ CommandParameter commandParameter = new CommandParameter(owner, feature, Collections.singleton(newElement), -1);
+ org.eclipse.emf.common.command.Command createCommand = itemProvider.createCommand(owner, domain, AddCommand.class, commandParameter);
+ Assert.assertNotNull("AddVariableValueAction can't be created.", createCommand);
+ Assert.assertTrue("Expected executable creation command.", createCommand.canExecute());
+ return createCommand;
+ }
+}

Back to the top