|
55 | 55 | import org.eclipse.syson.application.controllers.diagrams.checkers.CheckDiagramElementCount; |
56 | 56 | import org.eclipse.syson.application.controllers.diagrams.testers.EdgeCreationTester; |
57 | 57 | import org.eclipse.syson.application.controllers.diagrams.testers.EdgeReconnectionTester; |
| 58 | +import org.eclipse.syson.application.controllers.diagrams.testers.ToolTester; |
58 | 59 | import org.eclipse.syson.application.data.GeneralViewFlowConnectionItemUsagesProjectData; |
59 | 60 | import org.eclipse.syson.application.data.GeneralViewFlowUsageProjectData; |
60 | 61 | import org.eclipse.syson.services.SemanticRunnableFactory; |
|
69 | 70 | import org.eclipse.syson.sysml.FlowUsage; |
70 | 71 | import org.eclipse.syson.sysml.PayloadFeature; |
71 | 72 | import org.eclipse.syson.sysml.SysmlPackage; |
| 73 | +import org.eclipse.syson.sysml.helper.LabelConstants; |
72 | 74 | import org.eclipse.syson.util.IDescriptionNameGenerator; |
73 | 75 | import org.eclipse.syson.util.SysONRepresentationDescriptionIdentifiers; |
74 | 76 | import org.junit.jupiter.api.BeforeEach; |
@@ -131,6 +133,9 @@ public class GVFlowUsageTests extends AbstractIntegrationTests { |
131 | 133 | @Autowired |
132 | 134 | private IIdentityService identityService; |
133 | 135 |
|
| 136 | + @Autowired |
| 137 | + private ToolTester toolTester; |
| 138 | + |
134 | 139 | private SemanticCheckerService semanticCheckerService; |
135 | 140 |
|
136 | 141 | private Flux<DiagramRefreshedEventPayload> givenSubscriptionToDiagram() { |
@@ -195,6 +200,73 @@ public void checkFlowConnectionCreation() { |
195 | 200 | .verify(Duration.ofSeconds(10)); |
196 | 201 | } |
197 | 202 |
|
| 203 | + @DisplayName("GIVEN a SysML Project with ActionUsages with parameters (ReferenceUsages), WHEN creating a FlowUsage between parameters, THEN an edge should be displayed to represent that new flow") |
| 204 | + @GivenSysONServer({ GeneralViewFlowConnectionItemUsagesProjectData.SCRIPT_PATH }) |
| 205 | + @Test |
| 206 | + public void checkFlowConnectionBetweenParametersCreation() { |
| 207 | + var flux = this.givenSubscriptionToDiagram(); |
| 208 | + |
| 209 | + AtomicReference<Diagram> diagram = new AtomicReference<>(); |
| 210 | + Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); |
| 211 | + |
| 212 | + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewFlowConnectionItemUsagesProjectData.EDITING_CONTEXT_ID, |
| 213 | + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); |
| 214 | + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); |
| 215 | + |
| 216 | + var parameterCreationToolId = diagramDescriptionIdProvider.getNodeToolId(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getActionUsage()), "New Parameter In"); |
| 217 | + var flowCreationToolId = diagramDescriptionIdProvider.getEdgeCreationToolId(this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getReferenceUsage()), "New Flow (flow)"); |
| 218 | + |
| 219 | + Runnable parameterOnAction1CreationTool = () -> this.toolTester.invokeTool(GeneralViewFlowConnectionItemUsagesProjectData.EDITING_CONTEXT_ID, |
| 220 | + GeneralViewFlowConnectionItemUsagesProjectData.GraphicalIds.DIAGRAM_ID, |
| 221 | + GeneralViewFlowConnectionItemUsagesProjectData.GraphicalIds.ACTION_USAGE_1_ID, parameterCreationToolId, List.of()); |
| 222 | + |
| 223 | + var parameterOnAction1BorderNodeId = new AtomicReference<String>(); |
| 224 | + Consumer<Object> diagramContentConsumerAfterNewParameterOnAction1 = assertRefreshedDiagramThat(newDiagram -> { |
| 225 | + var parameterOnAction1BorderNode = new DiagramNavigator(newDiagram).nodeWithLabel(LabelConstants.OPEN_QUOTE + "action" + LabelConstants.CLOSE_QUOTE + LabelConstants.CR + "action1") |
| 226 | + .getNode().getBorderNodes().stream().filter(bn -> bn.getOutsideLabels().get(0).text().equals("parameter1")).findFirst().orElseThrow(); |
| 227 | + parameterOnAction1BorderNodeId.set(parameterOnAction1BorderNode.getId()); |
| 228 | + }); |
| 229 | + |
| 230 | + Runnable parameterOnAction2CreationTool = () -> this.toolTester.invokeTool(GeneralViewFlowConnectionItemUsagesProjectData.EDITING_CONTEXT_ID, |
| 231 | + GeneralViewFlowConnectionItemUsagesProjectData.GraphicalIds.DIAGRAM_ID, |
| 232 | + GeneralViewFlowConnectionItemUsagesProjectData.GraphicalIds.ACTION_USAGE_2_ID, parameterCreationToolId, List.of()); |
| 233 | + |
| 234 | + var parameterOnAction2BorderNodeId = new AtomicReference<String>(); |
| 235 | + Consumer<Object> diagramContentConsumerAfterNewParameterOnAction2 = assertRefreshedDiagramThat(newDiagram -> { |
| 236 | + var parameterOnAction2BorderNode = new DiagramNavigator(newDiagram).nodeWithLabel(LabelConstants.OPEN_QUOTE + "action" + LabelConstants.CLOSE_QUOTE + LabelConstants.CR + "action2") |
| 237 | + .getNode().getBorderNodes().stream().filter(bn -> bn.getOutsideLabels().get(0).text().equals("parameter1")).findFirst().orElseThrow(); |
| 238 | + parameterOnAction2BorderNodeId.set(parameterOnAction2BorderNode.getId()); |
| 239 | + }); |
| 240 | + |
| 241 | + Runnable flowCreationTool = () -> this.edgeCreationTester.createEdgeUsingNodeId(GeneralViewFlowConnectionItemUsagesProjectData.EDITING_CONTEXT_ID, |
| 242 | + diagram, |
| 243 | + parameterOnAction1BorderNodeId.get(), |
| 244 | + parameterOnAction2BorderNodeId.get(), |
| 245 | + flowCreationToolId); |
| 246 | + |
| 247 | + AtomicReference<String> newFlow = new AtomicReference<>(); |
| 248 | + Consumer<Object> diagramCheck = assertRefreshedDiagramThat(newDiagram -> { |
| 249 | + var initialDiagram = diagram.get(); |
| 250 | + assertThat(this.diagramComparator.newEdges(initialDiagram, newDiagram)).hasSize(1); |
| 251 | + Edge newEdge = this.diagramComparator.newEdges(initialDiagram, newDiagram).get(0); |
| 252 | + newFlow.set(newEdge.getTargetObjectId()); |
| 253 | + assertThat(newEdge).hasSourceId(parameterOnAction1BorderNodeId.get()); |
| 254 | + assertThat(newEdge).hasTargetId(parameterOnAction2BorderNodeId.get()); |
| 255 | + assertThat(newEdge.getStyle()).hasTargetArrow(ArrowStyle.InputFillClosedArrow); |
| 256 | + }); |
| 257 | + |
| 258 | + StepVerifier.create(flux) |
| 259 | + .consumeNextWith(initialDiagramContentConsumer) |
| 260 | + .then(parameterOnAction1CreationTool) |
| 261 | + .consumeNextWith(diagramContentConsumerAfterNewParameterOnAction1) |
| 262 | + .then(parameterOnAction2CreationTool) |
| 263 | + .consumeNextWith(diagramContentConsumerAfterNewParameterOnAction2) |
| 264 | + .then(flowCreationTool) |
| 265 | + .consumeNextWith(diagramCheck) |
| 266 | + .thenCancel() |
| 267 | + .verify(Duration.ofSeconds(10)); |
| 268 | + } |
| 269 | + |
198 | 270 | @DisplayName("GIVEN a SysML Project with ItemUsages on ActionUsage, WHEN creating a BindingConnectorAsUsage between them, THEN an edge should be displayed to represent that new binding") |
199 | 271 | @GivenSysONServer({ GeneralViewFlowConnectionItemUsagesProjectData.SCRIPT_PATH }) |
200 | 272 | @Test |
|
0 commit comments