|
31 | 31 | import org.eclipse.sirius.components.diagrams.OutsideLabel; |
32 | 32 | import org.eclipse.sirius.components.diagrams.ViewModifier; |
33 | 33 | import org.eclipse.sirius.components.diagrams.tests.navigation.DiagramNavigator; |
| 34 | +import org.eclipse.sirius.components.view.diagram.NodeTool; |
34 | 35 | import org.eclipse.sirius.components.view.emf.diagram.IDiagramIdProvider; |
35 | 36 | import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; |
36 | 37 | import org.eclipse.syson.AbstractIntegrationTests; |
|
52 | 53 | import org.eclipse.syson.sysml.PartUsage; |
53 | 54 | import org.eclipse.syson.sysml.StateDefinition; |
54 | 55 | import org.eclipse.syson.sysml.SysmlPackage; |
| 56 | +import org.eclipse.syson.sysml.helper.EMFUtils; |
55 | 57 | import org.eclipse.syson.sysml.helper.LabelConstants; |
56 | 58 | import org.eclipse.syson.util.IDescriptionNameGenerator; |
57 | 59 | import org.eclipse.syson.util.SysONRepresentationDescriptionIdentifiers; |
|
60 | 62 | import org.junit.jupiter.api.Test; |
61 | 63 | import org.springframework.beans.factory.annotation.Autowired; |
62 | 64 | import org.springframework.boot.test.context.SpringBootTest; |
| 65 | +import org.springframework.test.context.transaction.TestTransaction; |
63 | 66 | import org.springframework.transaction.annotation.Transactional; |
64 | 67 |
|
65 | 68 | import reactor.core.publisher.Flux; |
@@ -132,8 +135,8 @@ public void setUp() { |
132 | 135 | } |
133 | 136 |
|
134 | 137 | @DisplayName("GIVEN a General View diagram, WHEN duplicating a Part Usage node with attributes, THEN the semantic element is duplicated with its content and its representation") |
135 | | - @Test |
136 | 138 | @GivenSysONServer({ GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }) |
| 139 | + @Test |
137 | 140 | public void checkTopUsageNodeDuplication() { |
138 | 141 | var flux = this.givenSubscriptionToDiagram(); |
139 | 142 |
|
@@ -189,9 +192,32 @@ public void checkTopUsageNodeDuplication() { |
189 | 192 | .verify(Duration.ofSeconds(10)); |
190 | 193 | } |
191 | 194 |
|
192 | | - @DisplayName("GIVEN a General View diagram, WHEN duplicating an ItemUsage bordered node, THEN the semantic element is duplicated with its representation") |
| 195 | + @DisplayName("GIVEN a General View diagram, WHEN inspecting duplicate tools, THEN they provide the Ctrl+D keybinding") |
| 196 | + @GivenSysONServer({ GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }) |
193 | 197 | @Test |
| 198 | + public void checkDuplicateToolsKeyBinding() { |
| 199 | + TestTransaction.flagForCommit(); |
| 200 | + TestTransaction.end(); |
| 201 | + |
| 202 | + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewItemAndAttributeProjectData.EDITING_CONTEXT_ID, |
| 203 | + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); |
| 204 | + |
| 205 | + var duplicateElementTool = EMFUtils.allContainedObjectOfType(diagramDescription, NodeTool.class) |
| 206 | + .filter(nodeTool -> "Duplicate Element".equals(nodeTool.getName())) |
| 207 | + .findFirst(); |
| 208 | + assertThat(duplicateElementTool).isPresent(); |
| 209 | + this.assertCtrlDKeyBinding(duplicateElementTool.get()); |
| 210 | + |
| 211 | + var duplicateElementsGroupTool = EMFUtils.allContainedObjectOfType(diagramDescription.getGroupPalette(), NodeTool.class) |
| 212 | + .filter(nodeTool -> "Duplicate Elements".equals(nodeTool.getName())) |
| 213 | + .findFirst(); |
| 214 | + assertThat(duplicateElementsGroupTool).isPresent(); |
| 215 | + this.assertCtrlDKeyBinding(duplicateElementsGroupTool.get()); |
| 216 | + } |
| 217 | + |
| 218 | + @DisplayName("GIVEN a General View diagram, WHEN duplicating an ItemUsage bordered node, THEN the semantic element is duplicated with its representation") |
194 | 219 | @GivenSysONServer({ GeneralViewItemAndAttributeProjectData.SCRIPT_PATH }) |
| 220 | + @Test |
195 | 221 | public void checkBorderedNodeUsageNodeDuplication() { |
196 | 222 | var flux = this.givenSubscriptionToDiagram(); |
197 | 223 |
|
@@ -325,8 +351,8 @@ public void checkCompartmentItemUsageNodeDuplication() { |
325 | 351 | } |
326 | 352 |
|
327 | 353 | @DisplayName("GIVEN a General View diagram, WHEN duplicating two top container nodes, THEN both semantic elements and representations are duplicated") |
328 | | - @Test |
329 | 354 | @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) |
| 355 | + @Test |
330 | 356 | public void checkMultiSelectionContainerNodeDuplication() { |
331 | 357 | var flux = this.givenSubscriptionToDiagram(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, GeneralViewWithTopNodesTestProjectData.GraphicalIds.DIAGRAM_ID); |
332 | 358 | var topNodesSemanticCheckerService = new SemanticCheckerService(this.semanticRunnableFactory, this.objectSearchService, GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, |
@@ -387,8 +413,8 @@ public void checkMultiSelectionContainerNodeDuplication() { |
387 | 413 | } |
388 | 414 |
|
389 | 415 | @DisplayName("GIVEN a General View diagram, WHEN a part is created in a Package and duplicated with a StateDefinition, THEN both semantic elements and representations are duplicated") |
390 | | - @Test |
391 | 416 | @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) |
| 417 | + @Test |
392 | 418 | public void checkMultiSelectionDifferentContainerNodeDuplication() { |
393 | 419 | var flux = this.givenSubscriptionToDiagram(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, GeneralViewWithTopNodesTestProjectData.GraphicalIds.DIAGRAM_ID); |
394 | 420 | var topNodesSemanticCheckerService = new SemanticCheckerService(this.semanticRunnableFactory, this.objectSearchService, GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, |
@@ -499,4 +525,15 @@ private boolean containsLabel(Node node, String label) { |
499 | 525 | return match; |
500 | 526 | } |
501 | 527 |
|
| 528 | + private void assertCtrlDKeyBinding(NodeTool nodeTool) { |
| 529 | + assertThat(nodeTool.getKeyBindings()) |
| 530 | + .singleElement() |
| 531 | + .satisfies(keyBinding -> { |
| 532 | + assertThat(keyBinding.isCtrl()).isTrue(); |
| 533 | + assertThat(keyBinding.isAlt()).isFalse(); |
| 534 | + assertThat(keyBinding.isMeta()).isFalse(); |
| 535 | + assertThat(keyBinding.getKey()).isEqualTo("d"); |
| 536 | + }); |
| 537 | + } |
| 538 | + |
502 | 539 | } |
0 commit comments