From 2b67b8acded0b32ad43090b0f4bb03d3736a045e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Bausson?= Date: Tue, 14 Nov 2023 17:25:57 +0100 Subject: [PATCH] #2062 Adding test cases. --- .../constants/IToolNameConstants.java | 2 + .../AncestorDragAndDrop.afm | 4 + .../AncestorDragAndDrop.aird | 1108 +++++++++++++++++ .../AncestorDragAndDrop.capella | 470 +++++++ .../ju/xab/AncestorsDragAndDropProject.java | 23 + .../diagram/tools/ju/xab/DnDAllocations.java | 38 + 6 files changed, 1645 insertions(+) create mode 100644 tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.afm create mode 100644 tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.aird create mode 100644 tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.capella create mode 100644 tests/plugins/org.polarsys.capella.test.diagram.tools.ju/src/org/polarsys/capella/test/diagram/tools/ju/xab/AncestorsDragAndDropProject.java create mode 100644 tests/plugins/org.polarsys.capella.test.diagram.tools.ju/src/org/polarsys/capella/test/diagram/tools/ju/xab/DnDAllocations.java diff --git a/core/plugins/org.polarsys.capella.core.sirius.analysis/src/org/polarsys/capella/core/sirius/analysis/constants/IToolNameConstants.java b/core/plugins/org.polarsys.capella.core.sirius.analysis/src/org/polarsys/capella/core/sirius/analysis/constants/IToolNameConstants.java index a25f927f01..7c78a77872 100644 --- a/core/plugins/org.polarsys.capella.core.sirius.analysis/src/org/polarsys/capella/core/sirius/analysis/constants/IToolNameConstants.java +++ b/core/plugins/org.polarsys.capella.core.sirius.analysis/src/org/polarsys/capella/core/sirius/analysis/constants/IToolNameConstants.java @@ -55,6 +55,8 @@ public interface IToolNameConstants { String TOOL_INSERT_REMOVE_PV = "applied.property.values"; String TOOL_INSERT_REMOVE_PVG = "applied.property.value.groups"; + String TOOL_AB_DND_COMPONENT_PORT = "DnD AB ComponentPort"; + // Accelerators String TOOL_INITIALIZATION_FROM_EXISTING_DIAGRAM = "initialization.from.existing.diagram"; diff --git a/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.afm b/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.afm new file mode 100644 index 0000000000..8c558d2234 --- /dev/null +++ b/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.afm @@ -0,0 +1,4 @@ + + + + diff --git a/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.aird b/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.aird new file mode 100644 index 0000000000..d9a1a7f76a --- /dev/null +++ b/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.aird @@ -0,0 +1,1108 @@ + + + + AncestorDragAndDrop.afm + AncestorDragAndDrop.capella + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.capella b/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.capella new file mode 100644 index 0000000000..f18a6a6432 --- /dev/null +++ b/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/model/DnDEncapsulationTestModel/AncestorDragAndDrop.capella @@ -0,0 +1,470 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/src/org/polarsys/capella/test/diagram/tools/ju/xab/AncestorsDragAndDropProject.java b/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/src/org/polarsys/capella/test/diagram/tools/ju/xab/AncestorsDragAndDropProject.java new file mode 100644 index 0000000000..5f0e54b42f --- /dev/null +++ b/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/src/org/polarsys/capella/test/diagram/tools/ju/xab/AncestorsDragAndDropProject.java @@ -0,0 +1,23 @@ +package org.polarsys.capella.test.diagram.tools.ju.xab; + +import org.polarsys.capella.test.diagram.common.ju.api.AbstractDiagramTestCase; + +public abstract class AncestorsDragAndDropProject extends AbstractDiagramTestCase { + protected static final String LA__LAB_DIAGRAM = "[LAB] Structure"; + + + protected static final String LA__LAB_LC1 = "9580f98e-ba7f-4477-a2ce-8891fe596e18"; + protected static final String LA__LAB_LC111 = "d3049527-11c9-4aaf-a432-47f1e54dd06a"; + protected static final String LA__LAB_LA122 = "7e82055c-d2c6-4e09-aece-dee592a71bb0"; + + protected static final String LA__LAB_CP1 = "93cbda6d-4222-4c25-a3d8-72751a6178dd"; + + protected static final String LA__LAB_CP3 = "cc2c3cd7-855d-467a-bfc0-195eb8015877"; + protected static final String LA__LAB_CP5 = "f9894366-79ca-4a10-a237-c3b01efde13e"; + + @Override + protected String getRequiredTestModel() { + return "DnDEncapsulationTestModel"; + } + +} diff --git a/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/src/org/polarsys/capella/test/diagram/tools/ju/xab/DnDAllocations.java b/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/src/org/polarsys/capella/test/diagram/tools/ju/xab/DnDAllocations.java new file mode 100644 index 0000000000..3f3dab5508 --- /dev/null +++ b/tests/plugins/org.polarsys.capella.test.diagram.tools.ju/src/org/polarsys/capella/test/diagram/tools/ju/xab/DnDAllocations.java @@ -0,0 +1,38 @@ +package org.polarsys.capella.test.diagram.tools.ju.xab; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.sirius.business.api.session.Session; +import org.polarsys.capella.core.data.fa.ComponentPort; +import org.polarsys.capella.core.sirius.analysis.constants.IToolNameConstants; +import org.polarsys.capella.test.diagram.common.ju.context.DiagramContext; +import org.polarsys.capella.test.diagram.common.ju.step.crud.OpenDiagramStep; +import org.polarsys.capella.test.diagram.common.ju.step.tools.DragAndDropTool; +import org.polarsys.capella.test.framework.context.SessionContext; + +public class DnDAllocations extends AncestorsDragAndDropProject { + private static final String testFailMessage = "DragAndDrop was supposed to conserve ports in specific cases, but the expected number was not matched."; + + @Override + public void test() throws Exception { + Session session = getSession(getRequiredTestModel()); + SessionContext context = new SessionContext(session); + + testPortDND(context, LA__LAB_DIAGRAM, LA__LAB_CP1, LA__LAB_LC111, 1, "port DnD from parent to child"); + testPortDND(context, LA__LAB_DIAGRAM, LA__LAB_CP1, LA__LAB_LC1, 1, "port DnD from child to parent"); + testPortDND(context, LA__LAB_DIAGRAM, LA__LAB_CP3, LA__LAB_LC1, 1, "port DnD from child to grandparent"); + testPortDND(context, LA__LAB_DIAGRAM, LA__LAB_CP5, LA__LAB_LC1, 2, "port DnD with 2 delegations to parent"); + testPortDND(context, LA__LAB_DIAGRAM, LA__LAB_CP5, LA__LAB_LA122, 1, "port DnD with 2, invalidating one"); + } + + private void testPortDND(SessionContext context, String diagramName, String portID, String containerID, int expectedAllocation, String description) { + EObject portIdEObject = context.getSemanticElement(portID); + assertTrue("movingPort should be a ComponentPort in test: " + description, portIdEObject instanceof ComponentPort); + + ComponentPort movingPort = (ComponentPort) portIdEObject; + DiagramContext dndDiagram = new OpenDiagramStep(context, diagramName).run(); + new DragAndDropTool(dndDiagram, IToolNameConstants.TOOL_AB_DND_COMPONENT_PORT, portID, containerID).run(); + + assertEquals(testFailMessage + "in test: " + description, expectedAllocation, movingPort.getAllocatedFunctionPorts().size()); + } + +}