|
44 | 44 | import org.eclipse.sirius.components.diagrams.tests.graphql.PaletteQueryRunner; |
45 | 45 | import org.eclipse.sirius.components.diagrams.tests.navigation.DiagramNavigator; |
46 | 46 | import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionSuccessPayload; |
| 47 | +import org.eclipse.sirius.components.view.diagram.EdgeTool; |
| 48 | +import org.eclipse.sirius.components.view.diagram.NodeDescription; |
47 | 49 | import org.eclipse.sirius.components.view.emf.diagram.IDiagramIdProvider; |
48 | 50 | import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; |
49 | 51 | import org.eclipse.syson.AbstractIntegrationTests; |
|
67 | 69 | import org.eclipse.syson.sysml.FlowUsage; |
68 | 70 | import org.eclipse.syson.sysml.PayloadFeature; |
69 | 71 | import org.eclipse.syson.sysml.SysmlPackage; |
| 72 | +import org.eclipse.syson.sysml.helper.EMFUtils; |
70 | 73 | import org.eclipse.syson.sysml.helper.LabelConstants; |
71 | 74 | import org.eclipse.syson.util.IDescriptionNameGenerator; |
72 | 75 | import org.eclipse.syson.util.SysONRepresentationDescriptionIdentifiers; |
@@ -144,6 +147,48 @@ public void setUp() { |
144 | 147 | GeneralViewFlowConnectionItemUsagesProjectData.SemanticIds.PACKAGE_1_ID); |
145 | 148 | } |
146 | 149 |
|
| 150 | + @DisplayName("GIVEN a General View diagram description, WHEN inspecting the New Flow tool on ItemUsage border nodes, THEN it uses the full renderer-compatible border-node targets") |
| 151 | + @GivenSysONServer({ GeneralViewFlowConnectionItemUsagesProjectData.SCRIPT_PATH }) |
| 152 | + @Test |
| 153 | + public void givenGeneralViewDiagramDescriptionWhenInspectingItemFlowToolTargetsThenTheyMatchTheRendererContract() { |
| 154 | + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewFlowConnectionItemUsagesProjectData.EDITING_CONTEXT_ID, |
| 155 | + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); |
| 156 | + |
| 157 | + var itemUsageBorderNodeDescription = this.findNodeDescription(diagramDescription, |
| 158 | + this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getItemUsage(), SysmlPackage.eINSTANCE.getBehavior_Parameter())); |
| 159 | + var actionUsageNodeDescription = this.findNodeDescription(diagramDescription, this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getActionUsage())); |
| 160 | + |
| 161 | + var newFlowTool = itemUsageBorderNodeDescription.getPalette().getEdgeTools().stream() |
| 162 | + .filter(edgeTool -> "New Flow (flow)".equals(edgeTool.getName())) |
| 163 | + .findFirst(); |
| 164 | + assertThat(newFlowTool).isPresent(); |
| 165 | + |
| 166 | + assertThat(this.getTargetDescriptionNames(newFlowTool.get())) |
| 167 | + .containsExactlyInAnyOrderElementsOf(this.getExpectedFlowTargetDescriptionNames()) |
| 168 | + .doesNotContain(actionUsageNodeDescription.getName()); |
| 169 | + } |
| 170 | + |
| 171 | + @DisplayName("GIVEN a General View diagram description, WHEN inspecting the New Flow tool on ReferenceUsage border nodes, THEN it uses the full renderer-compatible border-node targets") |
| 172 | + @GivenSysONServer({ GeneralViewFlowConnectionItemUsagesProjectData.SCRIPT_PATH }) |
| 173 | + @Test |
| 174 | + public void givenGeneralViewDiagramDescriptionWhenInspectingReferenceFlowToolTargetsThenTheyMatchTheRendererContract() { |
| 175 | + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewFlowConnectionItemUsagesProjectData.EDITING_CONTEXT_ID, |
| 176 | + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); |
| 177 | + |
| 178 | + var referenceUsageBorderNodeDescription = this.findNodeDescription(diagramDescription, |
| 179 | + this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getReferenceUsage())); |
| 180 | + var actionUsageNodeDescription = this.findNodeDescription(diagramDescription, this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getActionUsage())); |
| 181 | + |
| 182 | + var newFlowTool = referenceUsageBorderNodeDescription.getPalette().getEdgeTools().stream() |
| 183 | + .filter(edgeTool -> "New Flow (flow)".equals(edgeTool.getName())) |
| 184 | + .findFirst(); |
| 185 | + assertThat(newFlowTool).isPresent(); |
| 186 | + |
| 187 | + assertThat(this.getTargetDescriptionNames(newFlowTool.get())) |
| 188 | + .containsExactlyInAnyOrderElementsOf(this.getExpectedFlowTargetDescriptionNames()) |
| 189 | + .doesNotContain(actionUsageNodeDescription.getName()); |
| 190 | + } |
| 191 | + |
147 | 192 | @DisplayName("GIVEN a SysML Project with ItemUsages on ActionUsage, WHEN creating a FlowUsage between them, THEN an edge should be displayed to represent that new flow") |
148 | 193 | @GivenSysONServer({ GeneralViewFlowConnectionItemUsagesProjectData.SCRIPT_PATH }) |
149 | 194 | @Test |
@@ -624,4 +669,31 @@ private void assertConnectionType(IEditingContext editingContext, String connect |
624 | 669 | var connectionTypeId = this.identityService.getId(connectionType); |
625 | 670 | assertThat(connectionTypeId).isEqualTo(expectedTypeElementId); |
626 | 671 | } |
| 672 | + |
| 673 | + private NodeDescription findNodeDescription(org.eclipse.sirius.components.view.diagram.DiagramDescription diagramDescription, String nodeDescriptionName) { |
| 674 | + return EMFUtils.allContainedObjectOfType(diagramDescription, NodeDescription.class) |
| 675 | + .filter(nodeDescription -> nodeDescriptionName.equals(nodeDescription.getName())) |
| 676 | + .findFirst() |
| 677 | + .orElseThrow(); |
| 678 | + } |
| 679 | + |
| 680 | + private List<String> getExpectedFlowTargetDescriptionNames() { |
| 681 | + return List.of( |
| 682 | + this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getPortUsage(), SysmlPackage.eINSTANCE.getUsage_NestedPort()), |
| 683 | + this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getPortUsage(), SysmlPackage.eINSTANCE.getDefinition_OwnedPort()), |
| 684 | + this.descriptionNameGenerator.getInheritedBorderNodeName(SysmlPackage.eINSTANCE.getPortUsage(), SysmlPackage.eINSTANCE.getUsage_NestedPort()), |
| 685 | + this.descriptionNameGenerator.getInheritedBorderNodeName(SysmlPackage.eINSTANCE.getPortUsage(), SysmlPackage.eINSTANCE.getDefinition_OwnedPort()), |
| 686 | + this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getItemUsage(), SysmlPackage.eINSTANCE.getDefinition_OwnedItem()), |
| 687 | + this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getItemUsage(), SysmlPackage.eINSTANCE.getUsage_NestedItem()), |
| 688 | + this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getItemUsage(), SysmlPackage.eINSTANCE.getBehavior_Parameter()), |
| 689 | + this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getReferenceUsage())); |
| 690 | + } |
| 691 | + |
| 692 | + private List<String> getTargetDescriptionNames(EdgeTool edgeTool) { |
| 693 | + return edgeTool.getTargetElementDescriptions().stream() |
| 694 | + .filter(NodeDescription.class::isInstance) |
| 695 | + .map(NodeDescription.class::cast) |
| 696 | + .map(NodeDescription::getName) |
| 697 | + .toList(); |
| 698 | + } |
627 | 699 | } |
0 commit comments