diff options
author | Vincent Lorenzo | 2018-01-25 09:55:47 +0000 |
---|---|---|
committer | vincent lorenzo | 2018-02-13 12:16:23 +0000 |
commit | cdd8be15a6787f5536a9d462b722152c4fb9aabb (patch) | |
tree | 89606772c568143b18f54d286590a648ee26a99f /tests/junit | |
parent | 720b4dde8e141f3428e44ad4a9c2a6f00227b724 (diff) | |
download | org.eclipse.papyrus-cdd8be15a6787f5536a9d462b722152c4fb9aabb.tar.gz org.eclipse.papyrus-cdd8be15a6787f5536a9d462b722152c4fb9aabb.tar.xz org.eclipse.papyrus-cdd8be15a6787f5536a9d462b722152c4fb9aabb.zip |
bug 530155: [Performance] NamedElementUtil.computeDefaultNameWithIncrementFromBase must be improved and provide a naming strategy
- implements a preference
- add the documentation
- update JUnit tests to force concerned tests to use the previous behavior
Change-Id: I5e68fafc37299ffc4c1a0e18f4b1960e7ce8f010
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'tests/junit')
15 files changed, 173 insertions, 78 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/META-INF/MANIFEST.MF index f6ae19bf1a1..fefdf552856 100755 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/META-INF/MANIFEST.MF @@ -22,7 +22,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.infra.emf;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.services.openelement;bundle-version="[3.0.0,4.0.0)", org.eclipse.core.expressions, - org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.3.0,4.0.0)", org.eclipse.xtend.lib;bundle-version="2.8.3", org.eclipse.xtext.xbase.lib;bundle-version="2.8.3", org.eclipse.papyrus.tests.framework;bundle-version="[1.2.0,2.0.0)", @@ -40,7 +40,7 @@ Export-Package: org.eclipse.papyrus.uml.diagram.clazz.test, org.eclipse.papyrus.uml.diagram.clazz.tests.generation Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 1.2.0.qualifier +Bundle-Version: 1.3.0.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-ManifestVersion: 2 diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/pom.xml b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/pom.xml index bf476b755ec..6873b4ffcae 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/pom.xml +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/pom.xml @@ -10,7 +10,7 @@ </parent> <groupId>org.eclipse.papyrus.tests</groupId> <artifactId>org.eclipse.papyrus.uml.diagram.clazz.tests</artifactId> - <version>1.2.0-SNAPSHOT</version> + <version>1.3.0-SNAPSHOT</version> <packaging>eclipse-test-plugin</packaging> <properties> diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/copyPaste/ConstraintPasteStrategyTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/copyPaste/ConstraintPasteStrategyTest.java index eab1ea0483d..02a4c47d2d1 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/copyPaste/ConstraintPasteStrategyTest.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/copyPaste/ConstraintPasteStrategyTest.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 CEA LIST. + * Copyright (c) 2014, 2018 CEA LIST. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -9,6 +9,7 @@ * Contributors: * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net- bug430548 + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - bug 530155 *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.clazz.test.copyPaste; @@ -35,12 +36,16 @@ import org.eclipse.papyrus.junit.utils.rules.ShowView; import org.eclipse.papyrus.uml.diagram.clazz.custom.edit.part.CustomConstraintEditPart; import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart; import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelEditPart; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NameElementNamingStrategyPreferenceInitializer; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NamedElementIndexNamingStrategyEnum; import org.eclipse.ui.ISelectionService; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.services.IEvaluationService; import org.eclipse.uml2.uml.Model; +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -64,12 +69,20 @@ public class ConstraintPasteStrategyTest extends AbstractPapyrusTest { public final static String CLASS1_NAME = "Class1"; //$NON-NLS-1$ - public final static String COPY_CLASS1_NAME = "CopyOf_Class1_1"; //$NON-NLS-N$; + public final static String COPY_CLASS1_NAME = "CopyOf_Class1_1"; //$NON-NLS-1$; public final static String CONSTRAINT_NAME = "Constraint1"; //$NON-NLS-1$ public final static String DIAGRAM_NAME = "ConstraintClassDiagram"; //$NON-NLS-1$ + /** + * @since 1.3 + */ + @Before + public void setUp() { + // we set the default naming strategy, to preserve a previous test behavior + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setValue(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION, NamedElementIndexNamingStrategyEnum.UNIQUE_INDEX_INITIALIZATION.getName()); + } /** * Test copy constraint in class diagram. @@ -101,7 +114,7 @@ public class ConstraintPasteStrategyTest extends AbstractPapyrusTest { Object defaultSelectionHandler = getSelectionLikeInAbstractGraphicalHandler(); editorFixture.flushDisplayEvents(); - Assert.assertNotNull("Constraint TreeElement is null", defaultSelection); //$NON-NLS-1$ + Assert.assertNotNull("Constraint TreeElement is null", defaultSelection); //$NON-NLS-1$ Assert.assertEquals("TreeElement is not a model", ModelEditPart.class, defaultSelection.getClass()); Assert.assertEquals("TreeElement is not a model", ModelEditPart.class, defaultSelectionHandler.getClass()); @@ -157,7 +170,7 @@ public class ConstraintPasteStrategyTest extends AbstractPapyrusTest { editorFixture.flushDisplayEvents(); // Check that there is a copy of Constraint - Assert.assertEquals("The copy failed", amountRulesBeforeCopy + 1, class1.getOwnedRules().size()); //$NON-NLS-1$ + Assert.assertEquals("The copy failed", amountRulesBeforeCopy + 1, class1.getOwnedRules().size()); //$NON-NLS-1$ } @@ -185,7 +198,7 @@ public class ConstraintPasteStrategyTest extends AbstractPapyrusTest { Object defaultSelectionHandler = getSelectionLikeInAbstractGraphicalHandler(); editorFixture.flushDisplayEvents(); - Assert.assertNotNull("Constraint TreeElement is null", defaultSelection); //$NON-NLS-1$ + Assert.assertNotNull("Constraint TreeElement is null", defaultSelection); //$NON-NLS-1$ Assert.assertEquals("TreeElement is not a model", ModelEditPart.class, defaultSelection.getClass()); Assert.assertEquals("TreeElement is not a model", ModelEditPart.class, defaultSelectionHandler.getClass()); @@ -199,7 +212,7 @@ public class ConstraintPasteStrategyTest extends AbstractPapyrusTest { ISelectionService selectionService = activeWorkbenchWindow.getSelectionService(); Object constraintSelection = ((IStructuredSelection) selectionService.getSelection()).toList().get(0); Object classSelection = ((IStructuredSelection) selectionService.getSelection()).toList().get(1); - + // it's working on service selection Assert.assertEquals("TreeElement is not a constraint", CustomConstraintEditPart.class, constraintSelection.getClass()); Assert.assertEquals("TreeElement is not a class", ClassEditPart.class, classSelection.getClass()); @@ -272,6 +285,15 @@ public class ConstraintPasteStrategyTest extends AbstractPapyrusTest { return ((IStructuredSelection) selectionService.getSelection()).getFirstElement(); } - + /** + * + * @throws Exception + * @since 1.3 + */ + @After + public void tearDown() throws Exception { + // we reset the naming strategy to its initial value + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setToDefault(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION); + } } diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF index 4d704655dbc..2597b06a08f 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF @@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.papyrus.uml.tools;bundle-version="[4.0.0,5.0.0)", org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)", org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.3.0,4.0.0)", org.eclipse.ui.ide;bundle-version="3.8.0", org.eclipse.papyrus.infra.core.sasheditor;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.widgets;bundle-version="[3.0.0,4.0.0)", @@ -22,7 +22,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.papyrus.infra.emf;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.junit.utils;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)", - org.eclipse.papyrus.uml.diagram.tests;bundle-version="[1.2.0,2.0.0)" + org.eclipse.papyrus.uml.diagram.tests;bundle-version="[1.3.0,2.0.0)" Export-Package: org.eclipse.papyrus.uml.diagram.stereotypeproperty Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/META-INF/MANIFEST.MF index e4debbdb784..cd7ee6787e9 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/META-INF/MANIFEST.MF @@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.junit.utils;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.uml.diagram.profile;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.emf.appearance;bundle-version="[2.0.0,3.0.0)", - org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.3.0,4.0.0)", org.eclipse.papyrus.junit.framework;bundle-version="[1.2.0,2.0.0)", org.eclipse.papyrus.views.modelexplorer;bundle-version="[3.0.0,4.0.0)", org.eclipse.xtend.lib, @@ -48,7 +48,7 @@ Export-Package: org.eclipse.papyrus.uml.diagram.tests.appearance, org.eclipse.papyrus.uml.diagram.tests.synchronization Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 1.2.100.qualifier +Bundle-Version: 1.3.0.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-ManifestVersion: 2 diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/pom.xml b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/pom.xml index f13d8b788d2..4d76b6e8a3b 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/pom.xml +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/pom.xml @@ -9,6 +9,6 @@ </parent> <groupId>org.eclipse.papyrus.tests</groupId> <artifactId>org.eclipse.papyrus.uml.diagram.tests</artifactId> - <version>1.2.100-SNAPSHOT</version> + <version>1.3.0-SNAPSHOT</version> <packaging>eclipse-test-plugin</packaging> </project> diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/AbstractPapyrusTestCase.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/AbstractPapyrusTestCase.java index 766ff302022..ace07425c5c 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/AbstractPapyrusTestCase.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/AbstractPapyrusTestCase.java @@ -12,7 +12,7 @@ * Christian W. Damus (CEA) - bug 436047 * Christian W. Damus - bug 473183 * Christian W. Damus - bug 464647 - * + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - bug 530155 *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.tests.canonical; @@ -68,6 +68,8 @@ import org.eclipse.papyrus.uml.diagram.common.part.UmlGmfDiagramEditor; import org.eclipse.papyrus.uml.diagram.profile.CreateProfileModelCommand; import org.eclipse.papyrus.uml.tools.model.UmlModel; import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NameElementNamingStrategyPreferenceInitializer; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NamedElementIndexNamingStrategyEnum; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.intro.IIntroPart; @@ -167,6 +169,8 @@ public abstract class AbstractPapyrusTestCase extends AbstractPapyrusTest { store.setValue(alwaysCreateLinkPreferenceName, true); store.setDefault(alwaysCreateLinkPreferenceName, true); + // we set the default naming strategy, to preserve a previous test behavior + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setValue(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION, NamedElementIndexNamingStrategyEnum.UNIQUE_INDEX_INITIALIZATION.getName()); suiteState.setupTest(); } @@ -201,6 +205,9 @@ public abstract class AbstractPapyrusTestCase extends AbstractPapyrusTest { @After public void tearDown() throws Exception { suiteState.teardownTest(); + + // we reset the naming strategy to its initial value + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setToDefault(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION); } void doTearDown() throws Exception { diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF index ca16b1c5079..3eca7519662 100644 --- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.papyrus.views.modelexplorer.tests;bundle-version="[1.2.0,2.0.0)", - org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.3.0,4.0.0)", org.eclipse.emf.ecore, org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)", org.eclipse.ui.navigator, @@ -26,7 +26,7 @@ Export-Package: org.eclipse.papyrus.uml.modelexplorer.tests, org.eclipse.papyrus.uml.modelexplorer.tests.paste Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 1.2.0.qualifier +Bundle-Version: 1.3.0.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-ManifestVersion: 2 diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/pom.xml b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/pom.xml index 40e241f270a..4409ff0cab9 100644 --- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/pom.xml +++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/pom.xml @@ -9,6 +9,6 @@ </parent> <groupId>org.eclipse.papyrus.tests</groupId> <artifactId>org.eclipse.papyrus.uml.modelexplorer.tests</artifactId> - <version>1.2.0-SNAPSHOT</version> + <version>1.3.0-SNAPSHOT</version> <packaging>eclipse-test-plugin</packaging> </project> diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CopyPasteModelExplorerTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CopyPasteModelExplorerTest.java index ccab89436a2..9d020409a6c 100644 --- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CopyPasteModelExplorerTest.java +++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CopyPasteModelExplorerTest.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 CEA LIST and others. + * Copyright (c) 2014, 2018 CEA LIST and others. * * * All rights reserved. This program and the accompanying materials @@ -10,7 +10,7 @@ * Contributors: * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation * Christian W. Damus (CEA) - bug 434133 - * + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - bug 530155 *****************************************************************************/ package org.eclipse.papyrus.uml.modelexplorer.tests.paste; @@ -25,11 +25,14 @@ import org.eclipse.papyrus.junit.utils.HandlerUtils; import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest; import org.eclipse.papyrus.uml.modelexplorer.tests.Activator; import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NameElementNamingStrategyPreferenceInitializer; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NamedElementIndexNamingStrategyEnum; import org.eclipse.ui.ISelectionService; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.uml2.uml.Model; import org.eclipse.uml2.uml.Package; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -58,7 +61,10 @@ public class CopyPasteModelExplorerTest extends AbstractEditorTest { @Before public void initModelForCutTest() { try { - initModel(PROJECT_NAME, MODEL_NAME, Activator.getDefault().getBundle()); //$NON-NLS-1$ //$NON-NLS-2$ + initModel(PROJECT_NAME, MODEL_NAME, Activator.getDefault().getBundle()); // $NON-NLS-1$ //$NON-NLS-2$ + + // we set the default naming strategy, to preserve a previous test behavior + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setValue(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION, NamedElementIndexNamingStrategyEnum.UNIQUE_INDEX_INITIALIZATION.getName()); } catch (Exception e) { Assert.fail(e.getMessage()); } @@ -69,9 +75,9 @@ public class CopyPasteModelExplorerTest extends AbstractEditorTest { return RESOURCES_PATH; } - - + + /** * Simple copy paste of a class1 * @@ -79,10 +85,10 @@ public class CopyPasteModelExplorerTest extends AbstractEditorTest { */ @Test public void copyPasteofClass1Test() throws Exception { - //get the rootModel + // get the rootModel Assert.assertNotNull("RootModel is null", getRootUMLModel()); //$NON-NLS-1$ - //get all semantic elment that will handled - Model model = (Model)getRootUMLModel(); + // get all semantic elment that will handled + Model model = (Model) getRootUMLModel(); IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ISelectionService selectionService = activeWorkbenchWindow.getSelectionService(); @@ -92,11 +98,11 @@ public class CopyPasteModelExplorerTest extends AbstractEditorTest { elements.add(getRootUMLModel()); modelExplorerView.revealSemanticElement(elements); - org.eclipse.uml2.uml.Class class1 = (org.eclipse.uml2.uml.Class)model.getPackagedElement(CLASS1_NAME); + org.eclipse.uml2.uml.Class class1 = (org.eclipse.uml2.uml.Class) model.getPackagedElement(CLASS1_NAME); elements.clear(); elements.add(class1); modelExplorerView.revealSemanticElement(elements); - Object class1TreeObject = ((IStructuredSelection)selectionService.getSelection()).getFirstElement(); + Object class1TreeObject = ((IStructuredSelection) selectionService.getSelection()).getFirstElement(); Assert.assertNotNull("Class1 TreeElement is null", class1TreeObject); //$NON-NLS-1$ IHandler copyHandler = HandlerUtils.getActiveHandlerFor(COPY_COMMAND_ID); @@ -114,9 +120,9 @@ public class CopyPasteModelExplorerTest extends AbstractEditorTest { Assert.assertTrue("Paste not available", pasteHandler.isEnabled()); //$NON-NLS-1$ pasteHandler.execute(new ExecutionEvent()); - // check that there is a Class1 - org.eclipse.uml2.uml.Class copyOfClass1 = (org.eclipse.uml2.uml.Class)model.getPackagedElement(NamedElementUtil.COPY_OF + "_" + CLASS1_NAME + "_1"); - Assert.assertNotNull("The copy is missing", copyOfClass1); //$NON-NLS-1$ + // check that there is a Class1 + org.eclipse.uml2.uml.Class copyOfClass1 = (org.eclipse.uml2.uml.Class) model.getPackagedElement(NamedElementUtil.COPY_OF + "_" + CLASS1_NAME + "_1"); + Assert.assertNotNull("The copy is missing", copyOfClass1); //$NON-NLS-1$ } /** @@ -138,48 +144,48 @@ public class CopyPasteModelExplorerTest extends AbstractEditorTest { elements.add(rootUMLModel); modelExplorerView.revealSemanticElement(elements); - //getItem for model - Object modelTreeObject = ((IStructuredSelection)selectionService.getSelection()).getFirstElement(); - Assert.assertNotNull("Model TreeElement is null", modelTreeObject); //$NON-NLS-1$ + // getItem for model + Object modelTreeObject = ((IStructuredSelection) selectionService.getSelection()).getFirstElement(); + Assert.assertNotNull("Model TreeElement is null", modelTreeObject); //$NON-NLS-1$ // copy class1 - org.eclipse.uml2.uml.Class class1 = (org.eclipse.uml2.uml.Class)rootUMLModel.getPackagedElement(CLASS1_NAME); + org.eclipse.uml2.uml.Class class1 = (org.eclipse.uml2.uml.Class) rootUMLModel.getPackagedElement(CLASS1_NAME); elements.clear(); elements.add(class1); modelExplorerView.revealSemanticElement(elements); - Object class1TreeObject = ((IStructuredSelection)selectionService.getSelection()).getFirstElement(); + Object class1TreeObject = ((IStructuredSelection) selectionService.getSelection()).getFirstElement(); Assert.assertNotNull("Class1 TreeElement is null", class1TreeObject); //$NON-NLS-1$ IHandler copyHandler = HandlerUtils.getActiveHandlerFor(COPY_COMMAND_ID); Assert.assertTrue("Copy not available", copyHandler.isEnabled()); //$NON-NLS-1$ - copyHandler.execute(new ExecutionEvent()); - - //get read only item + copyHandler.execute(new ExecutionEvent()); + + // get read only item EList<Package> importedPackages = rootUMLModel.getImportedPackages(); Package primitiveTypes = importedPackages.get(0); elements.clear(); elements.add(primitiveTypes); modelExplorerView.revealSemanticElement(elements); - Object treeObject = ((IStructuredSelection)selectionService.getSelection()).getFirstElement(); + Object treeObject = ((IStructuredSelection) selectionService.getSelection()).getFirstElement(); Assert.assertNotNull("PrimitiveTypes TreeElement is null", treeObject); //$NON-NLS-1$ IHandler pasteHandler = HandlerUtils.getActiveHandlerFor(PASTE_COMMAND_ID); - Assert.assertFalse("Paste is available on a readonly element", pasteHandler.isEnabled()); //$NON-NLS-1$ + Assert.assertFalse("Paste is available on a readonly element", pasteHandler.isEnabled()); //$NON-NLS-1$ } - - - + + + /** * Simple copy pasteof class1 & class2 test. */ @Test public void copyPasteofClass1And2Test() throws Exception { - //get the rootModel + // get the rootModel Assert.assertNotNull("RootModel is null", getRootUMLModel()); //$NON-NLS-1$ - //get all semantic elment that will handled - Model model = (Model)getRootUMLModel(); + // get all semantic elment that will handled + Model model = (Model) getRootUMLModel(); IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ISelectionService selectionService = activeWorkbenchWindow.getSelectionService(); @@ -189,17 +195,17 @@ public class CopyPasteModelExplorerTest extends AbstractEditorTest { elements.add(getRootUMLModel()); modelExplorerView.revealSemanticElement(elements); - org.eclipse.uml2.uml.Class class1 = (org.eclipse.uml2.uml.Class)model.getPackagedElement(CLASS1_NAME); - org.eclipse.uml2.uml.Class class2 = (org.eclipse.uml2.uml.Class)model.getPackagedElement(CLASS2_NAME); + org.eclipse.uml2.uml.Class class1 = (org.eclipse.uml2.uml.Class) model.getPackagedElement(CLASS1_NAME); + org.eclipse.uml2.uml.Class class2 = (org.eclipse.uml2.uml.Class) model.getPackagedElement(CLASS2_NAME); elements.clear(); elements.add(class1); elements.add(class2); modelExplorerView.revealSemanticElement(elements); - Object class1TreeObject = ((IStructuredSelection)selectionService.getSelection()).getFirstElement(); + Object class1TreeObject = ((IStructuredSelection) selectionService.getSelection()).getFirstElement(); Assert.assertNotNull("Class1 TreeElement is null", class1TreeObject); //$NON-NLS-1$ - Object class2TreeObject = ((IStructuredSelection)selectionService.getSelection()).getFirstElement(); - Assert.assertNotNull("Class2 TreeElement is null", class2TreeObject); //$NON-NLS-1$ + Object class2TreeObject = ((IStructuredSelection) selectionService.getSelection()).getFirstElement(); + Assert.assertNotNull("Class2 TreeElement is null", class2TreeObject); //$NON-NLS-1$ IHandler copyHandler = HandlerUtils.getActiveHandlerFor(COPY_COMMAND_ID); Assert.assertTrue("Copy not available", copyHandler.isEnabled()); //$NON-NLS-1$ @@ -215,12 +221,22 @@ public class CopyPasteModelExplorerTest extends AbstractEditorTest { Assert.assertTrue("Paste not available", pasteHandler.isEnabled()); //$NON-NLS-1$ pasteHandler.execute(new ExecutionEvent()); - // check that there is a Class1 - org.eclipse.uml2.uml.Class copyOfClass1 = (org.eclipse.uml2.uml.Class)model.getPackagedElement(NamedElementUtil.COPY_OF + "_" + CLASS1_NAME + "_1"); - Assert.assertNotNull("The class1 copy is missing", copyOfClass1); //$NON-NLS-1$ + // check that there is a Class1 + org.eclipse.uml2.uml.Class copyOfClass1 = (org.eclipse.uml2.uml.Class) model.getPackagedElement(NamedElementUtil.COPY_OF + "_" + CLASS1_NAME + "_1"); + Assert.assertNotNull("The class1 copy is missing", copyOfClass1); //$NON-NLS-1$ - org.eclipse.uml2.uml.Class copyOfClass2 = (org.eclipse.uml2.uml.Class)model.getPackagedElement(NamedElementUtil.COPY_OF + "_" + CLASS2_NAME + "_1"); - Assert.assertNotNull("The class2 copy is missing", copyOfClass2); //$NON-NLS-1$ + org.eclipse.uml2.uml.Class copyOfClass2 = (org.eclipse.uml2.uml.Class) model.getPackagedElement(NamedElementUtil.COPY_OF + "_" + CLASS2_NAME + "_1"); + Assert.assertNotNull("The class2 copy is missing", copyOfClass2); //$NON-NLS-1$ } + /** + * + * @throws Exception + * @since 1.3 + */ + @After + public void tearDown() throws Exception { + // we reset the naming strategy to its initial value + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setToDefault(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION); + } } diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CutPasteModelExplorerTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CutPasteModelExplorerTest.java index 6efefc68520..4f5120e0eb3 100644 --- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CutPasteModelExplorerTest.java +++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CutPasteModelExplorerTest.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 CEA LIST and others. + * Copyright (c) 2014, 2018 CEA LIST and others. * * * All rights reserved. This program and the accompanying materials @@ -10,7 +10,7 @@ * Contributors: * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation * Christian W. Damus (CEA) - bug 434133 - * + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - bug 530155 *****************************************************************************/ package org.eclipse.papyrus.uml.modelexplorer.tests.paste; @@ -25,12 +25,15 @@ import org.eclipse.papyrus.junit.utils.HandlerUtils; import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest; import org.eclipse.papyrus.uml.modelexplorer.tests.Activator; import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NameElementNamingStrategyPreferenceInitializer; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NamedElementIndexNamingStrategyEnum; import org.eclipse.ui.ISelectionService; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.uml2.uml.Model; import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.PackageableElement; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -60,6 +63,9 @@ public class CutPasteModelExplorerTest extends AbstractEditorTest { public void initModelForCutTest() { try { initModel(PROJECT_NAME, MODEL_NAME, Activator.getDefault().getBundle()); //$NON-NLS-1$ //$NON-NLS-2$ + + //we set the default naming strategy, to preserve a previous test behavior + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setValue(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION, NamedElementIndexNamingStrategyEnum.UNIQUE_INDEX_INITIALIZATION.getName()); } catch (Exception e) { Assert.fail(e.getMessage()); } @@ -190,5 +196,16 @@ public class CutPasteModelExplorerTest extends AbstractEditorTest { org.eclipse.uml2.uml.Class secondCopyOfClass1 = (org.eclipse.uml2.uml.Class)model.getPackagedElement(NamedElementUtil.COPY_OF + "_" + CLASS1_NAME + "_1"); Assert.assertNotNull("The copy second is missing", secondCopyOfClass1); //$NON-NLS-1$ } + + /** + * + * @throws Exception + * @since 1.3 + */ + @After + public void tearDown() throws Exception { + // we reset the naming strategy to its initial value + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setToDefault(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION); + } } diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/StereotypeCopyPasteModelExplorerTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/StereotypeCopyPasteModelExplorerTest.java index 859d64e4bd2..f02f4ef0e3d 100644 --- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/StereotypeCopyPasteModelExplorerTest.java +++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/StereotypeCopyPasteModelExplorerTest.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 CEA LIST and others. + * Copyright (c) 2014, 2018 CEA LIST and others. * * * All rights reserved. This program and the accompanying materials @@ -10,7 +10,7 @@ * Contributors: * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation * Gabriel Pascual (ALL4TEC gabriel.pascual@all4tec.net - bug 438511 - * + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - bug 530155 *****************************************************************************/ package org.eclipse.papyrus.uml.modelexplorer.tests.paste; @@ -26,13 +26,17 @@ import org.eclipse.papyrus.junit.utils.HandlerUtils; import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture; import org.eclipse.papyrus.junit.utils.rules.PluginResource; import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NameElementNamingStrategyPreferenceInitializer; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NamedElementIndexNamingStrategyEnum; import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView; import org.eclipse.ui.ISelectionService; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.uml2.uml.Model; import org.eclipse.uml2.uml.Stereotype; +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -56,14 +60,19 @@ public class StereotypeCopyPasteModelExplorerTest extends AbstractPapyrusTest { // information on the stereotype public final static String STEREOTYPE_QN = "profile::First"; //$NON-NLS-1$ - public final static String PARENT_STEREOTYPE_PROPERTY = "parentProperty"; //$NON-NLS-1$ + public final static String PARENT_STEREOTYPE_PROPERTY = "parentProperty"; //$NON-NLS-1$ public final static String PARENT_STEREOTYPE_PROPERTY_VALUE = "child"; //$NON-NLS-1$ public final static String STEREOTYPE_PROPERTY = "childProperty"; //$NON-NLS-1$ - public final static Double STEREOTYPE_PROPERTY_VALUE = 2.3; //$NON-NLS-1$ + public final static Double STEREOTYPE_PROPERTY_VALUE = 2.3; // $NON-NLS-1$ + @Before + public void setUp() { + // we set the default naming strategy, to preserve a previous test behavior + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setValue(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION, NamedElementIndexNamingStrategyEnum.UNIQUE_INDEX_INITIALIZATION.getName()); + } /** * Simple copy paste of a class1 with <<requirememt>> stereotype @@ -118,8 +127,16 @@ public class StereotypeCopyPasteModelExplorerTest extends AbstractPapyrusTest { } - - + /** + * + * @throws Exception + * @since 1.3 + */ + @After + public void tearDown() throws Exception { + // we reset the naming strategy to its initial value + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setToDefault(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION); + } } diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/META-INF/MANIFEST.MF index 9cbac593311..903221bfaf5 100644 --- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/META-INF/MANIFEST.MF @@ -5,14 +5,14 @@ Require-Bundle: org.eclipse.ui, org.junit;bundle-version="4.10.0", org.eclipse.papyrus.junit.framework;bundle-version="[1.2.0,2.0.0)", org.eclipse.emf.transaction;bundle-version="1.4.0", - org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.3.0,4.0.0)", org.eclipse.papyrus.infra.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.junit.utils;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.uml.dynamic.profile.tests;bundle-version="[1.2.0,2.0.0)" Export-Package: org.eclipse.papyrus.uml.tools.utils.tests.tests Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 1.2.100.qualifier +Bundle-Version: 1.3.0.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-ManifestVersion: 2 diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/pom.xml b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/pom.xml index ddc6e8d05ae..e5f2385349d 100644 --- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/pom.xml +++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/pom.xml @@ -9,6 +9,6 @@ </parent> <groupId>org.eclipse.papyrus.tests</groupId> <artifactId>org.eclipse.papyrus.uml.tools.utils.tests</artifactId> - <version>1.2.100-SNAPSHOT</version> + <version>1.3.0-SNAPSHOT</version> <packaging>eclipse-test-plugin</packaging> </project> diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/src/org/eclipse/papyrus/uml/tools/utils/tests/tests/NamedElementUtilTest.java b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/src/org/eclipse/papyrus/uml/tools/utils/tests/tests/NamedElementUtilTest.java index c813f0a4ffd..5f01e1f771f 100644 --- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/src/org/eclipse/papyrus/uml/tools/utils/tests/tests/NamedElementUtilTest.java +++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils.tests/src/org/eclipse/papyrus/uml/tools/utils/tests/tests/NamedElementUtilTest.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 CEA LIST and others. + * Copyright (c) 2014, 2018 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 @@ -8,7 +8,7 @@ * * Contributors: * CEA LIST - Initial API and implementation - * + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - bug 530155 *****************************************************************************/ package org.eclipse.papyrus.uml.tools.utils.tests.tests; @@ -23,6 +23,8 @@ import java.util.Collections; import org.eclipse.papyrus.junit.utils.rules.HouseKeeper; import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NameElementNamingStrategyPreferenceInitializer; +import org.eclipse.papyrus.uml.tools.utils.internal.preferences.NamedElementIndexNamingStrategyEnum; import org.eclipse.uml2.common.util.UML2Util; import org.eclipse.uml2.uml.Activity; import org.eclipse.uml2.uml.AggregationKind; @@ -43,6 +45,7 @@ import org.eclipse.uml2.uml.Transition; import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLFactory; import org.eclipse.uml2.uml.UMLPackage; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -71,7 +74,7 @@ public class NamedElementUtilTest { private Transition transition; private Message message; - + private GeneralOrdering generalOrdering; public NamedElementUtilTest() { @@ -125,20 +128,23 @@ public class NamedElementUtilTest { @Before public void createTestModel() { + // we set the default naming strategy, to preserve a previous test behavior + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setValue(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION, NamedElementIndexNamingStrategyEnum.UNIQUE_INDEX_INITIALIZATION.getName()); + testModel = autoName(UMLFactory.eINSTANCE.createModel()); class_ = autoName(testModel.createOwnedClass(null, false)); association = autoName(class_.createAssociation(true, AggregationKind.NONE_LITERAL, "foo", 0, 1, testModel.createOwnedClass("Foo", false), false, AggregationKind.NONE_LITERAL, null, 0, LiteralUnlimitedNatural.UNLIMITED)); - associationClass = autoName((AssociationClass)testModel.createOwnedType(null, UMLPackage.Literals.ASSOCIATION_CLASS)); + associationClass = autoName((AssociationClass) testModel.createOwnedType(null, UMLPackage.Literals.ASSOCIATION_CLASS)); dependency = autoName(class_.createDependency(associationClass)); - Activity activity = autoName((Activity)class_.createOwnedBehavior(null, UMLPackage.Literals.ACTIVITY)); - controlFlow = autoName((ControlFlow)activity.createEdge(null, UMLPackage.Literals.CONTROL_FLOW)); + Activity activity = autoName((Activity) class_.createOwnedBehavior(null, UMLPackage.Literals.ACTIVITY)); + controlFlow = autoName((ControlFlow) activity.createEdge(null, UMLPackage.Literals.CONTROL_FLOW)); - StateMachine stateMachine = autoName((StateMachine)class_.createOwnedBehavior(null, UMLPackage.Literals.STATE_MACHINE)); + StateMachine stateMachine = autoName((StateMachine) class_.createOwnedBehavior(null, UMLPackage.Literals.STATE_MACHINE)); Region region = autoName(stateMachine.createRegion(null)); transition = autoName(region.createTransition(null)); - Interaction interaction = autoName((Interaction)class_.createOwnedBehavior(null, UMLPackage.Literals.INTERACTION)); + Interaction interaction = autoName((Interaction) class_.createOwnedBehavior(null, UMLPackage.Literals.INTERACTION)); message = autoName(interaction.createMessage(null)); generalOrdering = autoName(interaction.createGeneralOrdering(null)); } @@ -146,11 +152,21 @@ public class NamedElementUtilTest { <N extends NamedElement> N autoName(N element) { Collection<?> siblings = (element.eContainer() != null) ? element.eContainer().eContents() : Collections.EMPTY_LIST; String name = NamedElementUtil.getDefaultNameWithIncrement(element, siblings); - if(UML2Util.isEmpty(name)) { + if (UML2Util.isEmpty(name)) { assertThat(NamedElementUtil.isAutoNamed(element), is(false)); } else { element.setName(name); } return element; } + + /** + * @throws Exception + * @since 1.3 + */ + @After + public void tearDown() throws Exception { + //we reset the naming strategy to its initial value + org.eclipse.papyrus.uml.tools.utils.Activator.getDefault().getPreferenceStore().setToDefault(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION); + } } |