|
13 | 13 | package org.eclipse.syson.application.controllers.diagrams.general.view; |
14 | 14 |
|
15 | 15 | import static org.assertj.core.api.Assertions.assertThat; |
| 16 | +import static org.eclipse.sirius.components.diagrams.tests.DiagramEventPayloadConsumer.assertRefreshedDiagramThat; |
16 | 17 | import static org.junit.jupiter.api.Assertions.assertEquals; |
17 | 18 |
|
18 | 19 | import java.time.Duration; |
|
36 | 37 | import org.eclipse.sirius.components.diagrams.Diagram; |
37 | 38 | import org.eclipse.sirius.components.diagrams.Node; |
38 | 39 | import org.eclipse.sirius.components.diagrams.tests.graphql.LayoutDiagramMutationRunner; |
| 40 | +import org.eclipse.sirius.components.diagrams.tests.navigation.DiagramNavigator; |
39 | 41 | import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionInput; |
40 | 42 | import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionRunner; |
41 | 43 | import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionSuccessPayload; |
@@ -213,7 +215,7 @@ public void addExistingElementsToolShouldUpdateExposedElements() { |
213 | 215 | this.verifier.then(semanticChecker); |
214 | 216 | } |
215 | 217 |
|
216 | | - @DisplayName("GIVEN a GV diagram on a ViewUsage, WHEN Add existing element(s) (recursive) tool is executed, THEN a the ViewUsage#exposedElements is updated with partA and partB") |
| 218 | + @DisplayName("GIVEN a GV diagram on a ViewUsage, WHEN Add existing element(s) (recursive) tool is executed, THEN the ViewUsage#exposedElements is updated with partA and partB") |
217 | 219 | @Sql(scripts = { ViewUsageExposedElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
218 | 220 | config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
219 | 221 | @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
@@ -303,4 +305,47 @@ public void updateExposedElementsShouldUpdateTheDiagram() { |
303 | 305 |
|
304 | 306 | this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); |
305 | 307 | } |
| 308 | + |
| 309 | + @DisplayName("GIVEN a GV diagram on a ViewUsage, WHEN an element is created inside a Package, THEN the element should only be visible inside the Package") |
| 310 | + @Sql(scripts = { ViewUsageExposedElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, |
| 311 | + config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 312 | + @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) |
| 313 | + @Test |
| 314 | + public void exposePackageChildShouldDisplayChildOnlyinPAckage() { |
| 315 | + var newPackageToolId = this.diagramDescriptionIdProvider.getDiagramCreationToolId("New Package"); |
| 316 | + assertThat(newPackageToolId).as("The tool 'New Package' should exist on the diagram").isNotNull(); |
| 317 | + var newInterfaceToolId = this.diagramDescriptionIdProvider.getNodeCreationToolId(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getPackage()), "New Interface"); |
| 318 | + assertThat(newInterfaceToolId).as("The tool 'New Interface' should exist on the Package").isNotNull(); |
| 319 | + |
| 320 | + Runnable newPackageTool = () -> this.toolTester.invokeTool(ViewUsageExposedElementsTestProjectData.EDITING_CONTEXT_ID, this.diagram, newPackageToolId); |
| 321 | + |
| 322 | + var packageNodeId = new AtomicReference<String>(); |
| 323 | + |
| 324 | + Consumer<Object> updatedDiagramWithPackage = assertRefreshedDiagramThat(diag -> { |
| 325 | + int diagramRootNodesCount = diag.getNodes().size(); |
| 326 | + assertThat(diagramRootNodesCount).isEqualTo(1); |
| 327 | + var packageNode = new DiagramNavigator(diag).nodeWithLabel("Package1").getNode(); |
| 328 | + assertThat(packageNode).isNotNull(); |
| 329 | + assertThat(packageNode.getChildNodes()).hasSize(0); |
| 330 | + packageNodeId.set(packageNode.getId()); |
| 331 | + }); |
| 332 | + |
| 333 | + Runnable newInterfaceTool = () -> this.toolTester.invokeTool(ViewUsageExposedElementsTestProjectData.EDITING_CONTEXT_ID, this.diagram.get().getId(), packageNodeId.get(), newInterfaceToolId, |
| 334 | + List.of()); |
| 335 | + |
| 336 | + Consumer<Object> updatedDiagramWithInterface = assertRefreshedDiagramThat(diag -> { |
| 337 | + int diagramRootNodesCount = diag.getNodes().size(); |
| 338 | + assertThat(diagramRootNodesCount).isEqualTo(1); |
| 339 | + var packageNode = new DiagramNavigator(diag).nodeWithLabel("Package1").getNode(); |
| 340 | + assertThat(packageNode.getChildNodes()).hasSize(1); |
| 341 | + var interfaceNode = new DiagramNavigator(diag).nodeWithLabel("Package1").childNodeWithLabel("\u00ABinterface\u00BB\ninterface1").getNode(); |
| 342 | + assertThat(interfaceNode).isNotNull(); |
| 343 | + }); |
| 344 | + |
| 345 | + this.verifier |
| 346 | + .then(newPackageTool) |
| 347 | + .consumeNextWith(updatedDiagramWithPackage) |
| 348 | + .then(newInterfaceTool) |
| 349 | + .consumeNextWith(updatedDiagramWithInterface); |
| 350 | + } |
306 | 351 | } |
0 commit comments