|
30 | 30 | import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload; |
31 | 31 | import org.eclipse.sirius.components.collaborative.diagrams.dto.EditLabelInput; |
32 | 32 | import org.eclipse.sirius.components.collaborative.diagrams.dto.EditLabelSuccessPayload; |
33 | | -import org.eclipse.sirius.components.collaborative.diagrams.dto.InvokeSingleClickOnDiagramElementToolInput; |
34 | | -import org.eclipse.sirius.components.collaborative.diagrams.dto.InvokeSingleClickOnDiagramElementToolSuccessPayload; |
35 | 33 | import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolVariable; |
36 | 34 | import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolVariableType; |
37 | 35 | import org.eclipse.sirius.components.core.api.IEditingContext; |
|
43 | 41 | import org.eclipse.sirius.components.diagrams.events.ReconnectEdgeKind; |
44 | 42 | import org.eclipse.sirius.components.diagrams.tests.assertions.DiagramAssertions; |
45 | 43 | import org.eclipse.sirius.components.diagrams.tests.graphql.EditLabelMutationRunner; |
46 | | -import org.eclipse.sirius.components.diagrams.tests.graphql.InvokeSingleClickOnDiagramElementToolMutationRunner; |
47 | 44 | import org.eclipse.sirius.components.diagrams.tests.graphql.PaletteQueryRunner; |
48 | 45 | import org.eclipse.sirius.components.diagrams.tests.navigation.DiagramNavigator; |
49 | 46 | import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionSuccessPayload; |
@@ -112,9 +109,6 @@ public class GVFlowUsageTests extends AbstractIntegrationTests { |
112 | 109 | @Autowired |
113 | 110 | private EditLabelMutationRunner editLabelMutationRunner; |
114 | 111 |
|
115 | | - @Autowired |
116 | | - private InvokeSingleClickOnDiagramElementToolMutationRunner invokeSingleClickOnDiagramElementToolMutationRunner; |
117 | | - |
118 | 112 | @Autowired |
119 | 113 | private PaletteQueryRunner paletteQueryRunner; |
120 | 114 |
|
@@ -437,14 +431,7 @@ public void createFlowUsageInConnection() { |
437 | 431 |
|
438 | 432 | Runnable createFlowUsageOnConnection = () -> { |
439 | 433 | var selectedObjectVariable = new ToolVariable("selectedObject", GeneralViewFlowUsageProjectData.SemanticIds.VIDEO_SIGNAL_ID, ToolVariableType.OBJECT_ID); |
440 | | - var input = new InvokeSingleClickOnDiagramElementToolInput(UUID.randomUUID(), GeneralViewFlowUsageProjectData.EDITING_CONTEXT_ID, diagramId.get(), List.of(connectionEdgeId.get()), |
441 | | - flowCreationToolId, 0, 0, |
442 | | - List.of(selectedObjectVariable)); |
443 | | - var result = this.invokeSingleClickOnDiagramElementToolMutationRunner.run(input); |
444 | | - String typename = JsonPath.read(result.data(), "$.data.invokeSingleClickOnDiagramElementTool.__typename"); |
445 | | - assertThat(typename).isEqualTo(InvokeSingleClickOnDiagramElementToolSuccessPayload.class.getSimpleName()); |
446 | | - List<String> messages = JsonPath.read(result.data(), "$.data.invokeSingleClickOnDiagramElementTool.messages[*].body"); |
447 | | - assertThat(messages).hasSize(0); |
| 434 | + this.toolTester.invokeTool(GeneralViewFlowUsageProjectData.EDITING_CONTEXT_ID, diagramId.get(), connectionEdgeId.get(), flowCreationToolId, List.of(selectedObjectVariable)); |
448 | 435 | }; |
449 | 436 |
|
450 | 437 | Consumer<Object> validateEffectOnLabel = assertRefreshedDiagramThat(diagram -> this.assertEdgeLabelText(connectionEdgeId.get(), diagram, "cable : HDMICable \u25b6 Flow")); |
@@ -489,6 +476,85 @@ public void createFlowUsageInConnection() { |
489 | 476 | .verify(Duration.ofSeconds(10)); |
490 | 477 | } |
491 | 478 |
|
| 479 | + @Test |
| 480 | + @DisplayName("GIVEN a connection WHEN we create a flow usage in it without selecting a payload THEN the flow is correctly setup without a payload feature") |
| 481 | + @GivenSysONServer({ GeneralViewFlowUsageProjectData.SCRIPT_PATH }) |
| 482 | + public void createFlowUsageInConnectionWithoutPayloadFeature() { |
| 483 | + var diagramEventInput = new DiagramEventInput(UUID.randomUUID(), |
| 484 | + GeneralViewFlowUsageProjectData.EDITING_CONTEXT_ID, |
| 485 | + GeneralViewFlowUsageProjectData.GraphicalIds.DIAGRAM_ID); |
| 486 | + |
| 487 | + var flux = this.givenDiagramSubscription.subscribe(diagramEventInput); |
| 488 | + |
| 489 | + var diagramId = new AtomicReference<String>(); |
| 490 | + var connectionEdgeId = new AtomicReference<String>(); |
| 491 | + var connectionEdgeLabelId = new AtomicReference<String>(); |
| 492 | + |
| 493 | + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewFlowUsageProjectData.EDITING_CONTEXT_ID, |
| 494 | + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); |
| 495 | + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); |
| 496 | + String flowCreationToolId = diagramDescriptionIdProvider.getNodeCreationToolIdOnEdge(this.descriptionNameGenerator.getEdgeName(SysmlPackage.eINSTANCE.getConnectionUsage()), "New Flow"); |
| 497 | + |
| 498 | + Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram -> { |
| 499 | + diagramId.set(diagram.getId()); |
| 500 | + var connectionEdge = new DiagramNavigator(diagram).edgeWithId(GeneralViewFlowUsageProjectData.GraphicalIds.CONNECTION_EDGE_ID).getEdge(); |
| 501 | + connectionEdgeId.set(connectionEdge.getId()); |
| 502 | + connectionEdgeLabelId.set(connectionEdge.getCenterLabel().id()); |
| 503 | + }); |
| 504 | + |
| 505 | + Runnable renameAndTypeTheConnection = () -> this.editLabel(diagramId.get(), connectionEdgeLabelId.get(), "cable : HDMICable"); |
| 506 | + |
| 507 | + Consumer<Object> validateLabelEditResult = assertRefreshedDiagramThat(diagram -> this.assertEdgeLabelText(connectionEdgeId.get(), diagram, "cable : HDMICable")); |
| 508 | + |
| 509 | + Runnable validateSemanticEffectOfLabelEdit = this.semanticRunnableFactory.createRunnable(GeneralViewFlowUsageProjectData.EDITING_CONTEXT_ID, |
| 510 | + (editingContext, executeEditingContextFunctionInput) -> { |
| 511 | + this.assertConnectionType(editingContext, GeneralViewFlowUsageProjectData.SemanticIds.CONNECT_ID, GeneralViewFlowUsageProjectData.SemanticIds.HDMI_CABLE_ID); |
| 512 | + return new ExecuteEditingContextFunctionSuccessPayload(executeEditingContextFunctionInput.id(), true); |
| 513 | + }); |
| 514 | + |
| 515 | + Runnable createFlowUsageOnConnection = () -> { |
| 516 | + var selectedObjectVariable = new ToolVariable("selectedObject", "", ToolVariableType.OBJECT_ID); |
| 517 | + this.toolTester.invokeTool(GeneralViewFlowUsageProjectData.EDITING_CONTEXT_ID, diagramId.get(), connectionEdgeId.get(), flowCreationToolId, List.of(selectedObjectVariable)); |
| 518 | + }; |
| 519 | + |
| 520 | + Consumer<Object> validateEffectOnLabel = assertRefreshedDiagramThat(diagram -> this.assertEdgeLabelText(connectionEdgeId.get(), diagram, "cable : HDMICable \u25b6 Flow")); |
| 521 | + |
| 522 | + Runnable validateSemanticEffectOfFlowCreation = this.semanticRunnableFactory.createRunnable(GeneralViewFlowUsageProjectData.EDITING_CONTEXT_ID, |
| 523 | + (editingContext, executeEditingContextFunctionInput) -> { |
| 524 | + var optionalConnection = this.objectSearchService.getObject(editingContext, GeneralViewFlowUsageProjectData.SemanticIds.CONNECT_ID); |
| 525 | + assertThat(optionalConnection).containsInstanceOf(ConnectionUsage.class); |
| 526 | + ConnectionUsage connection = (ConnectionUsage) optionalConnection.get(); |
| 527 | + // The flow usage has been created |
| 528 | + var optionalFlowUsage = connection.getOwnedFeature().stream().filter(FlowUsage.class::isInstance).map(FlowUsage.class::cast).findFirst(); |
| 529 | + assertThat(optionalFlowUsage).isPresent(); |
| 530 | + var flowUsage = optionalFlowUsage.get(); |
| 531 | + |
| 532 | + // The flow does not have a payload feature |
| 533 | + var optionalPayloadFeature = flowUsage.getOwnedFeature().stream().filter(PayloadFeature.class::isInstance).map(PayloadFeature.class::cast).findFirst(); |
| 534 | + assertThat(optionalPayloadFeature).isEmpty(); |
| 535 | + |
| 536 | + // The flow has two FlowEnds: one redefining HDMICable::inputSide, the other HDMICable::outputSide |
| 537 | + var flowEnds = flowUsage.getOwnedFeature().stream().filter(FlowEnd.class::isInstance).map(FlowEnd.class::cast).toList(); |
| 538 | + assertThat(flowEnds).hasSize(2); |
| 539 | + var sourceEnd = flowEnds.get(0); |
| 540 | + assertThat(sourceEnd.getOwnedFeature().get(0).getOwnedRedefinition().get(0).getRedefinedFeature().getQualifiedName()).isEqualTo("Package1::HDMICable::inputSide"); |
| 541 | + var targetEnd = flowEnds.get(1); |
| 542 | + assertThat(targetEnd.getOwnedFeature().get(0).getOwnedRedefinition().get(0).getRedefinedFeature().getQualifiedName()).isEqualTo("Package1::HDMICable::outputSide"); |
| 543 | + return new ExecuteEditingContextFunctionSuccessPayload(executeEditingContextFunctionInput.id(), true); |
| 544 | + }); |
| 545 | + |
| 546 | + StepVerifier.create(flux) |
| 547 | + .consumeNextWith(initialDiagramContentConsumer) |
| 548 | + .then(renameAndTypeTheConnection) |
| 549 | + .consumeNextWith(validateLabelEditResult) |
| 550 | + .then(validateSemanticEffectOfLabelEdit) |
| 551 | + .then(createFlowUsageOnConnection) |
| 552 | + .consumeNextWith(validateEffectOnLabel) |
| 553 | + .then(validateSemanticEffectOfFlowCreation) |
| 554 | + .thenCancel() |
| 555 | + .verify(Duration.ofSeconds(10)); |
| 556 | + } |
| 557 | + |
492 | 558 | @Test |
493 | 559 | @DisplayName("GIVEN an untype connection WHEN we opening its palette THEN the flow tool is not proposed") |
494 | 560 | @GivenSysONServer({ GeneralViewFlowUsageProjectData.SCRIPT_PATH }) |
|
0 commit comments