From 167befd38cad4969481fe5f3df5e7125b465a96c Mon Sep 17 00:00:00 2001 From: Arnaud Dieumegard Date: Mon, 13 Jun 2022 11:13:14 +0200 Subject: [PATCH] #88 Update test cases to check images path update Check that image paths in descriptions are updated Change-Id: I0000000000000000000000000000000000000000 Signed-off-by: Arnaud Dieumegard --- .../Project_test_01/Project_test_01.capella | 221 ++++++++++++++++++ .../tests/mixed/AllMixedTests.java | 6 +- .../mixed/CopyImagesAndUpdatePathsTest.java | 134 +++++++++++ .../tests/mixed/CopyImagesTest.java | 109 --------- .../META-INF/MANIFEST.MF | 3 +- 5 files changed, 360 insertions(+), 113 deletions(-) create mode 100644 plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/CopyImagesAndUpdatePathsTest.java delete mode 100644 plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/CopyImagesTest.java diff --git a/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/model/Project_test_01/Project_test_01.capella b/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/model/Project_test_01/Project_test_01.capella index 7ba151af..626efa5e 100644 --- a/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/model/Project_test_01/Project_test_01.capella +++ b/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/model/Project_test_01/Project_test_01.capella @@ -26036,4 +26036,225 @@ sourceElement="#d0da2368-967b-4048-98b0-fea5a8720abe"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/AllMixedTests.java b/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/AllMixedTests.java index bc0a52db..ce6423c9 100644 --- a/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/AllMixedTests.java +++ b/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/AllMixedTests.java @@ -101,9 +101,9 @@ protected List getTests() { tests.addAll(testsFor(ComponentToSystemName.Test2.class)); tests.addAll(testsFor(ComponentToSystemName.Test3.class)); - tests.addAll(testsFor(CopyImagesTest.CopyImagesInInterphasesTest.class)); - tests.addAll(testsFor(CopyImagesTest.CopyImagesInCrossphasesTest.class)); - tests.addAll(testsFor(CopyImagesTest.CopyImagesInMultiphasesTest.class)); + tests.addAll(testsFor(CopyImagesAndUpdatePathsTest.CopyImagesAndUpdatePathsInterphasesTest.class)); + tests.addAll(testsFor(CopyImagesAndUpdatePathsTest.CopyImagesAndUpdatePathsCrossphasesTest.class)); + tests.add(new CopyImagesAndUpdatePathsTest.CopyImagesAndUpdatePathsMultiphasesTest()); return tests; } diff --git a/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/CopyImagesAndUpdatePathsTest.java b/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/CopyImagesAndUpdatePathsTest.java new file mode 100644 index 00000000..833a1b9e --- /dev/null +++ b/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/CopyImagesAndUpdatePathsTest.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * Copyright (c) 2022 THALES GLOBAL SERVICES. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Thales - initial API and implementation + *******************************************************************************/ +package org.polarsys.capella.transition.system2subsystem.tests.mixed; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Collection; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.emf.ecore.EObject; +import org.polarsys.capella.core.data.capellacore.CapellaElement; +import org.polarsys.capella.core.model.helpers.BlockArchitectureExt; +import org.polarsys.capella.transition.system2subsystem.tests.System2SubsystemTest; +import org.polarsys.capella.transition.system2subsystem.tests.System2SubsystemTest.Crossphase; +import org.polarsys.capella.transition.system2subsystem.tests.System2SubsystemTest.Interphase; +import org.polarsys.capella.transition.system2subsystem.tests.TraceabilityArchitectureSID; +import org.polarsys.capella.transition.system2subsystem.tests.multiphases.MultiPhasesTest; + +/** + * Test that verifies the copy of images for all kind of transitions + */ +public class CopyImagesAndUpdatePathsTest { + + //TODO: modify the IDS to take elements from the actual correct SystemEngineering containing images + + private static final String ID_PC1 = "92e20a23-fb3f-45d8-aa2f-8aaecdafa7b4"; //$NON-NLS-1$ + + private static final String ID_LC1 = "8da8b3c5-9ed3-4bf7-93da-f53cc4ba95ab"; + + private static final String COPIED_IMAGE_PATH = "images/Capella128x128.png"; + + private static final String COPIED_LIB_IMAGE_PATH = "output_lib/images/Capella64x64.png"; + + // Hide default constructor + CopyImagesAndUpdatePathsTest() {} + + /** + * Test that verifies the copy of images during a Multiphases transition + */ + public static class CopyImagesAndUpdatePathsMultiphasesTest extends MultiPhasesTest { + + public CopyImagesAndUpdatePathsMultiphasesTest() { + super(); + } + + @Override + protected Collection getProjectionElements() { + return getObjects(ID_PC1); + } + + @Override + protected void verify() throws Exception { + ((TraceabilityArchitectureSID) traceability).setArchitecture(BlockArchitectureExt.Type.SA); + testImageCopy(getRequiredTestModels().get(0), getRequiredTestModels().get(1), mustBeTransitioned(ID_PC1, ComponentType.SYSTEM)); + ((TraceabilityArchitectureSID) traceability).setArchitecture(BlockArchitectureExt.Type.LA); + testImageCopy(getRequiredTestModels().get(0), getRequiredTestModels().get(1), mustBeTransitioned(ID_PC1, ComponentType.LOGICAL_COMPONENT)); + ((TraceabilityArchitectureSID) traceability).setArchitecture(BlockArchitectureExt.Type.PA); + testImageCopy(getRequiredTestModels().get(0), getRequiredTestModels().get(1), mustBeTransitioned(ID_PC1)); + } + } + + /** + * Test that verifies the copy of images during an Interphases transition + */ + public static class CopyImagesAndUpdatePathsInterphasesTest extends System2SubsystemTest implements Interphase { + + public CopyImagesAndUpdatePathsInterphasesTest() { + super(); + } + + @Override + protected Collection getProjectionElements() { + return getObjects(ID_PC1); + } + + @Override + protected void verify() { + testImageCopy(getRequiredTestModels().get(0), getRequiredTestModels().get(1), mustBeTransitioned(ID_PC1)); + } + + } + + /** + * Test that verifies the copy of images during a Crossphases transition + */ + public static class CopyImagesAndUpdatePathsCrossphasesTest extends System2SubsystemTest implements Crossphase { + + public CopyImagesAndUpdatePathsCrossphasesTest() { + super(); + } + + @Override + protected Collection getProjectionElements() { + return getObjects(ID_LC1); + } + + @Override + protected void verify() throws Exception { + testImageCopy(getRequiredTestModels().get(0), getRequiredTestModels().get(1), mustBeTransitioned(ID_LC1)); + } + + } + + public static void testImageCopy(String sourceProjectName, String targetProjectName, EObject targetObject) { + IFile copiedImage = ResourcesPlugin.getWorkspace().getRoot().getProject(targetProjectName).getFile(COPIED_IMAGE_PATH); + assertTrue("An image file should have been copied", copiedImage.exists()); + + assertTrue("Target Object is a Capella element", targetObject instanceof CapellaElement); + + boolean containsExpectedModifiedPath = ((CapellaElement)targetObject).getDescription().contains(targetProjectName + "/" + COPIED_IMAGE_PATH); + boolean containsOriginalPath = ((CapellaElement)targetObject).getDescription().contains(sourceProjectName + "/" + COPIED_IMAGE_PATH); + + boolean containsOriginalLibPath = ((CapellaElement)targetObject).getDescription().contains(COPIED_LIB_IMAGE_PATH); + + assertTrue("Target Object shall contain the modified image path", containsExpectedModifiedPath); + assertFalse("Target Object shall not contain the original image path", containsOriginalPath); + assertTrue("Target Object shall still contain the original lib image path", containsOriginalLibPath); + + } + +} + diff --git a/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/CopyImagesTest.java b/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/CopyImagesTest.java deleted file mode 100644 index 63d27fda..00000000 --- a/plugins/org.polarsys.capella.transition.system2subsystem.tests.ju/src/org/polarsys/capella/transition/system2subsystem/tests/mixed/CopyImagesTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 THALES GLOBAL SERVICES. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Thales - initial API and implementation - *******************************************************************************/ -package org.polarsys.capella.transition.system2subsystem.tests.mixed; - -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.polarsys.capella.transition.system2subsystem.tests.System2SubsystemTest; -import org.polarsys.capella.transition.system2subsystem.tests.System2SubsystemTest.Crossphase; -import org.polarsys.capella.transition.system2subsystem.tests.System2SubsystemTest.Interphase; -import org.polarsys.capella.transition.system2subsystem.tests.multiphases.MultiPhasesTest; - -/** - * Test that verifies the copy of images for all kind of transitions - */ -public class CopyImagesTest { - - private static final String MP_ORDERED_PA_PC_4 = "b271ea03-5360-43a3-823f-1f4aa88f83ba"; //$NON-NLS-1$ - - private static String _id_pc1 = "4d32c631-16c0-40cf-afb6-4493c895ab56"; //$NON-NLS-1$ - - private static final String LC_1 = "aa75d1f7-8bd9-49ff-8e61-a3462115e04e"; - - private static final String COPIED_IMAGE_PATH = "images/Capella128x128.png"; - - // Hide default constructor - CopyImagesTest() {} - - /** - * Test that verifies the copy of images during a Multiphases transition - */ - public static class CopyImagesInMultiphasesTest extends MultiPhasesTest { - - public CopyImagesInMultiphasesTest() { - super(); - } - - @Override - protected Collection getProjectionElements() { - return getObjects(MP_ORDERED_PA_PC_4); - } - - @Override - protected void verify() throws Exception { - testImageCopy(getRequiredTestModels().get(1)); - } - } - - /** - * Test that verifies the copy of images during an Interphases transition - */ - public static class CopyImagesInInterphasesTest extends System2SubsystemTest implements Interphase { - - public CopyImagesInInterphasesTest() { - super(); - } - - @Override - protected Collection getProjectionElements() { - return getObjects(_id_pc1); - } - - @Override - protected void verify() { - testImageCopy(getRequiredTestModels().get(1)); - } - - } - - /** - * Test that verifies the copy of images during a Crossphases transition - */ - public static class CopyImagesInCrossphasesTest extends System2SubsystemTest implements Crossphase { - - public CopyImagesInCrossphasesTest() { - super(); - } - - @Override - protected Collection getProjectionElements() { - return getObjects(LC_1); - } - - @Override - protected void verify() throws Exception { - testImageCopy(getRequiredTestModels().get(1)); - } - - } - - public static void testImageCopy(String outputProjectName) { - IFile copiedImage = ResourcesPlugin.getWorkspace().getRoot().getProject(outputProjectName).getFile(COPIED_IMAGE_PATH); - assertTrue("An image file should have been copied", copiedImage.exists()); - } - -} diff --git a/plugins/org.polarsys.capella.transition.system2subsystem/META-INF/MANIFEST.MF b/plugins/org.polarsys.capella.transition.system2subsystem/META-INF/MANIFEST.MF index f5dfac57..70d30c3b 100644 --- a/plugins/org.polarsys.capella.transition.system2subsystem/META-INF/MANIFEST.MF +++ b/plugins/org.polarsys.capella.transition.system2subsystem/META-INF/MANIFEST.MF @@ -32,7 +32,8 @@ Require-Bundle: org.eclipse.core.runtime, org.polarsys.capella.common.libraries, org.polarsys.capella.common.transition, org.polarsys.kitalpha.ad.metadata, - org.polarsys.capella.core.sirius.ui + org.polarsys.capella.core.sirius.ui, + org.polarsys.capella.core.compare Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 1.6.0.qualifier