Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.classpath7
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.options3
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.project28
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.settings/org.eclipse.jdt.core.prefs7
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/META-INF/MANIFEST.MF31
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/about.html28
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/build.properties4
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/plugin.xml5
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/pom.xml16
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/Activator.java63
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/AllTests.java27
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/model/UMLTestModel.java168
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/StrategyTestModel.java229
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/AssociationProcessor.java147
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/ClassProcessor.java103
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/ComponentProcessor.java101
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/PropertyProcessor.java92
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/Sysml14BlockProcessor.java58
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/SysmlBlockProcessor.java64
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/tests/AbstractPropertyLifecycleTests.java316
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/tests/PropertyLifecycleTests.java434
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/utils/ITestConstants.java179
-rwxr-xr-xtests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/utils/StrategyFactory.java183
23 files changed, 2293 insertions, 0 deletions
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.classpath b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.classpath
new file mode 100755
index 00000000000..eca7bdba8f0
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.options b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.options
new file mode 100755
index 00000000000..317cc0ddabc
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.options
@@ -0,0 +1,3 @@
+# Tracing options for the org.eclipse.paprus.infra.propertylifecycle.tests plug-in
+org.eclipse.papyrus.infra.propertylifecycle.tests/debug=true
+org.eclipse.papyrus.infra.propertylifecycle.tests/debug/PLCStrategy_Tests=true
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.project b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.project
new file mode 100755
index 00000000000..fe300e531ca
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.propertylifecycle.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100755
index 00000000000..0c68a61dca8
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/META-INF/MANIFEST.MF
new file mode 100755
index 00000000000..248bd0d3693
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tests
+Bundle-SymbolicName: org.eclipse.papyrus.propertylifecycle.tests;singleton:=true
+Bundle-Version: 0.0.1.qualifier
+Bundle-Activator: org.eclipse.papyrus.propertylifecycle.tests.Activator
+Require-Bundle: org.eclipse.ui;bundle-version="3.107.0",
+ org.eclipse.core.runtime;bundle-version="3.12.0",
+ org.eclipse.papyrus.junit.utils;bundle-version="1.2.0",
+ org.eclipse.papyrus.junit.framework;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
+ org.junit;bundle-version="4.12.0",
+ org.eclipse.papyrus.propertylifecycle.model;bundle-version="0.0.1",
+ org.eclipse.core.resources,
+ org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
+ org.eclipse.emf.transaction,
+ org.eclipse.papyrus.uml.tools,
+ org.eclipse.papyrus.infra.services.edit,
+ org.eclipse.emf.validation,
+ org.eclipse.gmf.runtime.emf.type.core,
+ org.eclipse.papyrus.uml.tools.utils,
+ org.eclipse.papyrus.infra.ui,
+ org.eclipse.gmf.runtime.common.core,
+ org.eclipse.emf.ecore,
+ org.eclipse.papyrus.propertylifecycle.preferences,
+ org.eclipse.papyrus.propertylifecycle,
+ org.eclipse.papyrus.uml.diagram.wizards,
+ org.eclipse.papyrus.sysml
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.papyrus.infra.emf.gmf.command
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/about.html b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/about.html
new file mode 100755
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/build.properties b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/build.properties
new file mode 100755
index 00000000000..34d2e4d2dad
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/plugin.xml b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/plugin.xml
new file mode 100755
index 00000000000..5535690d377
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/plugin.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+</plugin>
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/pom.xml b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/pom.xml
new file mode 100755
index 00000000000..0b28a7e09a2
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/pom.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.eclipse.papyrus.infra.propertylifecycle.tests</artifactId>
+ <version>0.0.1.qualifier</version>
+ <groupId>org.eclipse.papyrus</groupId>
+ <packaging>eclipse-plugin</packaging>
+ <parent>
+ <relativePath>../org.eclipse.papyrus.infra.propertylifecycle/pom.xml</relativePath>
+ <version>0.0.1.qualifier</version>
+ <artifactId>org.eclipse.papyrus.infra.propertylifecycle</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ </parent>
+</project>
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/Activator.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/Activator.java
new file mode 100755
index 00000000000..4a1955f6f49
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/Activator.java
@@ -0,0 +1,63 @@
+package org.eclipse.papyrus.propertylifecycle.tests;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.propertylifecycle.tests"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ // The logging helper
+ public static LogHelper log;
+
+ // The traces for debug purposes (don't forget to add them in the .options and the debug configurations)
+ public static String PLCSTRATEGY_TESTS_TRACE = "PLCStrategy_Tests";
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ log = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/AllTests.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/AllTests.java
new file mode 100755
index 00000000000..1cfbe3e3d5c
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/AllTests.java
@@ -0,0 +1,27 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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:
+ * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.propertylifecycle.tests;
+
+import org.junit.runner.RunWith;
+import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite;
+import org.eclipse.papyrus.propertylifecycle.tests.tests.PropertyLifecycleTests;
+import org.junit.runners.Suite.SuiteClasses;
+
+
+/**
+ * All tests for this fragment
+ */
+@RunWith(ClassificationSuite.class)
+@SuiteClasses({ PropertyLifecycleTests.class })
+public class AllTests {
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/model/UMLTestModel.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/model/UMLTestModel.java
new file mode 100755
index 00000000000..93b875e8035
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/model/UMLTestModel.java
@@ -0,0 +1,168 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.model;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.CommonPlugin;
+import org.eclipse.emf.common.util.URI;
+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.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.papyrus.propertylifecycle.tests.Activator;
+import org.eclipse.papyrus.propertylifecycle.tests.utils.ITestConstants;
+import org.eclipse.papyrus.sysml.util.SysmlResource;
+import org.eclipse.papyrus.uml.tools.utils.CustomUMLUtil.StereotypeApplicationHelper;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Component;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+
+/**
+ * Initialize the test model with elements before the application of the strategySet
+ *
+ */
+public class UMLTestModel implements ITestConstants {
+
+ public static Model rootModel;
+
+ public static Model initUMLModel() {
+ createUMLModel();
+
+ return rootModel;
+ }
+
+ public static ResourceSet initUMLModel(IProject parentProject) throws CoreException, IOException {
+ createUMLModel();
+
+ return saveUMLModel(rootModel, parentProject);
+ }
+
+
+ public static void createUMLModel() {
+ rootModel = UMLFactory.eINSTANCE.createModel();
+ rootModel.setName(ROOTMODEL_NAME);
+
+ createClassSubPackage(rootModel);
+ createComponentPackage(rootModel);
+ createSubModel(rootModel);
+
+ }
+
+ private static ResourceSet saveUMLModel(Model rootModel, IProject parentProject) throws CoreException, IOException {
+ ResourceSet umlResourceSet = new ResourceSetImpl();
+ IFolder modelFolder = createRecursiveFolder(parentProject.getFolder(RESOURCES_FOLDERNAME));
+ URI modelURI = URI.createPlatformResourceURI(modelFolder.getFullPath().toString() + "/" + RESOURCES_UMLMODELNAME, true);
+ Resource modelResource = umlResourceSet.createResource(modelURI);
+ modelResource.getContents().add(rootModel);
+
+ try {
+ Map<Object, Object> options = new HashMap<>();
+ options.put(XMIResource.OPTION_ENCODING, RESOURCES_ENCODING);
+ modelResource.save(options);
+
+ // String filePath = "~/Desktop/";
+ // String localPath = filePath.replaceFirst("^~", System.getProperty("user.home").replace("\\", "/"));
+ // Resource desktopModelResource = modelResource;
+ // desktopModelResource.setURI(CommonPlugin.resolve(URI.createFileURI(localPath + "desktop.uml")));
+ // desktopModelResource.save(options);
+
+ return umlResourceSet;
+ } catch (IOException ioe) {
+ Activator.log.error(ioe);
+ }
+
+ return null;
+ }
+
+ public static IFolder createRecursiveFolder(IFolder folderToCreate) throws CoreException {
+ if (folderToCreate.exists()) {
+ return folderToCreate;
+ }
+
+ folderToCreate.create(true, true, new NullProgressMonitor());
+ return folderToCreate;
+ }
+
+
+
+ private static Package createClassSubPackage(Model rootModel) {
+ Package classPackage = rootModel.createNestedPackage(CLASS_PACKAGE_NAME);
+ PackageableElement newClass = classPackage.createPackagedElement(CLASS_NAME, UMLFactory.eINSTANCE.createClass().eClass());
+ Class beforeStrategyClass = (Class) newClass;
+ beforeStrategyClass.createOwnedAttribute(PROPERTY_CLASS_NAME, UMLFactory.eINSTANCE.createProperty().getType());
+
+ return classPackage;
+ }
+
+
+ private static Package createComponentPackage(Model rootModel) {
+ Package componentPackage = rootModel.createNestedPackage(COMPONENT_PACKAGE_NAME);
+ PackageableElement newComponent = componentPackage.createPackagedElement(COMPONENT_NAME, UMLFactory.eINSTANCE.createComponent().eClass());
+ Component beforeStrategyComponent = (Component) newComponent;
+ beforeStrategyComponent.createOwnedAttribute(PROPERTY_COMPONENT_NAME, UMLFactory.eINSTANCE.createProperty().getType());
+
+ return componentPackage;
+ }
+
+ private static Package createSubModel(Model rootModel) {
+ Model subModel = UMLFactory.eINSTANCE.createModel();
+ Package subPackage = rootModel.createNestedPackage(SUBMODEL_NAME, subModel.eClass());
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource sysmlProfileResource = resourceSet.getResource(URI.createURI(SysmlResource.SYSML_PROFILE_URI), true);
+ Profile sysmlProfile = (Profile) EcoreUtil.getObjectByType(sysmlProfileResource.getContents(), UMLPackage.Literals.PACKAGE);
+ PackageUtil.applyProfile(subPackage, sysmlProfile, true);
+
+ // TransactionalEditingDomain domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
+ // AbstractTransactionalCommand newCommand = new AbstractTransactionalCommand(domain, "ApplyProfile", Collections.EMPTY_LIST) {
+ //
+ // @Override
+ // protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ // if (PackageUtil.applyProfile((org.eclipse.uml2.uml.Package) subPackage, sysmlProfile, true)) {
+ // return CommandResult.newOKCommandResult();
+ // }
+ // return CommandResult.newErrorCommandResult("Profile " + sysmlProfile.getName() + " could not be applied");
+ // }
+ // };
+ // try {
+ // newCommand.execute(new NullProgressMonitor(), null);
+ // } catch (ExecutionException e) {
+ // fail(e.getMessage());
+ // }
+ PackageableElement newComponent = subPackage.createPackagedElement(COMPONENT_NAME, UMLFactory.eINSTANCE.createComponent().eClass());
+ // StereotypeApplicationHelper.INSTANCE.applyStereotype(newComponent, UMLPackage.eINSTANCE.getComponent());
+ PackageableElement newClass = subPackage.createPackagedElement(CLASS_NAME, UMLFactory.eINSTANCE.createClass().eClass());
+ Class beforeStrategyClass = (Class) newClass;
+ beforeStrategyClass.createOwnedAttribute(PROPERTY_CLASS_NAME, UMLFactory.eINSTANCE.createProperty().getType());
+
+ return subPackage;
+ }
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/StrategyTestModel.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/StrategyTestModel.java
new file mode 100755
index 00000000000..365f76ae01f
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/StrategyTestModel.java
@@ -0,0 +1,229 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.strategies;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.CommonPlugin;
+import org.eclipse.emf.common.util.URI;
+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.emf.ecore.xmi.XMIResource;
+import org.eclipse.papyrus.propertylifecycle.ElementContainer;
+import org.eclipse.papyrus.propertylifecycle.ElementProperty;
+import org.eclipse.papyrus.propertylifecycle.JavaProcessor;
+import org.eclipse.papyrus.propertylifecycle.StrategyElement;
+import org.eclipse.papyrus.propertylifecycle.StrategySet;
+import org.eclipse.papyrus.propertylifecycle.tests.Activator;
+import org.eclipse.papyrus.propertylifecycle.tests.utils.ITestConstants;
+import org.eclipse.papyrus.propertylifecycle.tests.utils.StrategyFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Initialize the test strategySet model
+ *
+ */
+public class StrategyTestModel implements ITestConstants {
+
+ public static StrategySet strategySet;
+
+ public static StrategyFactory strategyFactory = new StrategyFactory();
+
+ public static StrategySet initStrategyModel() {
+ strategySet = StrategyFactory.createStrategySet(STRATEGYSET_DESCRIPTION, STRATEGYSET_ID, STRATEGYSET_NAME);
+ addStrategies(strategySet);
+
+ return strategySet;
+ }
+
+ public static ResourceSet initStrategyModel(IProject parentProject) throws CoreException, IOException {
+ strategySet = StrategyFactory.createStrategySet(STRATEGYSET_DESCRIPTION, STRATEGYSET_ID, STRATEGYSET_NAME);
+ addStrategies(strategySet);
+
+ return saveStrategyModel(strategySet, parentProject);
+ }
+
+ private static ResourceSet saveStrategyModel(StrategySet strategyModel, IProject parentProject) throws CoreException, IOException {
+ ResourceSet strategyResourceSet = new ResourceSetImpl();
+ String modelFileName = RESOURCES_STRATEGYMODELNAME;
+ IFolder modelFolder = createRecursiveFolder(parentProject.getFolder(RESOURCES_FOLDERNAME));
+ URI modelURI = CommonPlugin.resolve(URI.createFileURI(modelFolder.getFullPath().toString() + "/" + modelFileName));
+ Resource modelResource = strategyResourceSet.createResource(modelURI);
+ modelResource.getContents().add(strategyModel);
+
+ try {
+ Map<Object, Object> options = new HashMap<>();
+ options.put(XMIResource.OPTION_ENCODING, RESOURCES_ENCODING);
+ modelResource.save(options);
+ // String filePath = "~/Desktop/";
+ // String localPath = filePath.replaceFirst("^~", System.getProperty("user.home").replace("\\", "/"));
+ // modelResource.setURI(CommonPlugin.resolve(URI.createFileURI(localPath + RESOURCES_UMLMODELNAME)));
+ // modelResource.save(null);
+ return strategyResourceSet;
+ } catch (IOException ioe) {
+ Activator.log.error(ioe);
+ }
+
+ return null;
+ }
+
+ public static IFolder createRecursiveFolder(IFolder folderToCreate) throws CoreException {
+ if (folderToCreate.exists()) {
+ return folderToCreate;
+ }
+
+ folderToCreate.create(true, true, new NullProgressMonitor());
+ return folderToCreate;
+ }
+
+ protected static void addStrategies(StrategySet strategySet) {
+ Collection<StrategyElement> strategies = new ArrayList<>();
+ strategies.add(componentStrategy());
+ strategies.add(classStrategy());
+ strategies.add(propertyComponentStrategy());
+ strategies.add(propertyClassStrategy());
+ strategies.add(sysmlBlockStrategy());
+ strategies.add(sysml14BlockStrategy());
+ strategies.add(associationStrategy());
+
+ strategySet.getStrategies().addAll(strategies);
+ Assert.assertEquals("There should be 7 strategies created in the model", 7, strategySet.getStrategies().size());
+ }
+
+ /** The component strategy renames a Component when created */
+ protected static StrategyElement componentStrategy() {
+ StrategyElement componentStrategy = strategyFactory.createStrategy(STRATEGYELEMENT_BASETYPE_COMPONENT, STRATEGYELEMENT_DESCRIPTION_COMPONENT,
+ STRATEGYELEMENT_ID_COMPONENT, STRATEGYELEMENT_NAME_COMPONENT, STRATEGYELEMENT_SPECIALIZEDTYPE_COMPONENT);
+ JavaProcessor valueProcessor = strategyFactory.createJavaProcessor(ELEMENTPROPERTY_PROCESSORPATH_COMPONENT);
+ ElementProperty componentProperty = strategyFactory.createProperty(STRATEGYPROPERTY_FEATURELABEL_COMPONENT, ELEMENTPROPERTY_PRIORITY_COMPONENT,
+ valueProcessor);
+
+ componentStrategy.getElementProperties().add(componentProperty);
+ Assert.assertTrue("The properties should not be empty", componentStrategy.getElementProperties().size() > 0);
+
+ return componentStrategy;
+ }
+
+ /** The class strategy renames a Class created inside a Model */
+ protected static StrategyElement classStrategy() {
+ StrategyElement classStrategy = strategyFactory.createStrategy(STRATEGYELEMENT_BASETYPE_CLASS, STRATEGYELEMENT_DESCRIPTION_CLASS,
+ STRATEGYELEMENT_ID_CLASS, STRATEGYELEMENT_NAME_CLASS, STRATEGYELEMENT_SPECIALIZEDTYPE_CLASS);
+ ElementContainer classContainer = strategyFactory.createContainer(STRATEGYCONTAINER_BASETYPE_CLASS, STRATEGYCONTAINER_SPECIALIZEDTYPE_CLASS,
+ null);
+ JavaProcessor valueProcessor = strategyFactory.createJavaProcessor(ELEMENTPROPERTY_PROCESSORPATH_CLASS);
+ ElementProperty classProperty = strategyFactory.createProperty(STRATEGYPROPERTY_FEATURELABEL_CLASS, ELEMENTPROPERTY_PRIORITY_CLASS,
+ valueProcessor);
+
+ classStrategy.getElementContainers().add(classContainer);
+ Assert.assertTrue("The containers should not be empty", classStrategy.getElementContainers().size() > 0);
+ classStrategy.getElementProperties().add(classProperty);
+ Assert.assertTrue("The properties should not be empty", classStrategy.getElementProperties().size() > 0);
+
+ return classStrategy;
+ }
+
+ /** the property strategy renames a Property created inside a Class and when the Class changes its name afterwards */
+ protected static StrategyElement propertyComponentStrategy() {
+ StrategyElement propertyStrategy = strategyFactory.createStrategy(STRATEGYELEMENT_BASETYPE_PROPERTY, STRATEGYELEMENT_DESCRIPTION_PROPERTY,
+ STRATEGYELEMENT_ID_COMPONENTPROPERTY, STRATEGYELEMENT_NAME_COMPONENTPROPERTY, STRATEGYELEMENT_SPECIALIZEDTYPE_PROPERTY);
+ ElementContainer propertyContainer = strategyFactory.createContainer(STRATEGYCONTAINER_BASETYPE_COMPONENTPROPERTY, STRATEGYCONTAINER_SPECIALIZEDTYPE_PROPERTY,
+ null);
+ JavaProcessor valueProcessor = strategyFactory.createJavaProcessor(ELEMENTPROPERTY_PROCESSORPATH_PROPERTY);
+ ElementProperty propertyProperty = strategyFactory.createProperty(STRATEGYPROPERTY_FEATURELABEL_PROPERTY, ELEMENTPROPERTY_PRIORITY_PROPERTY,
+ valueProcessor);
+
+ propertyStrategy.getElementContainers().add(propertyContainer);
+ Assert.assertTrue("The containers should not be empty", propertyStrategy.getElementContainers().size() > 0);
+ propertyStrategy.getElementProperties().add(propertyProperty);
+ Assert.assertTrue("The properties should not be empty", propertyStrategy.getElementProperties().size() > 0);
+
+ return propertyStrategy;
+ }
+
+
+ /** the property strategy renames a Property created inside a Class and when the Class changes its name afterwards */
+ protected static StrategyElement propertyClassStrategy() {
+ StrategyElement propertyStrategy = strategyFactory.createStrategy(STRATEGYELEMENT_BASETYPE_PROPERTY, STRATEGYELEMENT_DESCRIPTION_PROPERTY,
+ STRATEGYELEMENT_ID_CLASSPROPERTY, STRATEGYELEMENT_NAME_CLASSPROPERTY, STRATEGYELEMENT_SPECIALIZEDTYPE_PROPERTY);
+ ElementContainer propertyContainer = strategyFactory.createContainer(STRATEGYCONTAINER_BASETYPE_CLASSPROPERTY, STRATEGYCONTAINER_SPECIALIZEDTYPE_PROPERTY,
+ null);
+ JavaProcessor valueProcessor = strategyFactory.createJavaProcessor(ELEMENTPROPERTY_PROCESSORPATH_PROPERTY);
+ ElementProperty propertyProperty = strategyFactory.createProperty(STRATEGYPROPERTY_FEATURELABEL_PROPERTY, ELEMENTPROPERTY_PRIORITY_CLASSPROPERTY,
+ valueProcessor);
+
+ propertyStrategy.getElementContainers().add(propertyContainer);
+ Assert.assertTrue("The containers should not be empty", propertyStrategy.getElementContainers().size() > 0);
+ propertyStrategy.getElementProperties().add(propertyProperty);
+ Assert.assertTrue("The properties should not be empty", propertyStrategy.getElementProperties().size() > 0);
+
+ return propertyStrategy;
+ }
+
+
+ /** the sysmlblock strategy renames a sysml Block when created */
+ protected static StrategyElement sysmlBlockStrategy() {
+ StrategyElement sysmlBlockStrategy = strategyFactory.createStrategy(STRATEGYELEMENT_BASETYPE_SYSMLBLOCK, STRATEGYELEMENT_DESCRIPTION_SYSMLBLOCK,
+ STRATEGYELEMENT_ID_SYSMLBLOCK, STRATEGYELEMENT_NAME_SYSMLBLOCK, STRATEGYELEMENT_SPECIALIZEDTYPE_SYSMLBLOCK);
+ JavaProcessor valueProcessor = strategyFactory.createJavaProcessor(ELEMENTPROPERTY_PROCESSORPATH_SYSMLBLOCK);
+ ElementProperty sysmlBlockProperty = strategyFactory.createProperty(STRATEGYPROPERTY_FEATURELABEL_SYSMLBLOCK, ELEMENTPROPERTY_PRIORITY_SYSMLBLOCK,
+ valueProcessor);
+
+ Assert.assertTrue("The containers should be empty", sysmlBlockStrategy.getElementContainers().size() == 0);
+ sysmlBlockStrategy.getElementProperties().add(sysmlBlockProperty);
+ Assert.assertTrue("The properties should not be empty", sysmlBlockStrategy.getElementProperties().size() > 0);
+
+ return sysmlBlockStrategy;
+ }
+
+ /** the sysml14block strategy renames a sysml14 Block when created */
+ protected static StrategyElement sysml14BlockStrategy() {
+ StrategyElement sysml14BlockStrategy = strategyFactory.createStrategy(STRATEGYELEMENT_BASETYPE_SYSML14BLOCK, STRATEGYELEMENT_DESCRIPTION_SYSML14BLOCK,
+ STRATEGYELEMENT_ID_SYSML14BLOCK, STRATEGYELEMENT_NAME_SYSML14BLOCK, STRATEGYELEMENT_SPECIALIZEDTYPE_SYSML14BLOCK);
+ JavaProcessor valueProcessor = strategyFactory.createJavaProcessor(ELEMENTPROPERTY_PROCESSORPATH_SYSML14BLOCK);
+ ElementProperty sysml14BlockProperty = strategyFactory.createProperty(STRATEGYPROPERTY_FEATURELABEL_SYSML14BLOCK, ELEMENTPROPERTY_PRIORITY_SYSML14BLOCK,
+ valueProcessor);
+
+ Assert.assertTrue("The containers should be empty", sysml14BlockStrategy.getElementContainers().size() == 0);
+ sysml14BlockStrategy.getElementProperties().add(sysml14BlockProperty);
+ Assert.assertTrue("The properties should not be empty", sysml14BlockStrategy.getElementProperties().size() > 0);
+
+ return sysml14BlockStrategy;
+ }
+
+ /** the association strategy renames an Association when created and when reoriented afterwards */
+ protected static StrategyElement associationStrategy() {
+ StrategyElement associationStrategy = strategyFactory.createStrategy(STRATEGYELEMENT_BASETYPE_ASSOCIATION, STRATEGYELEMENT_DESCRIPTION_ASSOCIATION,
+ STRATEGYELEMENT_ID_ASSOCIATION, STRATEGYELEMENT_NAME_ASSOCIATION, STRATEGYELEMENT_SPECIALIZEDTYPE_ASSOCIATION);
+ JavaProcessor valueProcessor = strategyFactory.createJavaProcessor(ELEMENTPROPERTY_PROCESSORPATH_ASSOCIATION);
+ ElementProperty associationProperty = strategyFactory.createProperty(STRATEGYPROPERTY_FEATURELABEL_ASSOCIATION, ELEMENTPROPERTY_PRIORITY_ASSOCIATION,
+ valueProcessor);
+
+ Assert.assertTrue("The containers should be empty", associationStrategy.getElementContainers().size() == 0);
+ associationStrategy.getElementProperties().add(associationProperty);
+ Assert.assertTrue("The properties should not be empty", associationStrategy.getElementProperties().size() > 0);
+
+ return associationStrategy;
+ }
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/AssociationProcessor.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/AssociationProcessor.java
new file mode 100755
index 00000000000..75e90e33900
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/AssociationProcessor.java
@@ -0,0 +1,147 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.strategies.processors;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.papyrus.propertylifecycle.commands.LifecycleSetCommand;
+import org.eclipse.papyrus.propertylifecycle.tests.Activator;
+import org.eclipse.papyrus.propertylifecycle.utils.CommandValueProcessor;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Property;
+
+/**
+ *
+ *
+ */
+public class AssociationProcessor implements CommandValueProcessor {
+
+ Association association;
+
+ @Override
+ public ICommand setValueFromRequest(String featureLabel, boolean isImmutable, AbstractEditCommandRequest request) {
+ return setName(request, isImmutable);
+ }
+
+ public AssociationProcessor() {
+
+ }
+
+ public ICommand setName(AbstractEditCommandRequest request, boolean isImmutable) {
+ if (isImmutable) {
+ Activator.log.trace(Activator.PLCSTRATEGY_TESTS_TRACE, "isJambon: " + isImmutable);
+ } else {
+ Activator.log.trace(Activator.PLCSTRATEGY_TESTS_TRACE, "isJambon: " + isImmutable);
+ }
+ ICommand gmfCommand = null;
+
+ if (request instanceof ConfigureRequest) {
+ ConfigureRequest confRequest = (ConfigureRequest) request;
+
+ association = (Association) confRequest.getElementToConfigure();
+ Classifier sourceType = getSourceOwnerType(confRequest);
+ Classifier targetType = getTargetOwnerType(confRequest);
+
+ String initializedName = "A_" + sourceType.getName() + "_" + targetType.getName();//$NON-NLS-1$ //$NON-NLS-2$
+ EStructuralFeature feature = association.eClass().getEStructuralFeature("name");
+
+ ICommand setCommand = new LifecycleSetCommand("AssociationConfigure", association, feature, initializedName);
+ gmfCommand = CompositeCommand.compose(gmfCommand, setCommand);
+ }
+
+ if (request instanceof ReorientRelationshipRequest) {
+ ReorientRelationshipRequest reorientRequest = (ReorientRelationshipRequest) request;
+
+ association = (Association) reorientRequest.getRelationship();
+ Property sourceProperty = association.getMemberEnds().get(1);
+ Property targetProperty = association.getMemberEnds().get(0);
+ EStructuralFeature feature = association.eClass().getEStructuralFeature("name");
+ String initializedName = null;
+
+ if (reorientRequest.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE) {
+ sourceProperty.setName(getReorientOwnerType(reorientRequest).getName().toLowerCase());
+ initializedName = "A_" + getReorientOwnerType(reorientRequest).getName() + "_" + targetProperty.getType().getName();
+ }
+ if (reorientRequest.getDirection() == ReorientRelationshipRequest.REORIENT_TARGET) {
+ targetProperty.setName(getReorientOwnerType(reorientRequest).getName().toLowerCase());
+ initializedName = "A_" + sourceProperty.getType().getName() + "_" + getReorientOwnerType(reorientRequest).getName();
+ }
+
+ // The strategies will be browsed by this setRequest and a command will be constructed in the PropertyProcessor if any match
+ ICommand setCommand = new LifecycleSetCommand("AssociationReorient", association, feature, initializedName);
+ gmfCommand = CompositeCommand.compose(gmfCommand, setCommand);
+ }
+
+ return gmfCommand;
+ }
+
+
+ /**
+ * This method provides the new owner type
+ *
+ * @param request
+ * The {@link ConfigureRequest}
+ * @return
+ * The Classifier owning the new end or null if none exists
+ */
+ protected Classifier getReorientOwnerType(ReorientRelationshipRequest request) {
+ Object paramObject = request.getNewRelationshipEnd();
+ if (paramObject instanceof Classifier) {
+ return (Classifier) paramObject;
+ }
+
+ return null;
+ }
+
+ /**
+ * This method provides the source type
+ *
+ * @param request
+ * The {@link ConfigureRequest}
+ * @return
+ * The Classifier owning the new end or null if none exists
+ */
+ protected Classifier getSourceOwnerType(ConfigureRequest request) {
+ Object paramObject = request.getParameter(CreateRelationshipRequest.SOURCE);
+ if (paramObject instanceof Classifier) {
+ return (Classifier) paramObject;
+ }
+
+ return null;
+ }
+
+ /**
+ * This method provides the target type
+ *
+ * @param request
+ * The {@link ConfigureRequest}
+ * @return
+ * The Classifier owning the new end or null if none exists
+ */
+ protected Classifier getTargetOwnerType(ConfigureRequest request) {
+ Object paramObject = request.getParameter(CreateRelationshipRequest.TARGET);
+ if (paramObject instanceof Classifier) {
+ return (Classifier) paramObject;
+ }
+
+ return null;
+ }
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/ClassProcessor.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/ClassProcessor.java
new file mode 100755
index 00000000000..e1af4415c3d
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/ClassProcessor.java
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.strategies.processors;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.propertylifecycle.commands.LifecycleSetCommand;
+import org.eclipse.papyrus.propertylifecycle.utils.CommandValueProcessor;
+import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Property;
+
+
+public class ClassProcessor implements CommandValueProcessor {
+
+ NamedElement element;
+
+ @Override
+ public ICommand setValueFromRequest(String featureLabel, boolean isImmutable, AbstractEditCommandRequest request) {
+ return setName(request, isImmutable);
+ }
+
+ public ClassProcessor() {
+
+ }
+
+ public ICommand setName(AbstractEditCommandRequest request, boolean isImmutable) {
+ ICommand gmfCommand = null;
+
+ if (request instanceof SetRequest) {
+ SetRequest setRequest = (SetRequest) request;
+ element = (NamedElement) setRequest.getElementToEdit();
+ TransactionalEditingDomain domain = request.getEditingDomain();
+ LifecycleSetCommand classSetCommand = new LifecycleSetCommand(domain, "Class_Set",
+ element, setRequest.getFeature(), setRequest.getValue());
+ gmfCommand = CompositeCommand.compose(gmfCommand, classSetCommand);
+
+ for (EObject eObject : element.eContents()) {
+ if (eObject instanceof Property) {
+ EStructuralFeature feature = eObject.eClass().getEStructuralFeature("name");
+ String value = "afterSetClassNamePropertyName";
+
+ // The strategies will be browsed by this setRequest and a command will be constructed in the PropertyProcessor if any match
+ SetRequest setPropRequest = new SetRequest(domain, eObject, feature, value);
+
+ // SubRequest, outside of the current service edit (element) hence we can call on it again (eObject) without fear of loops
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(eObject);
+ ICommand createGMFCommand = provider.getEditCommand(setPropRequest);
+
+ gmfCommand = CompositeCommand.compose(gmfCommand, createGMFCommand);
+ }
+ }
+
+ if (gmfCommand != null) {
+ gmfCommand.reduce();
+ }
+
+ } else {
+
+ if (request instanceof ConfigureRequest) {
+ ConfigureRequest confRequest = (ConfigureRequest) request;
+ element = (NamedElement) confRequest.getElementToConfigure();
+ }
+ if (request instanceof CreateElementRequest) {
+ CreateElementRequest createRequest = (CreateElementRequest) request;
+ element = (NamedElement) createRequest.getNewElement();
+ }
+
+ if (element != null && !isImmutable) {
+ String initializedName = NamedElementUtil.getDefaultNameWithIncrementFromBase("NewClassName", element.eContainer().eContents());
+ EStructuralFeature feature = element.eClass().getEStructuralFeature("name");
+
+ LifecycleSetCommand setCommand = new LifecycleSetCommand("Class_Conf&Create",
+ element, feature, initializedName);
+ gmfCommand = CompositeCommand.compose(gmfCommand, setCommand);
+ }
+
+ }
+
+ return gmfCommand;
+ }
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/ComponentProcessor.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/ComponentProcessor.java
new file mode 100755
index 00000000000..7e199a1cb34
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/ComponentProcessor.java
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.strategies.processors;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.propertylifecycle.commands.LifecycleSetCommand;
+import org.eclipse.papyrus.propertylifecycle.utils.CommandValueProcessor;
+import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Property;
+
+
+public class ComponentProcessor implements CommandValueProcessor {
+
+ NamedElement element;
+
+ @Override
+ public ICommand setValueFromRequest(String featureLabel, boolean isImmutable, AbstractEditCommandRequest request) {
+ return setName(request, isImmutable);
+ }
+
+ public ComponentProcessor() {
+
+ }
+
+ public ICommand setName(AbstractEditCommandRequest request, boolean isImmutable) {
+ ICommand gmfCommand = null;
+
+ if (request instanceof SetRequest) {
+ SetRequest setRequest = (SetRequest) request;
+ element = (NamedElement) setRequest.getElementToEdit();
+ LifecycleSetCommand setCommand = new LifecycleSetCommand("Component_Set",
+ element, setRequest.getFeature(), setRequest.getValue());
+ gmfCommand = CompositeCommand.compose(gmfCommand, setCommand);
+
+ // We want the name of the properties inside the element to change as well
+ for (EObject eObject : element.eContents()) {
+ if (eObject instanceof Property) {
+ String initializedName = NamedElementUtil.getDefaultNameWithIncrementFromBase(element.getName() + "_property", element.eContents());
+ EStructuralFeature feature = eObject.eClass().getEStructuralFeature("name");
+
+ // The strategies will be browsed by this setRequest and a command will be constructed in the PropertyProcessor if any match
+ SetRequest setPropRequest = new SetRequest(eObject, feature, initializedName);
+
+ // SubRequest, outside of the current service edit (element) hence we can call on it again (eObject) without fear of loops
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(eObject);
+ ICommand createGMFCommand = provider.getEditCommand(setPropRequest);
+
+ gmfCommand = CompositeCommand.compose(gmfCommand, createGMFCommand);
+ }
+ }
+
+ if (gmfCommand != null) {
+ gmfCommand.reduce();
+ }
+
+ } else {
+
+ if (request instanceof ConfigureRequest) {
+ ConfigureRequest confRequest = (ConfigureRequest) request;
+ element = (NamedElement) confRequest.getElementToConfigure();
+ }
+ if (request instanceof CreateElementRequest) {
+ CreateElementRequest createRequest = (CreateElementRequest) request;
+ element = (NamedElement) createRequest.getNewElement();
+ }
+
+ if (element != null && !isImmutable) {
+ String initializedName = NamedElementUtil.getDefaultNameWithIncrementFromBase("NewComponentName", element.eContainer().eContents());
+ EStructuralFeature feature = element.eClass().getEStructuralFeature("name");
+
+ ICommand setCommand = new LifecycleSetCommand("Component_Conf&Create", element, feature, initializedName);
+ gmfCommand = CompositeCommand.compose(gmfCommand, setCommand);
+ }
+ }
+
+ return gmfCommand;
+ }
+
+}
+
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/PropertyProcessor.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/PropertyProcessor.java
new file mode 100755
index 00000000000..ef3fbab9e12
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/PropertyProcessor.java
@@ -0,0 +1,92 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.strategies.processors;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.propertylifecycle.commands.LifecycleSetCommand;
+import org.eclipse.papyrus.propertylifecycle.utils.CommandValueProcessor;
+import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
+import org.eclipse.uml2.uml.NamedElement;
+
+public class PropertyProcessor implements CommandValueProcessor {
+
+ NamedElement element;
+
+ @Override
+ public ICommand setValueFromRequest(String featureLabel, boolean isImmutable, AbstractEditCommandRequest request) {
+ return setName(request, isImmutable);
+ }
+
+ public PropertyProcessor() {
+
+ }
+
+ public ICommand setName(AbstractEditCommandRequest request, boolean isImmutable) {
+ ICommand gmfCommand = null;
+
+ if (request instanceof SetRequest) {
+ SetRequest setRequest = (SetRequest) request;
+ Object nameValue;
+ TransactionalEditingDomain domain = request.getEditingDomain();
+
+ element = (NamedElement) setRequest.getElementToEdit();
+ EStructuralFeature feature = element.eClass().getEStructuralFeature("name");
+ if (isImmutable) {
+ nameValue = "propertyNameIsImmutable";
+ } else {
+ // EStructuralFeature setFeature = setRequest.getFeature();
+ Object newValue = setRequest.getValue();
+ nameValue = newValue;
+ }
+
+ // LifecycleSetCommand setCommand = new LifecycleSetCommand(domain, "Property_Set",
+ // element, feature, nameValue);
+ LifecycleSetCommand setCommand = new LifecycleSetCommand("Property_Set",
+ element, feature, nameValue);
+
+ gmfCommand = CompositeCommand.compose(gmfCommand, setCommand);
+
+ } else {
+
+ if (request instanceof ConfigureRequest) {
+ ConfigureRequest confRequest = (ConfigureRequest) request;
+ element = (NamedElement) confRequest.getElementToConfigure();
+ }
+ if (request instanceof CreateElementRequest) {
+ CreateElementRequest createRequest = (CreateElementRequest) request;
+ element = (NamedElement) createRequest.getNewElement();
+ }
+
+ if (element != null /* && !isImmutable */) {
+ String initializedName = NamedElementUtil.getDefaultNameWithIncrementFromBase("Attribute", element.eContainer().eContents());
+ EStructuralFeature feature = element.eClass().getEStructuralFeature("name");
+ // SetRequest setRequest = new SetRequest(element, feature, initializedName);
+ // return new SetValueCommand(setRequest);
+
+ ICommand setCommand = new LifecycleSetCommand("Property_Conf&Create", element, feature, initializedName);
+ gmfCommand = CompositeCommand.compose(gmfCommand, setCommand);
+ }
+ }
+
+ return gmfCommand;
+ }
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/Sysml14BlockProcessor.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/Sysml14BlockProcessor.java
new file mode 100755
index 00000000000..729cc1f567a
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/Sysml14BlockProcessor.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.strategies.processors;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.papyrus.propertylifecycle.commands.LifecycleSetCommand;
+import org.eclipse.papyrus.propertylifecycle.utils.CommandValueProcessor;
+import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
+import org.eclipse.uml2.uml.NamedElement;
+
+public class Sysml14BlockProcessor implements CommandValueProcessor {
+
+ NamedElement element;
+
+ @Override
+ public ICommand setValueFromRequest(String featureLabel, boolean isImmutable, AbstractEditCommandRequest request) {
+ return setName(request, isImmutable);
+ }
+
+ public Sysml14BlockProcessor() {
+
+ }
+
+ public ICommand setName(AbstractEditCommandRequest request, boolean isImmutable) {
+ ICommand gmfCommand = null;
+
+ if (request instanceof ConfigureRequest) {
+ ConfigureRequest confRequest = (ConfigureRequest) request;
+ element = (NamedElement) confRequest.getElementToConfigure();
+ }
+
+ if (element != null && !isImmutable) {
+ String initializedName = NamedElementUtil.getDefaultNameWithIncrementFromBase("NewSysml14BlockName", element.eContainer().eContents());
+ EStructuralFeature feature = element.eClass().getEStructuralFeature("name");
+
+ ICommand setCommand = new LifecycleSetCommand("Sysml14Block", element, feature, initializedName);
+ gmfCommand = CompositeCommand.compose(gmfCommand, setCommand);
+ }
+
+ return gmfCommand;
+ }
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/SysmlBlockProcessor.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/SysmlBlockProcessor.java
new file mode 100755
index 00000000000..97e18807090
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/strategies/processors/SysmlBlockProcessor.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.strategies.processors;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.papyrus.propertylifecycle.commands.LifecycleSetCommand;
+import org.eclipse.papyrus.propertylifecycle.utils.CommandValueProcessor;
+import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
+import org.eclipse.uml2.uml.NamedElement;
+
+public class SysmlBlockProcessor implements CommandValueProcessor {
+
+ NamedElement element;
+
+ @Override
+ public ICommand setValueFromRequest(String featureLabel, boolean isImmutable, AbstractEditCommandRequest request) {
+ return setName(request, isImmutable);
+ }
+
+ public SysmlBlockProcessor() {
+
+ }
+
+ public ICommand setName(AbstractEditCommandRequest request, boolean isImmutable) {
+ ICommand compositeCommand = null;
+
+ if (request instanceof ConfigureRequest) {
+ ConfigureRequest confRequest = (ConfigureRequest) request;
+ element = (NamedElement) confRequest.getElementToConfigure();
+ }
+
+ if (request instanceof CreateElementRequest) {
+ CreateElementRequest createRequest = (CreateElementRequest) request;
+ element = (NamedElement) createRequest.getNewElement();
+ }
+
+ if (element != null && !isImmutable) {
+ String initializedName = NamedElementUtil.getDefaultNameWithIncrementFromBase("NewSysmlBlockName", element.eContainer().eContents());
+ EStructuralFeature feature = element.eClass().getEStructuralFeature("name");
+
+ ICommand setCommand = new LifecycleSetCommand("SysmlBlock_Conf&Create", element, feature, initializedName);
+ compositeCommand = CompositeCommand.compose(compositeCommand, setCommand);
+ }
+
+ return compositeCommand;
+ }
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/tests/AbstractPropertyLifecycleTests.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/tests/AbstractPropertyLifecycleTests.java
new file mode 100755
index 00000000000..c5676b967c5
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/tests/AbstractPropertyLifecycleTests.java
@@ -0,0 +1,316 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.tests;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.CommonPlugin;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+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.emf.ecore.util.Diagnostician;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.emf.edit.command.OverrideableCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.ResourceSetListener;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
+import org.eclipse.papyrus.infra.core.resource.ModelException;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.ModelUtils;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.services.ExtensionServicesRegistry;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.EditorUtils;
+import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils;
+import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
+import org.eclipse.papyrus.propertylifecycle.StrategySet;
+import org.eclipse.papyrus.propertylifecycle.preferences.utils.PropertyLifecyclePreferencesManager;
+import org.eclipse.papyrus.propertylifecycle.tests.model.UMLTestModel;
+import org.eclipse.papyrus.propertylifecycle.tests.strategies.StrategyTestModel;
+import org.eclipse.papyrus.propertylifecycle.tests.utils.ITestConstants;
+import org.eclipse.papyrus.uml.diagram.wizards.Activator;
+import org.eclipse.papyrus.uml.tools.commands.ApplyProfileCommand;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
+import org.eclipse.papyrus.uml.tools.model.UmlUtils;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.Component;
+import org.eclipse.uml2.uml.Model;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.osgi.framework.Bundle;
+
+
+
+public abstract class AbstractPropertyLifecycleTests extends AbstractPapyrusTest implements ITestConstants {
+
+ @ClassRule
+ public static HouseKeeper.Static houseKeeper = new HouseKeeper.Static();
+
+ public static IProgressMonitor monitor = new NullProgressMonitor();
+
+ public static ResourceSet umlResourceSet;
+
+ public static ResourceSet strategyResourceSet;
+
+ public static StrategySet strategyModel;
+
+ public static Model umlModel;
+
+ public static IProject lifecycleProject;
+
+ public static IFile lifecycleModelFile;
+
+ public static IMultiDiagramEditor openPapyrusEditor;
+
+ public static TransactionalEditingDomain transactionalEditingDomain;
+
+ // public static IClientContext papyrusContext;
+
+ public static Package componentPackage;
+
+ public static Component component_ComponentPacakge;
+
+ public static Package classPackage;
+
+ public static org.eclipse.uml2.uml.Class class_ClassPackage;
+
+ public static Model subModel;
+
+ public static Component component_subModel;
+
+ public static org.eclipse.uml2.uml.Class class_subModel;
+
+ public static Property property_class_subModel;
+
+ public static ModelSet modelset;
+
+ public static UmlModel umlIModel;
+
+ public static Model rootModel;
+
+ public static Resource umlModelResource;
+
+
+ @BeforeClass
+ public static void initProject() {
+
+ // Create the project and its models
+ lifecycleProject = houseKeeper.createProject(RESOURCES_PROJECTNAME);
+ try {
+ umlResourceSet = UMLTestModel.initUMLModel(lifecycleProject);
+ strategyResourceSet = StrategyTestModel.initStrategyModel(lifecycleProject);
+ Assert.assertNotNull("the modelResourceSet should not be null", umlResourceSet);
+ Assert.assertNotNull("The strategyResourceSet should not be null", strategyResourceSet);
+
+ umlModelResource = umlResourceSet.getResources().get(0);
+
+ umlModel = (Model) umlModelResource.getContents().get(0);
+ Diagnostic umlDiagnostic = Diagnostician.INSTANCE.validate(umlModel);
+ Assert.assertTrue("The umlModel should be validated", umlDiagnostic.getSeverity() == Diagnostic.OK);
+ strategyModel = (StrategySet) strategyResourceSet.getResources().get(0).getContents().get(0);
+ Diagnostic strategyDiagnostic = Diagnostician.INSTANCE.validate(strategyModel);
+ Assert.assertTrue("The strategyModel should be validated", strategyDiagnostic.getSeverity() == Diagnostic.OK);
+
+ // Register the test strategies to call upon them during the tests
+ PropertyLifecyclePreferencesManager preferenceManager = new PropertyLifecyclePreferencesManager();
+ preferenceManager.registerCurrentPreferences(
+ Collections.singleton(strategyResourceSet.getResources().get(0).getURI().toString()), null,
+ strategyModel.getStrategies(), null);
+
+ // Check created models and project
+ checkExistingElements(umlModel);
+ Assert.assertTrue(lifecycleProject.getFolder(RESOURCES_FOLDERNAME).exists());
+ Assert.assertTrue(lifecycleProject.getFolder(RESOURCES_FOLDERNAME).getFile(RESOURCES_UMLMODELNAME).exists());
+ Assert.assertTrue(lifecycleProject.getFolder(RESOURCES_FOLDERNAME).getFile(RESOURCES_STRATEGYMODELNAME).exists());
+
+ // Create a new papyrus model
+ ServicesRegistry registry = createServicesRegistry();
+ Assert.assertNotNull("The service registry should not be null", registry);
+ ModelSet modelSet = registry.getService(ModelSet.class);
+ lifecycleModelFile = lifecycleProject.getFolder(RESOURCES_FOLDERNAME).getFile(RESOURCES_UMLMODELNAME);
+ // modelSet.createsModels(lifecycleModelFile);
+ modelSet.createModels(URI.createPlatformResourceURI(lifecycleModelFile.getFullPath().toString(), true));
+ modelSet.save(monitor);
+ lifecycleModelFile = lifecycleProject.getFolder(RESOURCES_FOLDERNAME).getFile(RESOURCES_DIMODELNAME);
+
+
+ } catch (CoreException ce) {
+ fail(ce.getMessage());
+ } catch (IOException ioe) {
+ fail(ioe.getMessage());
+ } catch (ServiceException se) {
+ fail(se.getMessage());
+ }
+
+ // Open the project
+ Display.getDefault().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ openPapyrusEditor = houseKeeper.cleanUpLater(EditorUtils.openPapyrusEditor(lifecycleModelFile));
+ } catch (PartInitException pie) {
+ fail(pie.getMessage());
+ }
+ }
+ });
+
+ // Get the transactional editing domain used to create the edit requests
+ transactionalEditingDomain = openPapyrusEditor.getAdapter(TransactionalEditingDomain.class);
+ assertTrue("Impossible to init editing domain", transactionalEditingDomain instanceof TransactionalEditingDomain);
+
+ // Retrieve UML model from this editor
+ try {
+ modelset = ModelUtils.getModelSetChecked(openPapyrusEditor.getServicesRegistry());
+ umlIModel = UmlUtils.getUmlModel(modelset);
+ rootModel = (Model) umlIModel.lookupRoot();
+ subModel = (Model) rootModel.getNestedPackage(SUBMODEL_NAME);
+
+ Assert.assertNotNull("root model should not be null", rootModel);
+
+ } catch (ServiceException e) {
+ fail(e.getMessage());
+ } catch (NotFoundException e) {
+ fail(e.getMessage());
+ } catch (ClassCastException e) {
+ fail(e.getMessage());
+ }
+
+ // Check the contents of the new project
+ try {
+ checkExistingElements(rootModel);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+ // try {
+ // papyrusContext = org.eclipse.papyrus.infra.services.edit.internal.context.TypeContext.getContext();
+ // } catch (ServiceException se) {
+ // fail(se.getMessage());
+ // }
+
+ }
+
+ protected static void checkExistingElements(Model lifecycleRootModel) {
+ componentPackage = lifecycleRootModel.getNestedPackage(COMPONENT_PACKAGE_NAME);
+ Assert.assertNotNull(COMPONENT_PACKAGE_NAME + ", should not be null", componentPackage);
+ Assert.assertTrue(COMPONENT_PACKAGE_NAME + ", should be a package", componentPackage instanceof Package);
+
+ classPackage = lifecycleRootModel.getNestedPackage(CLASS_PACKAGE_NAME);
+ Assert.assertNotNull(CLASS_PACKAGE_NAME + ", should not be null", classPackage);
+ Assert.assertTrue(CLASS_PACKAGE_NAME + ", should be a package", classPackage instanceof Package);
+
+ Package subModelPackage = lifecycleRootModel.getNestedPackage(SUBMODEL_NAME);
+ Assert.assertTrue("The subModel package should be a Model", subModelPackage instanceof Model);
+ subModel = (Model) subModelPackage;
+
+ component_ComponentPacakge = (Component) componentPackage.getPackagedElement(COMPONENT_NAME);
+ Assert.assertNotNull(COMPONENT_NAME + ", should not be null", component_ComponentPacakge);
+
+ class_ClassPackage = (org.eclipse.uml2.uml.Class) classPackage.getPackagedElement(CLASS_NAME);
+ Assert.assertNotNull(CLASS_NAME + ", should not be null", class_ClassPackage);
+
+ component_subModel = (Component) subModel.getPackagedElement(COMPONENT_NAME);
+ Assert.assertNotNull(COMPONENT_NAME + ", should not be null", component_ComponentPacakge);
+ class_subModel = (org.eclipse.uml2.uml.Class) subModel.getPackagedElement(CLASS_NAME);
+ Assert.assertNotNull(CLASS_NAME + ", should not be null", class_ClassPackage);
+
+ property_class_subModel = class_subModel.getAttribute(PROPERTY_CLASS_NAME, UMLFactory.eINSTANCE.createProperty().getType());
+ Assert.assertNotNull("the property of the subModel's class should exist", property_class_subModel);
+ }
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ protected static ServicesRegistry createServicesRegistry() {
+ ServicesRegistry result = null;
+
+ try {
+ result = new ExtensionServicesRegistry(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID);
+ } catch (ServiceException e) {
+ // couldn't create the registry? Fatal problem
+ Activator.log.error(e);
+ }
+
+ try {
+ // have to create the model set and populate it with the DI model
+ // before initializing other services that actually need the DI
+ // model, such as the SashModel Manager service
+ result.startServicesByClassKeys(ModelSet.class);
+ } catch (ServiceException ex) {
+ // Ignore this exception: some services may not have been loaded,
+ // which is probably normal at this point
+ }
+
+ return result;
+ }
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/tests/PropertyLifecycleTests.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/tests/PropertyLifecycleTests.java
new file mode 100755
index 00000000000..f64f617ad9e
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/tests/PropertyLifecycleTests.java
@@ -0,0 +1,434 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.tests;
+
+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.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.propertylifecycle.tests.Activator;
+import org.eclipse.papyrus.propertylifecycle.tests.utils.ITestConstants;
+import org.junit.Assert;
+import org.junit.Test;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Component;
+import org.eclipse.uml2.uml.NamedElement;
+
+public class PropertyLifecycleTests extends AbstractPropertyLifecycleTests implements ITestConstants {
+
+ public static ICommand createCommand;
+
+ public static EObject newElement;
+
+ public static String SysmlProfile_URI = "http://www.eclipse.org/papyrus/0.7.0/SysML/Blocks";
+
+ // @Test
+ // public void testInitialization() {
+ // Assert.assertTrue(true);
+ // }
+
+ // @Test
+ // public void testCreateSysML14BlockInModel() throws ExecutionException {
+ // IElementType blockType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.SysML14.Block");
+ // Profile sysml14Profile = ProfileUtil.getProfile(org.eclipse.papyrus.sysml14.definition.SysmlPackage.eINSTANCE);
+ // subModel.applyProfile(sysml14Profile);
+ // Assert.assertTrue("The sysml14 profile should be applied to the subModel", subModel.getAllAppliedProfiles().contains(sysml14Profile));
+ // createElementInPackage(subModel, blockType);
+ // Assert.assertTrue("The new element should be a Block", newElement instanceof org.eclipse.papyrus.SysML14.Block);
+ // String newName = ((NamedElement) newElement).getName();
+ // Activator.log.trace(Activator.PLCSTRATEGY_TESTS_TRACE, newName);
+ // Assert.assertTrue("The name of the new Componenet should be NewSysml14BlockName",
+ // "NewSysml14BlockName".equalsIgnoreCase(((NamedElement) newElement).getName().replaceAll("[0-9]", "")));
+ // createCommand.undo(monitor, null);
+ // subModel.unapplyProfile(sysml14Profile);
+ // }
+
+ @Test
+ public void testCreateComponentInPackage() throws ExecutionException {
+ IElementType componentType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Component");
+ Assert.assertTrue("componentPackage is instanceof Package", componentPackage instanceof Package);
+ createElementInPackage(componentPackage, componentType);
+ Assert.assertTrue("The new element should be a Component", newElement instanceof Component);
+ String newName = ((NamedElement) newElement).getName();
+ Activator.log.trace(Activator.PLCSTRATEGY_TESTS_TRACE, newName);
+ Assert.assertTrue("The name of the new Componenet should be NewComponentName",
+ "NewComponentName".equalsIgnoreCase(newName.replaceAll("[0-9]", "")));
+ createCommand.undo(monitor, null);
+ }
+
+ @Test
+ public void testCreateComponentInModel() throws ExecutionException {
+ IElementType componentType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Component");
+ createElementInPackage(subModel, componentType);
+ Assert.assertTrue("The new element should be a Component", newElement instanceof Component);
+ String newName = ((NamedElement) newElement).getName();
+ Activator.log.trace(Activator.PLCSTRATEGY_TESTS_TRACE, newName);
+ Assert.assertTrue("The name of the new Componenet should be NewComponentName",
+ "NewComponentName".equalsIgnoreCase(((NamedElement) newElement).getName().replaceAll("[0-9]", "")));
+ createCommand.undo(monitor, null);
+ }
+
+ @Test
+ public void testCreateClassInPackage() throws ExecutionException {
+ IElementType componentType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Class");
+ Assert.assertTrue("classPackage is instanceof Package", classPackage instanceof Package);
+ createElementInPackage(componentPackage, componentType);
+ Assert.assertTrue("The new element should be a Class", newElement instanceof org.eclipse.uml2.uml.Class);
+ String newName = ((NamedElement) newElement).getName();
+ Activator.log.trace(Activator.PLCSTRATEGY_TESTS_TRACE, newName);
+ Assert.assertTrue("The name of the new Class should be Class",
+ "Class".equalsIgnoreCase(newName.replaceAll("[0-9]", "")));
+ createCommand.undo(monitor, null);
+ }
+
+ @Test
+ public void testCreateClassInModel() throws ExecutionException {
+ IElementType componentType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Class");
+ createElementInPackage(subModel, componentType);
+ Assert.assertTrue("The new element should be a Class", newElement instanceof org.eclipse.uml2.uml.Class);
+ String newName = ((NamedElement) newElement).getName();
+ Activator.log.trace(Activator.PLCSTRATEGY_TESTS_TRACE, newName);
+ Assert.assertTrue("The name of the new Class should be NewClassName",
+ "NewClassName".equalsIgnoreCase(((NamedElement) newElement).getName().replaceAll("[0-9]", "")));
+ createCommand.undo(monitor, null);
+ }
+
+ @Test
+ public void testCreateSysmlBlockInModel() throws ExecutionException {
+ IElementType blockType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.sysml.Block");
+ Assert.assertTrue("The sysml profile should be applied to the subModel", subModel.getAllAppliedProfiles().size() > 0);
+ createElementInPackage(subModel, blockType);
+ Stereotype blockStereotype = null;
+ for (Profile appliedProfile : subModel.getAppliedProfiles()) {
+ if (appliedProfile.getURI() != null && appliedProfile.getURI().compareTo(SysmlProfile_URI) == 0) {
+ blockStereotype = appliedProfile.getOwnedStereotype("Block", true);
+ break;
+ }
+ }
+
+ Assert.assertTrue("The new element should be a block", ((NamedElement) newElement).isStereotypeApplied(blockStereotype));
+ String newName = ((NamedElement) newElement).getName();
+ Activator.log.trace(Activator.PLCSTRATEGY_TESTS_TRACE, newName);
+ Assert.assertTrue("The name of the new Componenet should be NewSysmlBlockName",
+ "NewSysmlBlockName".equalsIgnoreCase(((NamedElement) newElement).getName().replaceAll("[0-9]", "")));
+ createCommand.undo(monitor, null);
+ }
+
+
+ @Test
+ public void testCreatePropertyInComponent() throws ExecutionException {
+ IElementType propertyType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Property");
+ createPropertyInClassifier((Classifier) component_ComponentPacakge, propertyType);
+ Assert.assertTrue("The new element should be a Component", newElement instanceof Property);
+ String newName = ((NamedElement) newElement).getName();
+ Activator.log.trace(Activator.PLCSTRATEGY_TESTS_TRACE, newName);
+ Assert.assertTrue("The name of the new Componenet should be Attribute",
+ "Attribute".equalsIgnoreCase(((NamedElement) newElement).getName().replaceAll("[0-9]", "")));
+ createCommand.undo(monitor, null);
+ }
+
+ @Test
+ public void testCreatePropertyInClass() throws ExecutionException {
+ IElementType propertyType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Property");
+ createPropertyInClassifier((Classifier) class_ClassPackage, propertyType);
+ Assert.assertTrue("The new element should be a Component", newElement instanceof Property);
+ String newName = ((NamedElement) newElement).getName();
+ Activator.log.trace(Activator.PLCSTRATEGY_TESTS_TRACE, newName);
+ Assert.assertTrue("The name of the new Componenet should be Attribute",
+ "Attribute".equalsIgnoreCase(((NamedElement) newElement).getName().replaceAll("[0-9]", "")));
+ createCommand.undo(monitor, null);
+ }
+
+
+ @Test
+ public void testRenameContainer() throws ExecutionException {
+ EStructuralFeature nameFeature = component_ComponentPacakge.eClass().getEStructuralFeature("name");
+ SetRequest request = new SetRequest(transactionalEditingDomain, component_ComponentPacakge, nameFeature, "afterSetComponentName");
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(component_ComponentPacakge);
+ ICommand setCommand = service.getEditCommand(request);
+ Assert.assertTrue("The set command should be executable", setCommand.canExecute());
+ IStatus status = setCommand.execute(monitor, null);
+ Assert.assertTrue("The command should return OK", status.isOK());
+
+ // 1- Verify that the set command did work
+ Assert.assertTrue("The component name should be afterSetComponentName",
+ "afterSetComponentName".equalsIgnoreCase(component_ComponentPacakge.getName().replaceAll("[0-9]", "")));
+
+ // 2- Verify that the property strategy worked as excpected
+ Property componentProperty = component_ComponentPacakge.getAttributes().get(0);
+ Assert.assertTrue("The component's property name should be afterSetComponentName",
+ "afterSetComponentName_Property".equalsIgnoreCase(componentProperty.getName().replaceAll("[0-9]", "")));
+
+ // 3- Test the Undo/Redo
+ Assert.assertTrue("The set command should be undoable", setCommand.canUndo());
+ status = setCommand.undo(monitor, null);
+ Assert.assertTrue("The undo status should return OK", status.isOK());
+ Assert.assertTrue("The component name should be beforeStrategyComponent",
+ "beforeStrategyComponent".equalsIgnoreCase(component_ComponentPacakge.getName().replaceAll("[0-9]", "")));
+ Assert.assertTrue("The component's property name should be beforeStrategyComponentProperty",
+ "beforeStrategyComponentProperty".equalsIgnoreCase(componentProperty.getName().replaceAll("[0-9]", "")));
+
+ Assert.assertTrue("The set command should be redoable", setCommand.canRedo());
+ status = setCommand.redo(monitor, null);
+ Assert.assertTrue("The redo status should return OK", status.isOK());
+ Assert.assertTrue("The component name should be afterSetComponentName",
+ "afterSetComponentName".equalsIgnoreCase(component_ComponentPacakge.getName().replaceAll("[0-9]", "")));
+ Assert.assertTrue("The component's property name should be afterSetComponentName",
+ "afterSetComponentName_Property".equalsIgnoreCase(componentProperty.getName().replaceAll("[0-9]", "")));
+
+ }
+
+
+ @Test
+ public void testReorientAssociation() throws ExecutionException {
+ IElementType associationType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Association");
+ IElementType classType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Class");
+ IElementType componentType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Component");
+ createElementInPackage(subModel, classType);
+ EObject sourceClass = newElement;
+ createElementInPackage(subModel, componentType);
+ EObject targetComponent = newElement;
+
+ Classifier sourceClassifier = (Classifier) sourceClass;
+ List<EObject> originalElements = new ArrayList<EObject>(sourceClassifier.getOwnedElements());
+
+ CreateRelationshipRequest request = new CreateRelationshipRequest(transactionalEditingDomain, sourceClass, targetComponent, associationType);
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(subModel);
+ createCommand = service.getEditCommand(request);
+ Assert.assertTrue("The created command should be executable", createCommand.canExecute());
+ IStatus status = createCommand.execute(monitor, null);
+ Assert.assertTrue("The command should return OK", status.isOK());
+
+ List<EObject> afterCreateElements = new ArrayList<EObject>(sourceClassifier.getOwnedElements());
+ afterCreateElements.removeAll(originalElements);
+ Assert.assertEquals("There should have been two created elements in the source: the owned association "
+ + "and the property pointing to the target", 2, afterCreateElements.size());
+ for (EObject eobject : afterCreateElements) {
+ newElement = eobject instanceof Association ? eobject : null;
+ }
+ Assert.assertNotNull("There should have been an Association created", newElement);
+
+ // 2- Test the Undo/Redo
+ Assert.assertTrue("The creation command should be undoable", createCommand.canUndo());
+ status = createCommand.undo(monitor, null);
+ Assert.assertTrue("The undo status should return OK", status.isOK());
+ List<EObject> afterUndoElements = new ArrayList<EObject>(sourceClassifier.getOwnedElements());
+ afterUndoElements.removeAll(originalElements);
+ Assert.assertEquals("The model should return in the same state as before the creation command", 0,
+ afterUndoElements.size());
+
+ Assert.assertTrue("The creation command should be redoable", createCommand.canRedo());
+ status = createCommand.redo(monitor, null);
+ Assert.assertTrue("The redo status should return OK", status.isOK());
+ List<EObject> afterRedoElements = new ArrayList<EObject>(sourceClassifier.getOwnedElements());
+ afterRedoElements.removeAll(originalElements);
+ Assert.assertEquals("There should be one element added afer the redo of the creation command", 2, afterRedoElements.size());
+
+ // 3- Cache the memeberEnds
+ Association currentAssociation = (Association) newElement;
+ String beforeMoveName = currentAssociation.getLabel();
+ Property targetProperty = currentAssociation.getMemberEnds().get(0);
+ String targetPropertyName = targetProperty.getType().getName();
+ Property sourceProperty = currentAssociation.getMemberEnds().get(1);
+ String sourcePropertyName = sourceProperty.getType().getName();
+
+ // 4- Create a new Target and move the relationship
+ createElementInPackage(subModel, classType);
+ EObject newTarget = newElement;
+ ReorientRelationshipRequest reorientRequest = new ReorientRelationshipRequest(transactionalEditingDomain, currentAssociation,
+ newTarget, targetComponent, ReorientRelationshipRequest.REORIENT_TARGET);
+ createCommand = service.getEditCommand(reorientRequest);
+ Assert.assertTrue("The created command should be executable", createCommand.canExecute());
+ IStatus reorientStatus = createCommand.execute(monitor, null);
+ Assert.assertTrue("The command should return OK", reorientStatus.isOK());
+ String afterMoveName = currentAssociation.getLabel();
+
+ // 4.1 - Test the new association name
+ Assert.assertFalse("The new association should have a different label after the move", beforeMoveName.equals(afterMoveName));
+
+ // 4.2- Test the new target name
+ Association reorientedAssociation = currentAssociation;
+ Property reorientTargetProperty = reorientedAssociation.getMemberEnds().get(0);
+ String reorientTargetPropertyName = reorientTargetProperty.getType().getName();
+ Assert.assertFalse("The name of the target should have changed", reorientTargetPropertyName.equalsIgnoreCase(targetPropertyName));
+ Property reorientSourceProperty = reorientedAssociation.getMemberEnds().get(1);
+ String reorientSourcePropertyName = reorientSourceProperty.getType().getName();
+ Assert.assertTrue("The name of the source should not have changed", reorientSourcePropertyName.equalsIgnoreCase(sourcePropertyName));
+
+ }
+
+
+ @Test
+ public void testRenameImmutableProperty() throws ExecutionException {
+ EStructuralFeature nameFeature = property_class_subModel.eClass().getEStructuralFeature("name");
+ SetRequest request = new SetRequest(transactionalEditingDomain, property_class_subModel, nameFeature, "afterSetPropertyName");
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(property_class_subModel);
+ ICommand setCommand = service.getEditCommand(request);
+ Assert.assertTrue("The set command should be executable", setCommand.canExecute());
+ IStatus status = setCommand.execute(monitor, null);
+ Assert.assertTrue("The command should return OK", status.isOK());
+
+ // 1- Verify that the property strategy worked as excpected
+ Assert.assertTrue("The class' property name should be propertyNameIsImmutable",
+ "propertyNameIsImmutable".equalsIgnoreCase(property_class_subModel.getName().replaceAll("[0-9]", "")));
+
+ // 2- Test the Undo/Redo
+ setCommand.undo(monitor, null);
+ Assert.assertTrue("The class' property name should return to beforeStrategyClassProperty",
+ "beforeStrategyClassProperty".equalsIgnoreCase(property_class_subModel.getName().replaceAll("[0-9]", "")));
+
+ setCommand.redo(monitor, null);
+ Assert.assertTrue("The class' property name should return to propertyNameIsImmutable",
+ "propertyNameIsImmutable".equalsIgnoreCase(property_class_subModel.getName().replaceAll("[0-9]", "")));
+
+ // 3- Return to initial state
+ setCommand.undo(monitor, null);
+ Assert.assertTrue("The class' property name should return to beforeStrategyClassProperty",
+ "beforeStrategyClassProperty".equalsIgnoreCase(property_class_subModel.getName().replaceAll("[0-9]", "")));
+ }
+
+ @Test
+ public void testRenameImmutablePropertyInClass() throws ExecutionException {
+ EStructuralFeature nameFeature = class_subModel.eClass().getEStructuralFeature("name");
+ CommandStack commandStack = transactionalEditingDomain.getCommandStack();
+ commandStack.flush();
+ SetRequest request = new SetRequest(transactionalEditingDomain, class_subModel, nameFeature, "afterSetClassName");
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(class_subModel);
+ ICommand setCommand = service.getEditCommand(request);
+ Assert.assertTrue("The set command should be executable", setCommand.canExecute());
+ // The command needs to be executed inside the commandStack first has it has nested commands and the undo on the
+ // setCommand will only affect the first setRequest
+ commandStack.execute(new GMFtoEMFCommandWrapper(setCommand));
+
+ // 1- Verify that the set command did work
+ Assert.assertTrue("The class name should be afterSetClassName",
+ "afterSetClassName".equalsIgnoreCase(class_subModel.getName().replaceAll("[0-9]", "")));
+
+ // 2- Verify that the property strategy worked as excpected
+ Assert.assertTrue("The class' property name should be propertyNameIsImmutable",
+ "propertyNameIsImmutable".equalsIgnoreCase(property_class_subModel.getName().replaceAll("[0-9]", "")));
+
+ // 3- Test the Undo/Redo
+ commandStack.undo();
+ Assert.assertTrue("The class name should return to beforeStrategyClass",
+ "beforeStrategyClass".equalsIgnoreCase(class_subModel.getName().replaceAll("[0-9]", "")));
+ Assert.assertTrue("The class' property name should return to beforeStrategyClassProperty",
+ "beforeStrategyClassProperty".equalsIgnoreCase(property_class_subModel.getName().replaceAll("[0-9]", "")));
+
+ commandStack.redo();
+ Assert.assertTrue("The class name should be afterSetClassName",
+ "afterSetClassName".equalsIgnoreCase(class_subModel.getName().replaceAll("[0-9]", "")));
+ Assert.assertTrue("The class' property name should return to propertyNameIsImmutable",
+ "propertyNameIsImmutable".equalsIgnoreCase(property_class_subModel.getName().replaceAll("[0-9]", "")));
+
+ // 4- Return to initial state
+ commandStack.undo();
+
+ }
+
+
+ public void createPropertyInClassifier(Classifier container, IElementType elementType) throws ExecutionException {
+ List<EObject> originalElements = new ArrayList<EObject>(container.getAttributes());
+ CreateElementRequest request = new CreateElementRequest(transactionalEditingDomain, container, elementType);
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(container);
+ createCommand = service.getEditCommand(request);
+ Assert.assertTrue("The created command should be executable", createCommand.canExecute());
+ IStatus status = createCommand.execute(monitor, null);
+ Assert.assertTrue("The command should return OK", status.isOK());
+
+ List<EObject> afterCreateElements = new ArrayList<EObject>(container.getAttributes());
+ afterCreateElements.removeAll(originalElements);
+ Assert.assertEquals("There should have been only one created element", 1, afterCreateElements.size());
+
+ // 2- Test the Undo/Redo
+ assertUndoRedo(status, originalElements, container);
+
+ }
+
+ public void createElementInPackage(Package container, IElementType elementType) throws ExecutionException {
+ // 1- Test the Creation of the new element
+ List<EObject> originalElements = new ArrayList<EObject>(container.getPackagedElements());
+ CreateElementRequest request = new CreateElementRequest(transactionalEditingDomain, container, elementType);
+ IElementEditService service = ElementEditServiceUtils.getCommandProvider(container);
+ createCommand = service.getEditCommand(request);
+ Assert.assertTrue("The created command should be executable", createCommand.canExecute());
+ IStatus status = createCommand.execute(monitor, null);
+ Assert.assertTrue("The command should return OK", status.isOK());
+
+ List<EObject> afterCreateElements = new ArrayList<EObject>(container.getPackagedElements());
+ afterCreateElements.removeAll(originalElements);
+ Assert.assertEquals("There should have been only one created element", 1, afterCreateElements.size());
+
+ // 2- Test the Undo/Redo
+ assertUndoRedo(status, originalElements, container);
+
+ }
+
+ public static void assertUndoRedo(IStatus status, List<EObject> originalElements, Classifier container) throws ExecutionException {
+ Assert.assertTrue("The creation command should be undoable", createCommand.canUndo());
+ status = createCommand.undo(monitor, null);
+ Assert.assertTrue("The undo status should return OK", status.isOK());
+ List<EObject> afterUndoElements = new ArrayList<EObject>(container.getAttributes());
+ afterUndoElements.removeAll(originalElements);
+ Assert.assertEquals("The model should return in the same state as before the creation command", 0,
+ afterUndoElements.size());
+
+ Assert.assertTrue("The creation command should be redoable", createCommand.canRedo());
+ status = createCommand.redo(monitor, null);
+ Assert.assertTrue("The redo status should return OK", status.isOK());
+ List<EObject> afterRedoElements = new ArrayList<EObject>(container.getAttributes());
+ afterRedoElements.removeAll(originalElements);
+ Assert.assertEquals("There should be one element added afer the redo of the creation command", 1, afterRedoElements.size());
+ newElement = afterRedoElements.get(0);
+ }
+
+ public static void assertUndoRedo(IStatus status, List<EObject> originalElements, Package container) throws ExecutionException {
+ Assert.assertTrue("The creation command should be undoable", createCommand.canUndo());
+ status = createCommand.undo(monitor, null);
+ Assert.assertTrue("The undo status should return OK", status.isOK());
+ List<EObject> afterUndoElements = new ArrayList<EObject>(container.getPackagedElements());
+ afterUndoElements.removeAll(originalElements);
+ Assert.assertEquals("The model should return in the same state as before the creation command", 0,
+ afterUndoElements.size());
+
+ Assert.assertTrue("The creation command should be redoable", createCommand.canRedo());
+ status = createCommand.redo(monitor, null);
+ Assert.assertTrue("The redo status should return OK", status.isOK());
+ List<EObject> afterRedoElements = new ArrayList<EObject>(container.getPackagedElements());
+ afterRedoElements.removeAll(originalElements);
+ Assert.assertEquals("There should be one element added afer the redo of the creation command", 1, afterRedoElements.size());
+ newElement = afterRedoElements.get(0);
+ }
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/utils/ITestConstants.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/utils/ITestConstants.java
new file mode 100755
index 00000000000..b8dca29ff02
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/utils/ITestConstants.java
@@ -0,0 +1,179 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.utils;
+
+
+public interface ITestConstants {
+
+ // Saving Created Resources
+ public static String RESOURCES_PROJECTNAME = "PropertyLifecycle";
+
+ public static String RESOURCES_FOLDERNAME = "resources";
+
+ public static String RESOURCES_ENCODING = "UTF-8";
+
+ public static String RESOURCES_UMLMODELNAME = "testmodel.uml";
+
+ public static String RESOURCES_DIMODELNAME = "testmodel.di";
+
+ public static String RESOURCES_STRATEGYMODELNAME = "teststrategy.propertylifecycle";
+
+
+ // Init UML Test model
+ public static String ROOTMODEL_NAME = "PropertyLifecycleTestModel";
+
+ public static String SUBMODEL_NAME = "SubModel";
+
+ public static String COMPONENT_PACKAGE_NAME = "ComponentPackage";
+
+ public static String COMPONENT_NAME = "beforeStrategyComponent";
+
+ public static String CLASS_PACKAGE_NAME = "ClassPackage";
+
+ public static String CLASS_NAME = "beforeStrategyClass";
+
+ public static String PROPERTY_CLASS_NAME = "beforeStrategyClassProperty";
+
+ public static String PROPERTY_COMPONENT_NAME = "beforeStrategyComponentProperty";
+
+ // Init Strategy test model
+ static final String STRATEGYSET_DESCRIPTION = "this is a strategySet containing strategies applicable to the Elements";
+
+ static final String STRATEGYSET_ID = "org.eclipse.papyrus.infra.propertylifecycle.tests.propertylifecycletest";
+
+ static final String STRATEGYSET_NAME = "test strategySet";
+
+ /** Component strategy initialization variables */
+ static final String STRATEGYELEMENT_BASETYPE_COMPONENT = "org.eclipse.papyrus.uml.Component";
+
+ static final String STRATEGYELEMENT_DESCRIPTION_COMPONENT = "comonent description";
+
+ static final String STRATEGYELEMENT_ID_COMPONENT = "org.eclipse.papyrus.uml.Component.Tests";
+
+ static final String STRATEGYELEMENT_NAME_COMPONENT = "org.eclipse.papyrus.uml.Component.Tests";
+
+ static final String STRATEGYELEMENT_SPECIALIZEDTYPE_COMPONENT = null;
+
+ static final String STRATEGYPROPERTY_FEATURELABEL_COMPONENT = "name";
+
+ static final Integer ELEMENTPROPERTY_PRIORITY_COMPONENT = 0;
+
+ static final String ELEMENTPROPERTY_PROCESSORPATH_COMPONENT = "org.eclipse.papyrus.infra.propertylifecycle.tests.strategies.processors.ComponentProcessor";
+
+ /** Class strategy initialization variables */
+ static final String STRATEGYELEMENT_BASETYPE_CLASS = "org.eclipse.papyrus.uml.Class";
+
+ static final String STRATEGYELEMENT_DESCRIPTION_CLASS = "class description";
+
+ static final String STRATEGYELEMENT_ID_CLASS = "org.eclipse.papyrus.uml.Class.Tests";
+
+ static final String STRATEGYELEMENT_NAME_CLASS = "org.eclipse.papyrus.uml.Class.Tests";
+
+ static final String STRATEGYELEMENT_SPECIALIZEDTYPE_CLASS = null;
+
+ static final String STRATEGYCONTAINER_BASETYPE_CLASS = "org.eclipse.papyrus.uml.Model";
+
+ static final String STRATEGYCONTAINER_SPECIALIZEDTYPE_CLASS = null;
+
+ static final String STRATEGYPROPERTY_FEATURELABEL_CLASS = "name";
+
+ static final Integer ELEMENTPROPERTY_PRIORITY_CLASS = 0;
+
+ static final String ELEMENTPROPERTY_PROCESSORPATH_CLASS = "org.eclipse.papyrus.infra.propertylifecycle.tests.strategies.processors.ClassProcessor";
+
+ /** Property strategy initialization variables */
+ // 0- Shared variables
+ static final String STRATEGYELEMENT_BASETYPE_PROPERTY = "org.eclipse.papyrus.uml.Property";
+
+ static final String STRATEGYELEMENT_DESCRIPTION_PROPERTY = "property description";
+
+ static final String STRATEGYELEMENT_SPECIALIZEDTYPE_PROPERTY = null;
+
+ static final String STRATEGYCONTAINER_SPECIALIZEDTYPE_PROPERTY = null;
+
+ static final String STRATEGYPROPERTY_FEATURELABEL_PROPERTY = "name";
+
+ static final String ELEMENTPROPERTY_PROCESSORPATH_PROPERTY = "org.eclipse.papyrus.infra.propertylifecycle.tests.strategies.processors.PropertyProcessor";
+
+ // 1- Component property
+
+ static final String STRATEGYELEMENT_ID_COMPONENTPROPERTY = "org.eclipse.papyrus.uml.ComponentProperty.Tests";
+
+ static final String STRATEGYELEMENT_NAME_COMPONENTPROPERTY = "org.eclipse.papyrus.uml.ComponentProperty.Tests";
+
+ static final String STRATEGYCONTAINER_BASETYPE_COMPONENTPROPERTY = "org.eclipse.papyrus.uml.Component";
+
+ static final Integer ELEMENTPROPERTY_PRIORITY_PROPERTY = 0;
+
+ // 2- Class property
+ static final String STRATEGYELEMENT_ID_CLASSPROPERTY = "org.eclipse.papyrus.uml.ClassProperty.Tests";
+
+ static final String STRATEGYELEMENT_NAME_CLASSPROPERTY = "org.eclipse.papyrus.uml.ClassProperty.Tests";
+
+ static final String STRATEGYCONTAINER_BASETYPE_CLASSPROPERTY = "org.eclipse.papyrus.uml.Class";
+
+ static final Integer ELEMENTPROPERTY_PRIORITY_CLASSPROPERTY = -1;
+
+ /** SysML Block strategy initialization variables */
+ static final String STRATEGYELEMENT_BASETYPE_SYSMLBLOCK = "org.eclipse.papyrus.sysml.Block";
+
+ static final String STRATEGYELEMENT_DESCRIPTION_SYSMLBLOCK = "SysML Block description";
+
+ static final String STRATEGYELEMENT_ID_SYSMLBLOCK = "org.eclipse.papyrus.sysml.Block.Tests";
+
+ static final String STRATEGYELEMENT_NAME_SYSMLBLOCK = "org.eclipse.papyrus.sysml.Block.Tests";
+
+ static final String STRATEGYELEMENT_SPECIALIZEDTYPE_SYSMLBLOCK = "org.eclipse.papyrus.uml.Class";
+
+ static final String STRATEGYPROPERTY_FEATURELABEL_SYSMLBLOCK = "name";
+
+ static final Integer ELEMENTPROPERTY_PRIORITY_SYSMLBLOCK = 0;
+
+ static final String ELEMENTPROPERTY_PROCESSORPATH_SYSMLBLOCK = "org.eclipse.papyrus.infra.propertylifecycle.tests.strategies.processors.SysmlBlockProcessor";
+
+ /** SysML14 Block strategy initialization variables */
+ static final String STRATEGYELEMENT_BASETYPE_SYSML14BLOCK = "org.eclipse.papyrus.SysML14.Block";
+
+ static final String STRATEGYELEMENT_DESCRIPTION_SYSML14BLOCK = "SysML14 Block description";
+
+ static final String STRATEGYELEMENT_ID_SYSML14BLOCK = "org.eclipse.papyrus.SysML14.Block.Tests";
+
+ static final String STRATEGYELEMENT_NAME_SYSML14BLOCK = "org.eclipse.papyrus.SysML14.Block.Tests";
+
+ static final String STRATEGYELEMENT_SPECIALIZEDTYPE_SYSML14BLOCK = "org.eclipse.papyrus.uml.Class";
+
+ static final String STRATEGYPROPERTY_FEATURELABEL_SYSML14BLOCK = "name";
+
+ static final Integer ELEMENTPROPERTY_PRIORITY_SYSML14BLOCK = 0;
+
+ static final String ELEMENTPROPERTY_PROCESSORPATH_SYSML14BLOCK = "org.eclipse.papyrus.infra.propertylifecycle.tests.strategies.processors.Sysml14BlockProcessor";
+
+ /** Association strategy initialization variables */
+ static final String STRATEGYELEMENT_BASETYPE_ASSOCIATION = "org.eclipse.papyrus.uml.Association";
+
+ static final String STRATEGYELEMENT_DESCRIPTION_ASSOCIATION = "association description";
+
+ static final String STRATEGYELEMENT_ID_ASSOCIATION = "org.eclipse.papyrus.uml.Association.Tests";
+
+ static final String STRATEGYELEMENT_NAME_ASSOCIATION = "org.eclipse.papyrus.uml.Association.Tests";
+
+ static final String STRATEGYELEMENT_SPECIALIZEDTYPE_ASSOCIATION = null;
+
+ static final String STRATEGYPROPERTY_FEATURELABEL_ASSOCIATION = "name";
+
+ static final Integer ELEMENTPROPERTY_PRIORITY_ASSOCIATION = 0;
+
+ static final String ELEMENTPROPERTY_PROCESSORPATH_ASSOCIATION = "org.eclipse.papyrus.infra.propertylifecycle.tests.strategies.processors.AssociationProcessor";
+
+}
diff --git a/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/utils/StrategyFactory.java b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/utils/StrategyFactory.java
new file mode 100755
index 00000000000..e01beab45c3
--- /dev/null
+++ b/tests/junit/extraplugins/propertylifecycle/org.eclipse.papyrus.propertylifecycle.tests/src/org/eclipse/papyrus/propertylifecycle/tests/utils/StrategyFactory.java
@@ -0,0 +1,183 @@
+/*****************************************************************************
+ * 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.propertylifecycle.tests.utils;
+
+import org.eclipse.papyrus.propertylifecycle.AbstractValueProcessor;
+import org.eclipse.papyrus.propertylifecycle.BasicTrigger;
+import org.eclipse.papyrus.propertylifecycle.ElementContainer;
+import org.eclipse.papyrus.propertylifecycle.ElementProperty;
+import org.eclipse.papyrus.propertylifecycle.JavaProcessor;
+import org.eclipse.papyrus.propertylifecycle.PropertylifecycleFactory;
+import org.eclipse.papyrus.propertylifecycle.StrategyElement;
+import org.eclipse.papyrus.propertylifecycle.StrategySet;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Class used to facilitate the creation of the test strategies
+ *
+ */
+public class StrategyFactory {
+
+ public static PropertylifecycleFactory strategyModelFactory = PropertylifecycleFactory.eINSTANCE;
+
+ public StrategyFactory() {
+
+ }
+
+ /**
+ * Handle the creation of the strategySet containing the test strategies
+ *
+ * @param description
+ * user informations about the set
+ * @param id
+ * the unique id of the set
+ * @param name
+ * the name of the set
+ * @return
+ * The {@link org.eclipse.papyrus.propertylifecycle.StrategySet StrategySet}
+ */
+ public static StrategySet createStrategySet(String description, String id, String name) {
+ StrategySet strategySet = strategyModelFactory.createStrategySet();
+ Assert.assertNotNull("The strategySet should not be null", strategySet);
+
+ strategySet.setDecription(description);
+ strategySet.setId(id);
+ Assert.assertNotNull("The strategySet ID should not be null", strategySet.getId());
+ strategySet.setName(name);
+
+ return strategySet;
+ }
+
+ /**
+ * Handle the creation of the core of the new strategy, allowing the manager to match it against the model's elements.
+ * For the strategy to be complete there still needs to specify the properties affected and their triggers and processors
+ *
+ * @param baseType
+ * The base elementtype of the element this strategy will affect
+ * @param description
+ * The user information explaining the strategy
+ * @param id
+ * The unique id of the strategy
+ * @param name
+ * The name of the strategy
+ * @param specializedType
+ * The specialized elementtype, if any, of the element
+ * @return
+ * The created new strategy's {@link org.eclipse.papyrus.propertylifecycle.StrategyElement core}
+ */
+ public StrategyElement createStrategy(String baseType, String description, String id, String name, String specializedType) {
+ StrategyElement strategyElement = strategyModelFactory.createStrategyElement();
+ Assert.assertNotNull("The strategyElement should not be null", strategyElement);
+
+ strategyElement.setBaseType(baseType);
+ Assert.assertNotNull("The strategyElement baseType should not be null", strategyElement.getBaseType());
+ strategyElement.setDecription(description);
+ strategyElement.setId(id);
+ Assert.assertNotNull("The strategyElement id should not be null", strategyElement.getId());
+ strategyElement.setName(name);
+ strategyElement.setSpecializedType(specializedType);
+
+ return strategyElement;
+ }
+
+ /**
+ * Handle the creation of the containers used to specify a more specific context to the application of the strategy
+ *
+ * @param baseType
+ * The base elementtype of the container
+ * @param specializedType
+ * The specialized elementtype, if any, of the container
+ * @param container
+ * The container's container, if any
+ * @return
+ * The identified container {@link org.eclipse.papyrus.propertylifecycle.ElementContainer context} of the element affected by the strategy
+ */
+ public ElementContainer createContainer(String baseType, String specializedType, ElementContainer container) {
+ ElementContainer elementContainer = strategyModelFactory.createElementContainer();
+ Assert.assertNotNull("The elementContainer should not be null", elementContainer);
+
+ elementContainer.setBaseType(baseType);
+ Assert.assertNotNull("The elementContainer baseType should not be null", elementContainer.getBaseType());
+ elementContainer.setSpecializedType(specializedType);
+ elementContainer.setContainersContainer(container);
+
+ return elementContainer;
+ }
+
+ /**
+ * Handle the specification of the property to be affected by the strategy
+ *
+ * @param featureLabel
+ * The label of the property
+ * @param priority
+ * The priority in case of multiple strategies affecting the same property
+ * @param valueProcessor
+ * The processor returning the new value of the property
+ * @return
+ * The property {@link org.eclipse.papyrus.propertylifecycle.ElementProperty specification}
+ */
+ public ElementProperty createProperty(String featureLabel, Integer priority, AbstractValueProcessor valueProcessor) {
+ ElementProperty elementProperty = strategyModelFactory.createElementProperty();
+ Assert.assertNotNull("The elementProperty should not be null", elementProperty);
+
+ elementProperty.setFeatureLabel(featureLabel);
+ Assert.assertNotNull("The elementProperty featureLabel should not be null", elementProperty.getFeatureLabel());
+ elementProperty.setPriority(priority);
+ Assert.assertNotNull("The elementProperty should not be null", elementProperty.getPriority());
+
+ elementProperty.setValueProcessor(valueProcessor);
+ Assert.assertNotNull("The valueProcessor should not be null", elementProperty.getValueProcessor());
+ Assert.assertNotNull("The processorPath should not be null nor empty", ((JavaProcessor) elementProperty.getValueProcessor()).getClassName() != null
+ && ((JavaProcessor) elementProperty.getValueProcessor()).getClassName() != "");
+ elementProperty.getTriggers().add(createBasicTrigger());
+ Assert.assertNotNull("The trigger list should not be empty", elementProperty.getTriggers().size() > 0);
+
+ return elementProperty;
+ }
+
+ /**
+ * Handle the specification of the processor used for this property
+ *
+ * @param processorPath
+ * The path of the processor used to call on it
+ * @return
+ * The {@link org.eclipse.papyrus.propertylifecycle.JavaProcessor processor}
+ */
+ public JavaProcessor createJavaProcessor(String processorPath) {
+ JavaProcessor javaProcessor = strategyModelFactory.createJavaProcessor();
+ Assert.assertNotNull("The javaProcessor should not be null", javaProcessor);
+ javaProcessor.setClassName(processorPath);
+
+ return javaProcessor;
+ }
+
+ /**
+ * Handle the creation of the trigger used to apply the strategy based on the lifecycle
+ *
+ * @return
+ * The {@link org.eclipse.papyrus.propertylifecycle.BasicTrigger trigger}
+ */
+ public BasicTrigger createBasicTrigger() {
+ BasicTrigger basicTrigger = strategyModelFactory.createBasicTrigger();
+ Assert.assertNotNull("The basicTrigger should not be null", basicTrigger);
+ basicTrigger.setOnCreate(true);
+ basicTrigger.setOnMove(true);
+ basicTrigger.setOnDelete(true);
+ basicTrigger.setOnOpen(true);
+
+ return basicTrigger;
+ }
+
+}

Back to the top