diff --git a/plugins/org.polarsys.capella.filtering.tools/src/org/polarsys/capella/filtering/tools/utils/FilteringUtils.java b/plugins/org.polarsys.capella.filtering.tools/src/org/polarsys/capella/filtering/tools/utils/FilteringUtils.java index 34cad33e..6551aa18 100644 --- a/plugins/org.polarsys.capella.filtering.tools/src/org/polarsys/capella/filtering/tools/utils/FilteringUtils.java +++ b/plugins/org.polarsys.capella.filtering.tools/src/org/polarsys/capella/filtering/tools/utils/FilteringUtils.java @@ -381,12 +381,14 @@ public static Collection getMainAndReferencedVariantProjects(EObject ob public static List getReferencedProjects(Project project) { List res = new ArrayList(); Session session = SessionManager.INSTANCE.getSession(project); - TransactionalEditingDomain transactionalEditingDomain = session.getTransactionalEditingDomain(); - IModel model = ILibraryManager.INSTANCE.getModel(project); - Collection allReferences = LibraryManagerExt.getAllReferences(model); - for (IModel lib : allReferences) { - if (lib instanceof ICapellaModel) { - res.add(((ICapellaModel) lib).getProject(transactionalEditingDomain)); + if (session != null) { + TransactionalEditingDomain transactionalEditingDomain = session.getTransactionalEditingDomain(); + IModel model = ILibraryManager.INSTANCE.getModel(project); + Collection allReferences = LibraryManagerExt.getAllReferences(model); + for (IModel lib : allReferences) { + if (lib instanceof ICapellaModel) { + res.add(((ICapellaModel) lib).getProject(transactionalEditingDomain)); + } } } return res; diff --git a/plugins/org.polarsys.capella.filtering.transition/src/org/polarsys/capella/filtering/transition/rules/FilteringModelRule.java b/plugins/org.polarsys.capella.filtering.transition/src/org/polarsys/capella/filtering/transition/rules/FilteringModelRule.java index be2521fd..4f4b611d 100644 --- a/plugins/org.polarsys.capella.filtering.transition/src/org/polarsys/capella/filtering/transition/rules/FilteringModelRule.java +++ b/plugins/org.polarsys.capella.filtering.transition/src/org/polarsys/capella/filtering/transition/rules/FilteringModelRule.java @@ -15,7 +15,7 @@ import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; -import org.polarsys.capella.core.data.capellamodeller.SystemEngineering; +import org.polarsys.capella.core.data.capellamodeller.Project; import org.polarsys.capella.core.transition.common.constants.ITransitionConstants; import org.polarsys.capella.core.transition.common.handlers.attachment.AttachmentHelper; import org.polarsys.capella.core.transition.common.rules.AbstractUpdateRule; @@ -52,12 +52,12 @@ protected void retrieveGoDeep(EObject source_p, List result_p, IContext */ @Override protected EObject getDefaultContainer(EObject element_p, EObject result_p, IContext context_p) { - return (SystemEngineering) context_p.get(ITransitionConstants.TRANSFORMATION_TARGET_ROOT); + return (Project) context_p.get(ITransitionConstants.TRANSFORMATION_TARGET_ROOT); } @Override protected EObject getBestContainer(EObject element_p, EObject result_p, IContext context_p) { - return (SystemEngineering) context_p.get(ITransitionConstants.TRANSFORMATION_TARGET_ROOT); + return (Project) context_p.get(ITransitionConstants.TRANSFORMATION_TARGET_ROOT); } /** diff --git a/tests/org.polarsys.capella.filtering.tests.ju/META-INF/MANIFEST.MF b/tests/org.polarsys.capella.filtering.tests.ju/META-INF/MANIFEST.MF index a0f869fa..565fa723 100644 --- a/tests/org.polarsys.capella.filtering.tests.ju/META-INF/MANIFEST.MF +++ b/tests/org.polarsys.capella.filtering.tests.ju/META-INF/MANIFEST.MF @@ -9,8 +9,9 @@ Require-Bundle: org.polarsys.capella.filtering.tools, org.eclipse.emf.diffmerge.ui, org.polarsys.capella.test.framework;bundle-version="1.2.1", org.eclipse.emf.common, - org.polarsys.capella.filtering.sirius.analysis;bundle-version="1.2.0", - org.polarsys.capella.filtering.business.queries;bundle-version="1.2.0" + org.polarsys.capella.filtering.sirius.analysis, + org.polarsys.capella.filtering.business.queries, + org.polarsys.capella.test.transition.ju Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Export-Package: org.polarsys.capella.filtering.tests.ju.tests.derivation, diff --git a/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/.project b/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/.project new file mode 100644 index 00000000..17770f63 --- /dev/null +++ b/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/.project @@ -0,0 +1,12 @@ + + + Transition + + + + + + + org.polarsys.capella.project.nature + + diff --git a/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/Transition.afm b/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/Transition.afm new file mode 100644 index 00000000..43eee218 --- /dev/null +++ b/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/Transition.afm @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/Transition.aird b/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/Transition.aird new file mode 100644 index 00000000..6bde0c0f --- /dev/null +++ b/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/Transition.aird @@ -0,0 +1,29 @@ + + + Transition.afm + Transition.melodymodeller + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/Transition.melodymodeller b/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/Transition.melodymodeller new file mode 100644 index 00000000..a85c181a --- /dev/null +++ b/tests/org.polarsys.capella.filtering.tests.ju/model/Transition/Transition.melodymodeller @@ -0,0 +1,290 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.polarsys.capella.filtering.tests.ju/src/org/polarsys/capella/filtering/tests/ju/tests/misc/MiscTestSuite.java b/tests/org.polarsys.capella.filtering.tests.ju/src/org/polarsys/capella/filtering/tests/ju/tests/misc/MiscTestSuite.java index a9b2c796..2f1dd200 100644 --- a/tests/org.polarsys.capella.filtering.tests.ju/src/org/polarsys/capella/filtering/tests/ju/tests/misc/MiscTestSuite.java +++ b/tests/org.polarsys.capella.filtering.tests.ju/src/org/polarsys/capella/filtering/tests/ju/tests/misc/MiscTestSuite.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.List; +import org.polarsys.capella.filtering.tests.ju.tests.misc.transition.TransitionTestSuite; import org.polarsys.capella.test.framework.api.BasicTestArtefact; import org.polarsys.capella.test.framework.api.BasicTestSuite; @@ -30,6 +31,7 @@ protected List getTests() { testCases.add(new FilteringCriterionSetHelperTest()); testCases.add(new FilteringServicesTest()); testCases.add(new FilteringUtilsTest()); + testCases.add(new TransitionTestSuite()); return testCases; } diff --git a/tests/org.polarsys.capella.filtering.tests.ju/src/org/polarsys/capella/filtering/tests/ju/tests/misc/transition/FunctionalTransitionTestCase.java b/tests/org.polarsys.capella.filtering.tests.ju/src/org/polarsys/capella/filtering/tests/ju/tests/misc/transition/FunctionalTransitionTestCase.java new file mode 100644 index 00000000..23c7dee6 --- /dev/null +++ b/tests/org.polarsys.capella.filtering.tests.ju/src/org/polarsys/capella/filtering/tests/ju/tests/misc/transition/FunctionalTransitionTestCase.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2019 THALES GLOBAL SERVICES. + * 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: + * Thales - initial API and implementation + *******************************************************************************/ +package org.polarsys.capella.filtering.tests.ju.tests.misc.transition; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.polarsys.capella.test.transition.ju.TopDownTransitionTestCase; + +import junit.framework.Test; + +/** + * This test case tests the transition of a AssociatedFilteringCriterionSet + * + */ +public class FunctionalTransitionTestCase extends TopDownTransitionTestCase { + public static final String SYSTEMFUNCTION_1 = "bc18b8d1-7b7c-4a92-8ee3-85ae431c1593"; //$NON-NLS-1$ + public static final String SF1_ASSOCIATED_FILTERING_CRITERION_SET = "e29b9987-09cb-4acb-8070-0a1abaaa7e3a"; //$NON-NLS-1$ + + @Override + public List getRequiredTestModels() { + return Arrays.asList("Transition"); + } + + @Override + public void performTest() throws Exception { + EObject sf1 = getObject(SYSTEMFUNCTION_1); + performFunctionalTransition(Arrays.asList(sf1)); + mustBeTransitioned(SF1_ASSOCIATED_FILTERING_CRITERION_SET); + } + + public static Test suite() { + return new FunctionalTransitionTestCase(); + } +} diff --git a/tests/org.polarsys.capella.filtering.tests.ju/src/org/polarsys/capella/filtering/tests/ju/tests/misc/transition/TransitionTestSuite.java b/tests/org.polarsys.capella.filtering.tests.ju/src/org/polarsys/capella/filtering/tests/ju/tests/misc/transition/TransitionTestSuite.java new file mode 100644 index 00000000..e7f16de5 --- /dev/null +++ b/tests/org.polarsys.capella.filtering.tests.ju/src/org/polarsys/capella/filtering/tests/ju/tests/misc/transition/TransitionTestSuite.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2019 THALES GLOBAL SERVICES. + * 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: + * Thales - initial API and implementation + *******************************************************************************/ +package org.polarsys.capella.filtering.tests.ju.tests.misc.transition; + +import java.util.ArrayList; +import java.util.List; + +import org.polarsys.capella.test.framework.api.BasicTestArtefact; +import org.polarsys.capella.test.framework.api.BasicTestSuite; + +import junit.framework.Test; + +public class TransitionTestSuite extends BasicTestSuite { + + public static Test suite() { + return new TransitionTestSuite(); + } + + @Override + protected List getTests() { + List testCases = new ArrayList<>(); + testCases.add(new FunctionalTransitionTestCase()); + + return testCases; + } + +} \ No newline at end of file