Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFlorian Noyrit2016-01-29 05:02:50 -0500
committerFlorian Noyrit2016-01-29 05:02:50 -0500
commitc33bf090ae301abce757edc6969dbd8326084927 (patch)
treef6460855b0493b814fad96d7572a0cd89a3b7913 /tests
parentea8ea3da07dd133eed8a6e3f81087c17ad9c5ee5 (diff)
downloadorg.eclipse.papyrus-c33bf090ae301abce757edc6969dbd8326084927.tar.gz
org.eclipse.papyrus-c33bf090ae301abce757edc6969dbd8326084927.tar.xz
org.eclipse.papyrus-c33bf090ae301abce757edc6969dbd8326084927.zip
Improve ElementTypeConfiguration Framework to support:
- Advice execution ordering - Prepare Multiple ClientContext in Papyrus Change-Id: I00b5d3d5e090de1b8fc9926c9073913c90dda47e
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/cyclicAdvices.elementtypesconfigurations45
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/elementtypetest.elementtypesconfigurations1
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/validAdvicesOrder.elementtypesconfigurations42
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/plugin.xml2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ElementEditHelperAdviceTests.java546
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ElementTypesRegistryTests.java2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ITestConstants.java11
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice1.java20
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice2.java20
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice3.java20
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests/META-INF/MANIFEST.MF5
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/ui/tests/ElementTypesRegistryTests.java49
-rw-r--r--tests/junit/plugins/infra/gmfdiag/assistant/org.eclipse.papyrus.infra.gmfdiag.assistant.tests/src/org/eclipse/papyrus/infra/gmfdiag/assistant/tests/AssistantsFixture.java34
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/fragment.xml2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/plugin.xml4
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/resources/FakeProfile.elementtypesconfigurations4
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/resources/TestPalette.elementtypesconfigurations2
17 files changed, 540 insertions, 269 deletions
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/cyclicAdvices.elementtypesconfigurations b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/cyclicAdvices.elementtypesconfigurations
new file mode 100644
index 00000000000..a4122a8b0c7
--- /dev/null
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/cyclicAdvices.elementtypesconfigurations
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ASCII"?>
+<elementtypesconfigurations:ElementTypeSetConfiguration
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.0"
+ xmi:id="_ScP1oFYCEeS0WsAAtVmToA"
+ name="Test cyclic edvices dependencies"
+ identifier="org.eclipse.papyrus.infra.elementtypesconfigurations.cyclicAdvices.elementtypesconfigurations"
+ metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML">
+ <adviceBindingsConfigurations
+ xmi:id="_SGAo4LK-EeWUIbTgfwAP3g"
+ name="TestEditHelperAdvice1"
+ identifier="TestEditHelperAdvice1"
+ editHelperAdviceClassName="org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice1">
+ <after>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice2</after>
+ <after>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice3</after>
+ <target
+ xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration"
+ href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_Sca0wVYCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations
+ xmi:id="_nSyIoLK-EeWUIbTgfwAP3g"
+ name="TestEditHelperAdvice2"
+ identifier="TestEditHelperAdvice2"
+ editHelperAdviceClassName="org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice2">
+ <before>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice1</before>
+ <after>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice3</after>
+ <target
+ xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration"
+ href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_Sca0wVYCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations
+ xmi:id="_ojuzILK-EeWUIbTgfwAP3g"
+ name="TestEditHelperAdvice3"
+ identifier="TestEditHelperAdvice3"
+ editHelperAdviceClassName="org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice3">
+ <before>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice1</before>
+ <before>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice2</before>
+ <after>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice1</after>
+ <target
+ xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration"
+ href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_Sca0wVYCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+</elementtypesconfigurations:ElementTypeSetConfiguration>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/elementtypetest.elementtypesconfigurations b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/elementtypetest.elementtypesconfigurations
index 125a0ad1f99..53a85abfb53 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/elementtypetest.elementtypesconfigurations
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/elementtypetest.elementtypesconfigurations
@@ -13,6 +13,7 @@
xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"
xmi:id="_ScP1oFYCEeS0WsAAtVmToA"
name="Test element types"
+ identifier="org.eclipse.papyrus.infra.elementtypesconfigurations.tests.tests"
metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML">
<elementTypeConfigurations
xsi:type="invarianttypeconfiguration:InvariantTypeConfiguration"
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/validAdvicesOrder.elementtypesconfigurations b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/validAdvicesOrder.elementtypesconfigurations
new file mode 100644
index 00000000000..c621816c8c3
--- /dev/null
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/validAdvicesOrder.elementtypesconfigurations
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ASCII"?>
+<elementtypesconfigurations:ElementTypeSetConfiguration
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.0"
+ xmi:id="_ScP1oFYCEeS0WsAAtVmToA"
+ name="Test cyclic edvices dependencies"
+ identifier="org.eclipse.papyrus.infra.elementtypesconfigurations.cyclicAdvices.elementtypesconfigurations"
+ metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML">
+ <adviceBindingsConfigurations
+ xmi:id="_SGAo4LK-EeWUIbTgfwAP3g"
+ name="TestEditHelperAdvice1"
+ identifier="TestEditHelperAdvice1"
+ editHelperAdviceClassName="org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice1">
+ <before>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice2</before>
+ <target
+ xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration"
+ href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_Sca0wVYCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations
+ xmi:id="_nSyIoLK-EeWUIbTgfwAP3g"
+ name="TestEditHelperAdvice2"
+ identifier="TestEditHelperAdvice2"
+ editHelperAdviceClassName="org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice2">
+ <before>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice3</before>
+ <after>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice1</after>
+ <target
+ xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration"
+ href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_Sca0wVYCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations
+ xmi:id="_ojuzILK-EeWUIbTgfwAP3g"
+ name="TestEditHelperAdvice3"
+ identifier="TestEditHelperAdvice3"
+ editHelperAdviceClassName="org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice3">
+ <after>org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice2</after>
+ <target
+ xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration"
+ href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_Sca0wVYCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+</elementtypesconfigurations:ElementTypeSetConfiguration>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/plugin.xml b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/plugin.xml
index 133a60204d3..604ae6cf4da 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/plugin.xml
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/plugin.xml
@@ -4,7 +4,7 @@
<extension
point="org.eclipse.papyrus.infra.elementtypesconfigurations.elementTypeSetConfiguration">
<elementTypeSet
- id="org.eclipse.papyrus.infra.elementtypesconfigurations.tests.tests"
+ clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
path="model/elementtypetest.elementtypesconfigurations">
</elementTypeSet>
</extension>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ElementEditHelperAdviceTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ElementEditHelperAdviceTests.java
index cac6e74c8f2..17ec1f21322 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ElementEditHelperAdviceTests.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ElementEditHelperAdviceTests.java
@@ -1,239 +1,307 @@
-/*****************************************************************************
- * 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:
- * Francois Le Fevre (CEA LIST) francois.le-fevre@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.elementtypesconfigurations.tests;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.uml2.uml.Component;
-import org.eclipse.uml2.uml.Package;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Based upon ExtendedEditHelperAdviceTests
- * Test class for element type edit helper advice
- */
-public class ElementEditHelperAdviceTests extends AbstractElementTypeTests implements ITestConstants {
-
- @Test
- // transcoded from extended types framework
- public void testPACKAGE_WITH_COMPONENTSType() {
- List<IElementType> elementTypes = Arrays.asList(ElementTypeRegistry.getInstance().getAllTypesMatching(packageWithComponents, papyrusContext));
- Assert.assertNotNull("list should not be null", elementTypes);
- Assert.assertTrue("list should not be empty", elementTypes.size() > 0);
- System.out.println("elementTypes.size() " + elementTypes.size());
- Assert.assertTrue(PACKAGE_WITH_COMPONENTS + " should be a Package With components only type", elementTypes.contains(ElementTypeRegistry.getInstance().getType(PACKAGE_WITH_COMPONENTS_TYPE_ID)));
- }
-
- @Test
- public void testPACKAGE_WITH_ALL_ELEMENTSType() {
- List<IElementType> elementTypes = Arrays.asList(ElementTypeRegistry.getInstance().getAllTypesMatching(packageWithAllElements, papyrusContext));
- Assert.assertNotNull("list should not be null", elementTypes);
- Assert.assertTrue("list should not be empty", elementTypes.size() > 0);
- Assert.assertTrue(PACKAGE_WITH_ALL_ELEMENTS + " should not be a Package With components only type", !elementTypes.contains(ElementTypeRegistry.getInstance().getType(PACKAGE_WITH_COMPONENTS_TYPE_ID)));
- }
-
- @Test
- // transcoded from extended types framework
- public void testSemanticCreateComponentInGoodPackage() throws ExecutionException {
- testCreateComponent(packageWithComponents, true);
- }
-
- @Test
- // transcoded from extended types framework
- public void testSemanticCreateComponentInWrongPackage() throws ExecutionException {
- testCreateComponent(packageWithAllElements, false);
- }
-
- protected void testCreateComponent(Package container, boolean canCreate) throws ExecutionException {
- IProgressMonitor monitor = new NullProgressMonitor();
- // should be possible
- IElementType type = ElementTypeRegistry.getInstance().getType(SPECIFICCOMPONENT_TYPE_ID);
- CreateElementRequest request = new CreateElementRequest(transactionalEditingDomain, container, type);
- IElementEditService service = ElementEditServiceUtils.getCommandProvider(container);
- ICommand command = service.getEditCommand(request);
- // get children before modification
- List<EObject> originalChildren = new ArrayList<EObject>(container.getPackagedElements());
- if (canCreate) {
- Assert.assertTrue("Command should be executable", command.canExecute());
- IStatus status = command.execute(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- // get result
- List<EObject> afterCreationChildren = new ArrayList<EObject>(container.getPackagedElements());
- List<EObject> delta = new ArrayList<EObject>(afterCreationChildren);
- delta.removeAll(originalChildren);
- Assert.assertEquals("List should have only one more element", 1, delta.size());
- // check it does not impact undo
- Assert.assertTrue("Command should be undoable", command.canUndo());
- status = command.undo(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- List<EObject> afterUndoChildren = new ArrayList<EObject>(container.getPackagedElements());
- delta = new ArrayList<EObject>(afterUndoChildren);
- delta.removeAll(originalChildren);
- Assert.assertEquals("List should have no element", 0, delta.size());
- // should be redoable
- Assert.assertTrue("Command should be redoable", command.canRedo());
- status = command.redo(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- List<EObject> afterRedoChildren = new ArrayList<EObject>(container.getPackagedElements());
- delta = new ArrayList<EObject>(afterRedoChildren);
- delta.removeAll(originalChildren);
- Assert.assertEquals("List should have one more element", 1, delta.size());
- // undo to revert state
- Assert.assertTrue("Command should be undoable", command.canUndo());
- status = command.undo(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- } else {
- Assert.assertTrue("Command should not be executable", command == null || !(command.canExecute()));
- }
- }
-
- @Test
- public void testSemanticMoveComponentFromGoodPackageToGoodPackage() throws ExecutionException {
- // should be possible (target = good package)
- testMoveComponent(otherPackageWithComponents, component1_packageWithComponents, true);
- }
-
- @Test
- // transcoded from extended types framework
- public void testSemanticMoveComponentFromGoodPackageToWrongPackage() throws ExecutionException {
- // should be impossible (target = wrong package)
- testMoveComponent(packageWithAllElements, component1_packageWithComponents, false);
- }
-
- @Test
- public void testSemanticMoveComponentFromWrongPackageToGoodPackage() throws ExecutionException {
- // should be possible (target = good package)
- testMoveComponent(packageWithComponents, component1_packageWithAllElements, true);
- }
-
- @Test
- public void testSemanticMoveComponentFromWrongPackageToWrongPackage() throws ExecutionException {
- // should be impossible (target = wrong package)
- testMoveComponent(packageWithAllElements, component1_packageWithAllElements, false);
- }
-
- protected void testMoveComponent(Package targetContainer, Component sourceComponent, boolean canMove) throws ExecutionException {
- IProgressMonitor monitor = new NullProgressMonitor();
- // should be possible
- MoveRequest request = new MoveRequest(transactionalEditingDomain, targetContainer, sourceComponent);
- IElementEditService service = ElementEditServiceUtils.getCommandProvider(targetContainer);
- ICommand command = service.getEditCommand(request);
- // get children before modification
- List<EObject> originalChildren = new ArrayList<EObject>(targetContainer.getPackagedElements());
- if (canMove) {
- Assert.assertTrue("Command should be executable", command.canExecute());
- IStatus status = command.execute(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- // get result
- List<EObject> afterCreationChildren = new ArrayList<EObject>(targetContainer.getPackagedElements());
- List<EObject> delta = new ArrayList<EObject>(afterCreationChildren);
- delta.removeAll(originalChildren);
- Assert.assertEquals("List should have only one more element", 1, delta.size());
- // check it does not impact undo
- Assert.assertTrue("Command should be undoable", command.canUndo());
- status = command.undo(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- List<EObject> afterUndoChildren = new ArrayList<EObject>(targetContainer.getPackagedElements());
- delta = new ArrayList<EObject>(afterUndoChildren);
- delta.removeAll(originalChildren);
- Assert.assertEquals("List should have no element", 0, delta.size());
- // should be redoable
- Assert.assertTrue("Command should be undoable", command.canUndo());
- status = command.undo(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- List<EObject> afterRedoChildren = new ArrayList<EObject>(targetContainer.getPackagedElements());
- delta = new ArrayList<EObject>(afterRedoChildren);
- delta.removeAll(originalChildren);
- Assert.assertEquals("List should have one more element", 1, delta.size());
- // undo to revert state
- Assert.assertTrue("Command should be undoable", command.canUndo());
- status = command.undo(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- } else {
- Assert.assertTrue("Command should not be executable", command == null || !command.canExecute());
- }
- }
-
- @Test
- public void testDeleteComponentFromWrongPackage() throws ExecutionException {
- // should be possible. no influence on deletion is expected
- testDeleteComponent(component1_packageWithAllElements, true);
- }
-
- @Test
- public void testDeleteComponentFromGoodPackage() throws ExecutionException {
- // should be possible. no influence on deletion is expected
- testDeleteComponent(component1_packageWithComponents, true);
- }
-
- protected void testDeleteComponent(EObject objectToDelete, boolean canDelete) throws ExecutionException {
- IProgressMonitor monitor = new NullProgressMonitor();
- // should be possible
- DestroyElementRequest request = new DestroyElementRequest(transactionalEditingDomain, objectToDelete, false);
- IElementEditService service = ElementEditServiceUtils.getCommandProvider(objectToDelete);
- ICommand command = service.getEditCommand(request);
- // get children before modification
- List<EObject> originalChildren = new ArrayList<EObject>((List<EObject>) objectToDelete.eContainer().eGet(objectToDelete.eContainingFeature(), true));
- EObject container = objectToDelete.eContainer();
- EStructuralFeature containingFeature = objectToDelete.eContainingFeature();
- if (canDelete) {
- Assert.assertTrue("Command should be executable", command.canExecute());
- IStatus status = command.execute(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- // get result
- List<EObject> afterDeletionChildren = new ArrayList<EObject>((List<EObject>) container.eGet(containingFeature, true));
- List<EObject> delta = new ArrayList<EObject>(originalChildren);
- delta.removeAll(afterDeletionChildren);
- Assert.assertEquals("List should have one element only", 1, delta.size());
- Assert.assertEquals("deleted element should be the specified one", objectToDelete, delta.get(0));
- // check it does not impact undo
- Assert.assertTrue("Command should be undoable", command.canUndo());
- status = command.undo(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- List<EObject> afterUndoChildren = new ArrayList<EObject>((List<EObject>) container.eGet(containingFeature, true));
- delta = new ArrayList<EObject>(afterUndoChildren);
- delta.removeAll(originalChildren);
- Assert.assertEquals("List should have no element", 0, delta.size());
- // should be redoable
- Assert.assertTrue("Command should be redoable", command.canRedo());
- status = command.redo(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- List<EObject> afterRedoChildren = new ArrayList<EObject>((List<EObject>) container.eGet(containingFeature, true));
- delta = new ArrayList<EObject>(originalChildren);
- delta.removeAll(afterRedoChildren);
- Assert.assertEquals("List should have one more element", 1, delta.size());
- // undo to revert state
- Assert.assertTrue("Command should be undoable", command.canUndo());
- status = command.undo(monitor, null);
- Assert.assertTrue("Status should be OK", status.isOK());
- } else {
- Assert.assertTrue("Command should not be executable", command == null || !command.canExecute());
- }
- }
-}
+/*****************************************************************************
+ * 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:
+ * Francois Le Fevre (CEA LIST) francois.le-fevre@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.elementtypesconfigurations.tests;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeSetConfiguration;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.registries.ElementTypeSetConfigurationRegistry;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.utils.AdviceComparator;
+import org.eclipse.papyrus.infra.services.edit.internal.context.TypeContext;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.uml2.uml.Component;
+import org.eclipse.uml2.uml.Package;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Based upon ExtendedEditHelperAdviceTests
+ * Test class for element type edit helper advice
+ */
+public class ElementEditHelperAdviceTests extends AbstractElementTypeTests implements ITestConstants {
+
+ @Test
+ // transcoded from extended types framework
+ public void testPACKAGE_WITH_COMPONENTSType() {
+ List<IElementType> elementTypes = Arrays.asList(ElementTypeRegistry.getInstance().getAllTypesMatching(packageWithComponents, papyrusContext));
+ Assert.assertNotNull("list should not be null", elementTypes);
+ Assert.assertTrue("list should not be empty", elementTypes.size() > 0);
+ Assert.assertTrue(PACKAGE_WITH_COMPONENTS + " should be a Package With components only type", elementTypes.contains(ElementTypeRegistry.getInstance().getType(PACKAGE_WITH_COMPONENTS_TYPE_ID)));
+ }
+
+ @Test
+ public void testPACKAGE_WITH_ALL_ELEMENTSType() {
+ List<IElementType> elementTypes = Arrays.asList(ElementTypeRegistry.getInstance().getAllTypesMatching(packageWithAllElements, papyrusContext));
+ Assert.assertNotNull("list should not be null", elementTypes);
+ Assert.assertTrue("list should not be empty", elementTypes.size() > 0);
+ Assert.assertTrue(PACKAGE_WITH_ALL_ELEMENTS + " should not be a Package With components only type", !elementTypes.contains(ElementTypeRegistry.getInstance().getType(PACKAGE_WITH_COMPONENTS_TYPE_ID)));
+ }
+
+ @Test
+ // transcoded from extended types framework
+ public void testSemanticCreateComponentInGoodPackage() throws ExecutionException {
+ testCreateComponent(packageWithComponents, true);
+ }
+
+ @Test
+ // transcoded from extended types framework
+ public void testSemanticCreateComponentInWrongPackage() throws ExecutionException {
+ testCreateComponent(packageWithAllElements, false);
+ }
+
+ protected void testCreateComponent(Package container, boolean canCreate) throws ExecutionException {
+ IProgressMonitor monitor = new NullProgressMonitor();
+ // should be possible
+ IElementType type = ElementTypeRegistry.getInstance().getType(SPECIFICCOMPONENT_TYPE_ID);
+ CreateElementRequest request = new CreateElementRequest(transactionalEditingDomain, container, type);
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(container);
+ ICommand command = service.getEditCommand(request);
+ // get children before modification
+ List<EObject> originalChildren = new ArrayList<EObject>(container.getPackagedElements());
+ if (canCreate) {
+ Assert.assertTrue("Command should be executable", command.canExecute());
+ IStatus status = command.execute(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ // get result
+ List<EObject> afterCreationChildren = new ArrayList<EObject>(container.getPackagedElements());
+ List<EObject> delta = new ArrayList<EObject>(afterCreationChildren);
+ delta.removeAll(originalChildren);
+ Assert.assertEquals("List should have only one more element", 1, delta.size());
+ // check it does not impact undo
+ Assert.assertTrue("Command should be undoable", command.canUndo());
+ status = command.undo(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ List<EObject> afterUndoChildren = new ArrayList<EObject>(container.getPackagedElements());
+ delta = new ArrayList<EObject>(afterUndoChildren);
+ delta.removeAll(originalChildren);
+ Assert.assertEquals("List should have no element", 0, delta.size());
+ // should be redoable
+ Assert.assertTrue("Command should be redoable", command.canRedo());
+ status = command.redo(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ List<EObject> afterRedoChildren = new ArrayList<EObject>(container.getPackagedElements());
+ delta = new ArrayList<EObject>(afterRedoChildren);
+ delta.removeAll(originalChildren);
+ Assert.assertEquals("List should have one more element", 1, delta.size());
+ // undo to revert state
+ Assert.assertTrue("Command should be undoable", command.canUndo());
+ status = command.undo(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ } else {
+ Assert.assertTrue("Command should not be executable", command == null || !(command.canExecute()));
+ }
+ }
+
+ @Test
+ public void testSemanticMoveComponentFromGoodPackageToGoodPackage() throws ExecutionException {
+ // should be possible (target = good package)
+ testMoveComponent(otherPackageWithComponents, component1_packageWithComponents, true);
+ }
+
+ @Test
+ // transcoded from extended types framework
+ public void testSemanticMoveComponentFromGoodPackageToWrongPackage() throws ExecutionException {
+ // should be impossible (target = wrong package)
+ testMoveComponent(packageWithAllElements, component1_packageWithComponents, false);
+ }
+
+ @Test
+ public void testSemanticMoveComponentFromWrongPackageToGoodPackage() throws ExecutionException {
+ // should be possible (target = good package)
+ testMoveComponent(packageWithComponents, component1_packageWithAllElements, true);
+ }
+
+ @Test
+ public void testSemanticMoveComponentFromWrongPackageToWrongPackage() throws ExecutionException {
+ // should be impossible (target = wrong package)
+ testMoveComponent(packageWithAllElements, component1_packageWithAllElements, false);
+ }
+
+ protected void testMoveComponent(Package targetContainer, Component sourceComponent, boolean canMove) throws ExecutionException {
+ IProgressMonitor monitor = new NullProgressMonitor();
+ // should be possible
+ MoveRequest request = new MoveRequest(transactionalEditingDomain, targetContainer, sourceComponent);
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(targetContainer);
+ ICommand command = service.getEditCommand(request);
+ // get children before modification
+ List<EObject> originalChildren = new ArrayList<EObject>(targetContainer.getPackagedElements());
+ if (canMove) {
+ Assert.assertTrue("Command should be executable", command.canExecute());
+ IStatus status = command.execute(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ // get result
+ List<EObject> afterCreationChildren = new ArrayList<EObject>(targetContainer.getPackagedElements());
+ List<EObject> delta = new ArrayList<EObject>(afterCreationChildren);
+ delta.removeAll(originalChildren);
+ Assert.assertEquals("List should have only one more element", 1, delta.size());
+ // check it does not impact undo
+ Assert.assertTrue("Command should be undoable", command.canUndo());
+ status = command.undo(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ List<EObject> afterUndoChildren = new ArrayList<EObject>(targetContainer.getPackagedElements());
+ delta = new ArrayList<EObject>(afterUndoChildren);
+ delta.removeAll(originalChildren);
+ Assert.assertEquals("List should have no element", 0, delta.size());
+ // should be redoable
+ Assert.assertTrue("Command should be undoable", command.canUndo());
+ status = command.undo(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ List<EObject> afterRedoChildren = new ArrayList<EObject>(targetContainer.getPackagedElements());
+ delta = new ArrayList<EObject>(afterRedoChildren);
+ delta.removeAll(originalChildren);
+ Assert.assertEquals("List should have one more element", 1, delta.size());
+ // undo to revert state
+ Assert.assertTrue("Command should be undoable", command.canUndo());
+ status = command.undo(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ } else {
+ Assert.assertTrue("Command should not be executable", command == null || !command.canExecute());
+ }
+ }
+
+ @Test
+ public void testDeleteComponentFromWrongPackage() throws ExecutionException {
+ // should be possible. no influence on deletion is expected
+ testDeleteComponent(component1_packageWithAllElements, true);
+ }
+
+ @Test
+ public void testDeleteComponentFromGoodPackage() throws ExecutionException {
+ // should be possible. no influence on deletion is expected
+ testDeleteComponent(component1_packageWithComponents, true);
+ }
+
+ protected void testDeleteComponent(EObject objectToDelete, boolean canDelete) throws ExecutionException {
+ IProgressMonitor monitor = new NullProgressMonitor();
+ // should be possible
+ DestroyElementRequest request = new DestroyElementRequest(transactionalEditingDomain, objectToDelete, false);
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(objectToDelete);
+ ICommand command = service.getEditCommand(request);
+ // get children before modification
+ List<EObject> originalChildren = new ArrayList<EObject>((List<EObject>) objectToDelete.eContainer().eGet(objectToDelete.eContainingFeature(), true));
+ EObject container = objectToDelete.eContainer();
+ EStructuralFeature containingFeature = objectToDelete.eContainingFeature();
+ if (canDelete) {
+ Assert.assertTrue("Command should be executable", command.canExecute());
+ IStatus status = command.execute(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ // get result
+ List<EObject> afterDeletionChildren = new ArrayList<EObject>((List<EObject>) container.eGet(containingFeature, true));
+ List<EObject> delta = new ArrayList<EObject>(originalChildren);
+ delta.removeAll(afterDeletionChildren);
+ Assert.assertEquals("List should have one element only", 1, delta.size());
+ Assert.assertEquals("deleted element should be the specified one", objectToDelete, delta.get(0));
+ // check it does not impact undo
+ Assert.assertTrue("Command should be undoable", command.canUndo());
+ status = command.undo(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ List<EObject> afterUndoChildren = new ArrayList<EObject>((List<EObject>) container.eGet(containingFeature, true));
+ delta = new ArrayList<EObject>(afterUndoChildren);
+ delta.removeAll(originalChildren);
+ Assert.assertEquals("List should have no element", 0, delta.size());
+ // should be redoable
+ Assert.assertTrue("Command should be redoable", command.canRedo());
+ status = command.redo(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ List<EObject> afterRedoChildren = new ArrayList<EObject>((List<EObject>) container.eGet(containingFeature, true));
+ delta = new ArrayList<EObject>(originalChildren);
+ delta.removeAll(afterRedoChildren);
+ Assert.assertEquals("List should have one more element", 1, delta.size());
+ // undo to revert state
+ Assert.assertTrue("Command should be undoable", command.canUndo());
+ status = command.undo(monitor, null);
+ Assert.assertTrue("Status should be OK", status.isOK());
+ } else {
+ Assert.assertTrue("Command should not be executable", command == null || !command.canExecute());
+ }
+ }
+
+ @Test
+ public void testValidAdvicesOrder() {
+ IElementType classElementType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Class");
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource validAdviesOrderConfigurationResource = resourceSet.getResource(URI.createURI(VALID_ADVICES_ORDER_CONFIGURATIONS), true);
+ EObject root = validAdviesOrderConfigurationResource.getContents().get(0);
+ if (root instanceof ElementTypeSetConfiguration) {
+
+ try {
+ ElementTypeSetConfigurationRegistry.getInstance().loadElementTypeSetConfiguration(TypeContext.getContext().getId(), (ElementTypeSetConfiguration) root);
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ IEditHelperAdvice[] advicesAfterLoading = ElementTypeRegistry.getInstance().getEditHelperAdvice(classElementType);
+ Arrays.sort(advicesAfterLoading, new AdviceComparator());
+
+ int advice1Index = -1;
+ int advice2Index = -1;
+ int advice3Index = -1;
+ for (int i = 0; i < advicesAfterLoading.length; i++) {
+ IEditHelperAdvice iEditHelperAdvice = advicesAfterLoading[i];
+ if (iEditHelperAdvice.getClass().getName().equals(ADVICES_ID_1)) {
+ advice1Index = i;
+ } else if (iEditHelperAdvice.getClass().getName().equals(ADVICES_ID_2)) {
+ advice2Index = i;
+ } else if (iEditHelperAdvice.getClass().getName().equals(ADVICES_ID_3)) {
+ advice3Index = i;
+ }
+ }
+
+ Assert.assertTrue(ADVICES_ID_2 + " should be after " + ADVICES_ID_3, advice3Index < advice2Index);
+ Assert.assertTrue(ADVICES_ID_3 + " should be after " + ADVICES_ID_1, advice2Index < advice1Index);
+ } else {
+ Assert.fail("Failed to load test model: " + CYCLIC_ADVICES_CONFIGURATIONS);
+ }
+ }
+
+ @Test
+ public void testCyclicAdvices() {
+ IElementType classElementType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Class");
+ IEditHelperAdvice[] advicesBeforeLoading = ElementTypeRegistry.getInstance().getEditHelperAdvice(classElementType);
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource cyclicAdvicesConfigurationResource = resourceSet.getResource(URI.createURI(CYCLIC_ADVICES_CONFIGURATIONS), true);
+ org.eclipse.emf.ecore.EObject root = cyclicAdvicesConfigurationResource.getContents().get(0);
+ if (root instanceof ElementTypeSetConfiguration) {
+ try {
+ ElementTypeSetConfigurationRegistry.getInstance().loadElementTypeSetConfiguration(TypeContext.getContext().getId(), (ElementTypeSetConfiguration) root);
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ IEditHelperAdvice[] advicesAfterLoading = ElementTypeRegistry.getInstance().getEditHelperAdvice(classElementType);
+ Assert.assertArrayEquals("Advices for UML::Class should have not been changed: ", advicesBeforeLoading, advicesAfterLoading);
+ } else {
+ Assert.fail("Failed to load test model: " + CYCLIC_ADVICES_CONFIGURATIONS);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ElementTypesRegistryTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ElementTypesRegistryTests.java
index ddb483835c4..6c0f7d518dc 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ElementTypesRegistryTests.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ElementTypesRegistryTests.java
@@ -37,4 +37,4 @@ public class ElementTypesRegistryTests extends AbstractElementTypeTests implemen
IElementType abstractClassType = ElementTypeRegistry.getInstance().getType(ABSTRACT_CLASS_TOOL);
Assert.assertNotNull("Element type should be registered", abstractClassType);
}
-}
+} \ No newline at end of file
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ITestConstants.java b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ITestConstants.java
index 9e723e65591..449ab399284 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ITestConstants.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/ITestConstants.java
@@ -21,7 +21,7 @@ public interface ITestConstants {
final static String ABSTRACT_CLASS_TOOL = "org.eclipse.papyrus.infra.elementtypesconfigurations.tests.aspectabstractclass"; //$NON-NLS-1$
final static String ElementTypeConfigurationSetName_Test1 = "org.eclipse.papyrus.infra.elementtypesconfigurations.tests.tests"; //$NON-NLS-1$
-
+
final static String WORKSPACE_ELEMENT_TYPE_ID = "org.eclipse.papyrus.infra.elementtypesconfigurations.tests.workspacetype"; //$NON-NLS-1$
final static String WORKSPACE_ELEMENT_TYPE_TOOL = "org.eclipse.papyrus.infra.elementtypesconfigurations.tests.tool"; //$NON-NLS-1$
@@ -38,4 +38,13 @@ public interface ITestConstants {
static final String COMPONENT_NAME = "Component1"; //$NON-NLS-1$
+ static final String CYCLIC_ADVICES_CONFIGURATIONS = "platform:/plugin/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/cyclicAdvices.elementtypesconfigurations";
+
+ static final String VALID_ADVICES_ORDER_CONFIGURATIONS = "platform:/plugin/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/model/validAdvicesOrder.elementtypesconfigurations";
+
+ static final String ADVICES_ID_1 = "org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice1";
+ static final String ADVICES_ID_2 = "org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice2";
+ static final String ADVICES_ID_3 = "org.eclipse.papyrus.infra.elementtypesconfigurations.tests.TestEditHelperAdvice3";
+
+
}
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice1.java b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice1.java
new file mode 100644
index 00000000000..1b9f3e552ab
--- /dev/null
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice1.java
@@ -0,0 +1,20 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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.infra.elementtypesconfigurations.tests;
+
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+
+public class TestEditHelperAdvice1 extends AbstractEditHelperAdvice {
+
+}
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice2.java b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice2.java
new file mode 100644
index 00000000000..a4472a6125d
--- /dev/null
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice2.java
@@ -0,0 +1,20 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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.infra.elementtypesconfigurations.tests;
+
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+
+public class TestEditHelperAdvice2 extends AbstractEditHelperAdvice {
+
+}
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice3.java b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice3.java
new file mode 100644
index 00000000000..cfa4994160d
--- /dev/null
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/tests/TestEditHelperAdvice3.java
@@ -0,0 +1,20 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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.infra.elementtypesconfigurations.tests;
+
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+
+public class TestEditHelperAdvice3 extends AbstractEditHelperAdvice {
+
+}
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests/META-INF/MANIFEST.MF
index 619a5e42414..c6ed73d54d2 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests/META-INF/MANIFEST.MF
@@ -6,7 +6,10 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.papyrus.infra.elementtypesconfigurations;bundle-version="1.2.0",
org.eclipse.papyrus.junit.utils;bundle-version="1.2.0",
org.eclipse.papyrus.infra.elementtypesconfigurations.ui;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.elementtypesconfigurations.tests;bundle-version="1.2.0"
+ org.eclipse.papyrus.infra.elementtypesconfigurations.tests;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.services.edit,
+ org.eclipse.gmf.runtime.emf.type.core,
+ org.eclipse.papyrus.infra.core
Export-Package: org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/ui/tests/ElementTypesRegistryTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/ui/tests/ElementTypesRegistryTests.java
index 938a12326af..135f2ecc549 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/ui/tests/ElementTypesRegistryTests.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.elementtypesconfigurations.ui.tests/src/org/eclipse/papyrus/infra/elementtypesconfigurations/ui/tests/ElementTypesRegistryTests.java
@@ -23,10 +23,11 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.internal.ui.preferences.ElementTypesPreferences;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.elementtypesconfigurations.registries.ElementTypeSetConfigurationRegistry;
import org.eclipse.papyrus.infra.elementtypesconfigurations.tests.AbstractElementTypeTests;
import org.eclipse.papyrus.infra.elementtypesconfigurations.tests.ITestConstants;
+import org.eclipse.papyrus.infra.services.edit.internal.context.TypeContext;
import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -59,14 +60,25 @@ public class ElementTypesRegistryTests extends AbstractElementTypeTests implemen
}
/**
+ * Test registration based on plugin declaration
+ */
+ @Test
+ // transcoded from extended types framework
+ public final void testGetTypeRegisteredInplugin() {
+ // check standard class
+ IElementType classType = ElementTypeRegistry.getInstance().getType(ORG_ECLIPSE_PAPYRUS_UML_CLASS);
+ Assert.assertNotNull("Element type should be registered", classType);
+ IElementType abstractClassType = ElementTypeRegistry.getInstance().getType(ABSTRACT_CLASS_TOOL);
+ Assert.assertNotNull("Element type should be registered", abstractClassType);
+ }
+
+ /**
* Test workspace registration. Element type in the workspace, but element type set is not loaded
*/
@Test
// transcoded from extended types framework
public final void testGetTypeRegisteredInWorkspaceNotLoaded() {
checkPluginTypes();
- // no preference should be set for this test
- ElementTypesPreferences.unregisterWorkspaceDefinition(WORKSPACE_ELEMENT_TYPE_ID);
// this should not be defined yet
IElementType workspaceType = ElementTypeRegistry.getInstance().getType(WORKSPACE_ELEMENT_TYPE_TOOL);
Assert.assertNull("Element type should not be registered yet", workspaceType);
@@ -83,19 +95,22 @@ public class ElementTypesRegistryTests extends AbstractElementTypeTests implemen
Assert.assertNull("Element type should not be registered yet", workspaceType);
checkPluginTypes();
// register
- System.out.println(WORKSPACE_ELEMENT_TYPE_ID + "=" + workspaceTestFile.getFullPath().toString());
- ElementTypesPreferences.registerWorkspaceDefinition(WORKSPACE_ELEMENT_TYPE_ID, workspaceTestFile.getFullPath().toString());
- ElementTypeSetConfigurationRegistry.getInstance().loadElementTypeSetConfiguration(WORKSPACE_ELEMENT_TYPE_ID);
- //
- workspaceType = ElementTypeRegistry.getInstance().getType(WORKSPACE_ELEMENT_TYPE_TOOL);
- Assert.assertNotNull("Element type should be registered", workspaceType);
- checkPluginTypes();
- // unregister
- ElementTypesPreferences.unregisterWorkspaceDefinition(WORKSPACE_ELEMENT_TYPE_ID);
- ElementTypeSetConfigurationRegistry.getInstance().unload(WORKSPACE_ELEMENT_TYPE_ID);
- workspaceType = ElementTypeRegistry.getInstance().getType(WORKSPACE_ELEMENT_TYPE_TOOL);
- Assert.assertNull("Element type should not be registered anymore", workspaceType);
- checkPluginTypes();
+ try {
+ ElementTypeSetConfigurationRegistry.getInstance().loadElementTypeSetConfiguration(TypeContext.getContext().getId(), workspaceTestFile.getFullPath().toString());
+
+ //
+ workspaceType = ElementTypeRegistry.getInstance().getType(WORKSPACE_ELEMENT_TYPE_TOOL);
+ Assert.assertNotNull("Element type should be registered", workspaceType);
+ checkPluginTypes();
+ // unregister
+ ElementTypeSetConfigurationRegistry.getInstance().unload(TypeContext.getContext().getId(), WORKSPACE_ELEMENT_TYPE_ID);
+ workspaceType = ElementTypeRegistry.getInstance().getType(WORKSPACE_ELEMENT_TYPE_TOOL);
+ Assert.assertNull("Element type should not be registered anymore", workspaceType);
+ checkPluginTypes();
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
/**
@@ -107,4 +122,6 @@ public class ElementTypesRegistryTests extends AbstractElementTypeTests implemen
IElementType abstractClassType = ElementTypeRegistry.getInstance().getType(ABSTRACT_CLASS_TOOL);
Assert.assertNotNull("Element type should be registered", abstractClassType);
}
+
+
}
diff --git a/tests/junit/plugins/infra/gmfdiag/assistant/org.eclipse.papyrus.infra.gmfdiag.assistant.tests/src/org/eclipse/papyrus/infra/gmfdiag/assistant/tests/AssistantsFixture.java b/tests/junit/plugins/infra/gmfdiag/assistant/org.eclipse.papyrus.infra.gmfdiag.assistant.tests/src/org/eclipse/papyrus/infra/gmfdiag/assistant/tests/AssistantsFixture.java
index 081968a289c..a32806e8cfa 100644
--- a/tests/junit/plugins/infra/gmfdiag/assistant/org.eclipse.papyrus.infra.gmfdiag.assistant.tests/src/org/eclipse/papyrus/infra/gmfdiag/assistant/tests/AssistantsFixture.java
+++ b/tests/junit/plugins/infra/gmfdiag/assistant/org.eclipse.papyrus.infra.gmfdiag.assistant.tests/src/org/eclipse/papyrus/infra/gmfdiag/assistant/tests/AssistantsFixture.java
@@ -14,11 +14,12 @@
package org.eclipse.papyrus.infra.gmfdiag.assistant.tests;
import java.net.URL;
-import java.util.Collections;
+import java.util.HashMap;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeSetConfiguration;
import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementtypesconfigurationsPackage;
import org.eclipse.papyrus.infra.elementtypesconfigurations.registries.ElementTypeSetConfigurationRegistry;
@@ -26,6 +27,7 @@ import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.gmfdiag.assistant.core.IModelingAssistantModelProvider;
import org.eclipse.papyrus.infra.gmfdiag.assistant.internal.core.DefaultModelingAssistantModelProvider;
import org.eclipse.papyrus.infra.gmfdiag.assistant.internal.core.ModelingAssistantModelRegistry;
+import org.eclipse.papyrus.infra.services.edit.internal.context.TypeContext;
import org.eclipse.papyrus.junit.utils.JUnitUtils;
import org.eclipse.uml2.uml.util.UMLUtil;
import org.junit.rules.TestWatcher;
@@ -61,10 +63,27 @@ public class AssistantsFixture extends TestWatcher {
URI elementTypesModelURI = getModelURI(assistantsModelPath.replaceFirst("\\.assistants$", ".elementtypesconfigurations"), description);
if (elementTypesModelURI != null) {
ElementTypeSetConfiguration elementTypes = UMLUtil.load(resourceSet, elementTypesModelURI, ElementtypesconfigurationsPackage.Literals.ELEMENT_TYPE_SET_CONFIGURATION);
- ElementTypeSetConfigurationRegistry.getInstance().loadElementTypeSetConfigurations(Collections.singleton(elementTypes));
+
+ try {
+ ElementTypeSetConfigurationRegistry.getInstance().loadElementTypeSetConfiguration(TypeContext.getContext().getId(), (ElementTypeSetConfiguration) elementTypes);
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
elementTypesID = JUnitUtils.getTestClass(description).getName();
- ElementTypeSetConfigurationRegistry.getInstance().getElementTypeSetConfigurations().put(elementTypesID, elementTypes);
+
+ try {
+ String contextId = TypeContext.getContext().getId();
+
+ if (!ElementTypeSetConfigurationRegistry.getInstance().getElementTypeSetConfigurations().containsKey(contextId)) {
+ ElementTypeSetConfigurationRegistry.getInstance().getElementTypeSetConfigurations().put(contextId, new HashMap<String, ElementTypeSetConfiguration>());
+ }
+ ElementTypeSetConfigurationRegistry.getInstance().getElementTypeSetConfigurations().get(contextId).put(elementTypesID, elementTypes);
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
// And then the assistants that reference them
@@ -89,7 +108,14 @@ public class AssistantsFixture extends TestWatcher {
assistantModelProvider = null;
if (elementTypesID != null) {
- ElementTypeSetConfigurationRegistry.getInstance().unload(elementTypesID);
+ try {
+ String contextId = TypeContext.getContext().getId();
+
+ ElementTypeSetConfigurationRegistry.getInstance().unload(contextId, elementTypesID);
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
EMFHelper.unload(resourceSet);
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/fragment.xml b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/fragment.xml
index 4760815ced0..8ed905b33b7 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/fragment.xml
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/fragment.xml
@@ -4,7 +4,7 @@
<extension
point="org.eclipse.papyrus.infra.elementtypesconfigurations.elementTypeSetConfiguration">
<elementTypeSet
- id="org.eclipse.papyrus.infra.gmfdiag.common.tests.testexpansiondiagram"
+ clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
path="models/TestExpansionDiagram.elementtypesconfigurations">
</elementTypeSet>
</extension>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/plugin.xml b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/plugin.xml
index 013e1243d48..626214771f3 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/plugin.xml
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/plugin.xml
@@ -4,7 +4,7 @@
<extension
point="org.eclipse.papyrus.infra.elementtypesconfigurations.elementTypeSetConfiguration">
<elementTypeSet
- id="org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests.elementTypeSet"
+ clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
path="resources/TestPalette.elementtypesconfigurations">
</elementTypeSet>
</extension>
@@ -33,7 +33,7 @@
<extension
point="org.eclipse.papyrus.infra.elementtypesconfigurations.elementTypeSetConfiguration">
<elementTypeSet
- id="org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests.elementTypeSet"
+ clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
path="resources/FakeProfile.elementtypesconfigurations">
</elementTypeSet>
</extension>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/resources/FakeProfile.elementtypesconfigurations b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/resources/FakeProfile.elementtypesconfigurations
index 0cb788ff33b..fc0db65c2a3 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/resources/FakeProfile.elementtypesconfigurations
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/resources/FakeProfile.elementtypesconfigurations
@@ -7,9 +7,9 @@
xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.0"
xmlns:stereotypeapplicationmatcherconfiguration="http://www.eclipse.org/payrus/elementtypesconfigurations/uml/stereotypematcherconfiguration"
xmi:id="_ubJcsKeUEeSUR5jX0TaAcA"
- name="TestPaletteConfiguration"
+ name="FakeProfile"
description="Element types configuration for test palette configuration plugin"
- identifier="org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests"
+ identifier="org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests.FakeProfile"
metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML">
<elementTypeConfigurations
xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/resources/TestPalette.elementtypesconfigurations b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/resources/TestPalette.elementtypesconfigurations
index 9846199b7dc..4ba0f0e10c6 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/resources/TestPalette.elementtypesconfigurations
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests/resources/TestPalette.elementtypesconfigurations
@@ -9,7 +9,7 @@
xmi:id="_ubJcsKeUEeSUR5jX0TaAcA"
name="TestPaletteConfiguration"
description="Element types configuration for test palette configuration plugin"
- identifier="org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests"
+ identifier="org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests.TestPaletteConfiguration"
metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML">
<elementTypeConfigurations
xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"

Back to the top