47
47
import org .eclipse .syson .application .controllers .diagrams .testers .NodeCreationTester ;
48
48
import org .eclipse .syson .application .controllers .utils .TestNameGenerator ;
49
49
import org .eclipse .syson .application .data .SysMLv2Identifiers ;
50
+ import org .eclipse .syson .diagram .common .view .services .description .ReferencingPerformActionUsageNodeDescriptionService ;
50
51
import org .eclipse .syson .diagram .general .view .GVDescriptionNameGenerator ;
51
52
import org .eclipse .syson .services .SemanticCheckerFactory ;
52
53
import org .eclipse .syson .services .diagrams .DiagramComparator ;
55
56
import org .eclipse .syson .services .diagrams .api .IGivenDiagramReference ;
56
57
import org .eclipse .syson .services .diagrams .api .IGivenDiagramSubscription ;
57
58
import org .eclipse .syson .sysml .AcceptActionUsage ;
59
+ import org .eclipse .syson .sysml .ActionUsage ;
58
60
import org .eclipse .syson .sysml .Element ;
59
61
import org .eclipse .syson .sysml .FeatureTyping ;
60
62
import org .eclipse .syson .sysml .Membership ;
63
+ import org .eclipse .syson .sysml .PerformActionUsage ;
61
64
import org .eclipse .syson .sysml .SysmlPackage ;
62
65
import org .eclipse .syson .sysml .helper .EMFUtils ;
63
66
import org .eclipse .syson .sysml .helper .LabelConstants ;
86
89
@ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .RANDOM_PORT )
87
90
public class GVSubNodeCreationTests extends AbstractIntegrationTests {
88
91
92
+ private static final String ACTIONS_COMPARTMENT = "actions" ;
93
+
89
94
private static final String ATTRIBUTES_COMPARTMENT = "attributes" ;
90
95
91
96
private static final String DOC_COMPARTMENT = "doc" ;
@@ -341,8 +346,8 @@ private static Stream<Arguments> actionUsageListNodeParameters() {
341
346
342
347
private static Stream <Arguments > actionUsageListAndFreeFormNodeParameters () {
343
348
return Stream .of (
344
- Arguments .of (SysmlPackage .eINSTANCE .getAcceptActionUsage (), "actions" , SysmlPackage .eINSTANCE .getUsage_NestedAction (), 1 ),
345
- Arguments .of (SysmlPackage .eINSTANCE .getActionUsage (), "actions" , SysmlPackage .eINSTANCE .getUsage_NestedAction (), 4 ))
349
+ Arguments .of (SysmlPackage .eINSTANCE .getAcceptActionUsage (), ACTIONS_COMPARTMENT , SysmlPackage .eINSTANCE .getUsage_NestedAction (), 1 ),
350
+ Arguments .of (SysmlPackage .eINSTANCE .getActionUsage (), ACTIONS_COMPARTMENT , SysmlPackage .eINSTANCE .getUsage_NestedAction (), 4 ))
346
351
// Uncomment when https://github.com/eclipse-sirius/sirius-web/issues/3650 is fixed
347
352
// Arguments.of(SysmlPackage.eINSTANCE.getDecisionNode(), "actions",
348
353
// SysmlPackage.eINSTANCE.getUsage_NestedAction(), 0),
@@ -357,8 +362,8 @@ private static Stream<Arguments> actionUsageListAndFreeFormNodeParameters() {
357
362
358
363
private static Stream <Arguments > actionDefinitionListAndFreeFormNodeParameters () {
359
364
return Stream .of (
360
- Arguments .of (SysmlPackage .eINSTANCE .getAcceptActionUsage (), "actions" , SysmlPackage .eINSTANCE .getDefinition_OwnedAction (), 1 ),
361
- Arguments .of (SysmlPackage .eINSTANCE .getActionUsage (), "actions" , SysmlPackage .eINSTANCE .getDefinition_OwnedAction (), 4 ))
365
+ Arguments .of (SysmlPackage .eINSTANCE .getAcceptActionUsage (), ACTIONS_COMPARTMENT , SysmlPackage .eINSTANCE .getDefinition_OwnedAction (), 1 ),
366
+ Arguments .of (SysmlPackage .eINSTANCE .getActionUsage (), ACTIONS_COMPARTMENT , SysmlPackage .eINSTANCE .getDefinition_OwnedAction (), 4 ))
362
367
// Uncomment when https://github.com/eclipse-sirius/sirius-web/issues/3650 is fixed
363
368
// Arguments.of(SysmlPackage.eINSTANCE.getDecisionNode(), "actions",
364
369
// SysmlPackage.eINSTANCE.getDefinition_OwnedAction(), 0),
@@ -934,6 +939,91 @@ public void createActionUsageListAndFreeFormChildNodes(EClass childEClass, Strin
934
939
this .checkEditingContext (this .getElementInParentSemanticChecker (parentLabel , containmentReference , childEClass ));
935
940
}
936
941
942
+ @ Sql (scripts = { "/scripts/syson-test-database.sql" }, executionPhase = Sql .ExecutionPhase .BEFORE_TEST_METHOD )
943
+ @ Sql (scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql .ExecutionPhase .AFTER_TEST_METHOD , config = @ SqlConfig (transactionMode = SqlConfig .TransactionMode .ISOLATED ))
944
+ @ Test
945
+ public void createReferencingPerformActionUsageInActionUsage () {
946
+ EClass parentEClass = SysmlPackage .eINSTANCE .getActionUsage ();
947
+ EClass childEClass = SysmlPackage .eINSTANCE .getPerformActionUsage ();
948
+ String parentLabel = "action" ;
949
+ String creationToolName = "New Perfom" ;
950
+ EReference containmentReference = SysmlPackage .eINSTANCE .getUsage_NestedAction ();
951
+
952
+ this .createNode (parentEClass , parentLabel , creationToolName );
953
+ IDiagramChecker diagramChecker = (initialDiagram , newDiagram ) -> {
954
+ int createdNodesExpectedCount = 3 ;
955
+ new CheckDiagramElementCount (this .diagramComparator )
956
+ .hasNewNodeCount (createdNodesExpectedCount )
957
+ .check (initialDiagram , newDiagram );
958
+ String listNodeDescription = this .descriptionNameGenerator .getCompartmentItemName (parentEClass , containmentReference );
959
+ new CheckNodeInCompartment (this .diagramDescriptionIdProvider , this .diagramComparator )
960
+ .withParentLabel (parentLabel )
961
+ .withCompartmentName (ACTIONS_COMPARTMENT )
962
+ .hasNodeDescriptionName (listNodeDescription )
963
+ .hasCompartmentCount (0 )
964
+ .check (initialDiagram , newDiagram );
965
+ String freeFormNodeDescription = this .descriptionNameGenerator .getNodeName (ReferencingPerformActionUsageNodeDescriptionService .REFERENCING_PERFORM_ACTION_NAME );
966
+ new CheckNodeInCompartment (this .diagramDescriptionIdProvider , this .diagramComparator )
967
+ .withParentLabel (parentLabel )
968
+ .withCompartmentName ("action flow" )
969
+ .hasNodeDescriptionName (freeFormNodeDescription )
970
+ .hasCompartmentCount (0 )
971
+ .check (initialDiagram , newDiagram );
972
+ };
973
+ this .checkDiagram (diagramChecker );
974
+ ISemanticChecker semanticChecker = (editingContext ) -> {
975
+ Object semanticRootObject = this .objectService .getObject (editingContext , SysMLv2Identifiers .GENERAL_VIEW_WITH_TOP_NODES_DIAGRAM_OBJECT ).orElse (null );
976
+ assertThat (semanticRootObject ).isInstanceOf (Element .class );
977
+ Element semanticRootElement = (Element ) semanticRootObject ;
978
+ Optional <PerformActionUsage > optParentElement = EMFUtils .allContainedObjectOfType (semanticRootElement , PerformActionUsage .class )
979
+ .filter (element -> Objects .equals (element .getName (), "performAction" ))
980
+ .findFirst ();
981
+ assertThat (optParentElement ).isPresent ();
982
+ var performActionUsage = optParentElement .get ();
983
+ ActionUsage performedAction = performActionUsage .getPerformedAction ();
984
+ // the performed action is another action
985
+ assertThat (performedAction ).isNotEqualTo (performedAction );
986
+ assertThat (performedAction .getName ()).isEqualTo ("performedAction" );
987
+ };
988
+ this .checkEditingContext (this .getElementInParentSemanticChecker (parentLabel , containmentReference , childEClass ));
989
+ this .checkEditingContext (semanticChecker );
990
+ }
991
+
992
+ @ Sql (scripts = { "/scripts/syson-test-database.sql" }, executionPhase = Sql .ExecutionPhase .BEFORE_TEST_METHOD )
993
+ @ Sql (scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql .ExecutionPhase .AFTER_TEST_METHOD , config = @ SqlConfig (transactionMode = SqlConfig .TransactionMode .ISOLATED ))
994
+ @ Test
995
+ public void createPerformActionUsageInActionUsage () {
996
+ EClass parentEClass = SysmlPackage .eINSTANCE .getActionUsage ();
997
+ EClass childEClass = SysmlPackage .eINSTANCE .getPerformActionUsage ();
998
+ String parentLabel = "action" ;
999
+ String creationToolName = "New Perfom action" ;
1000
+ EReference containmentReference = SysmlPackage .eINSTANCE .getUsage_NestedAction ();
1001
+
1002
+ this .createNode (parentEClass , parentLabel , creationToolName );
1003
+ IDiagramChecker diagramChecker = (initialDiagram , newDiagram ) -> {
1004
+ int createdNodesExpectedCount = 6 ;
1005
+ new CheckDiagramElementCount (this .diagramComparator )
1006
+ .hasNewNodeCount (createdNodesExpectedCount )
1007
+ .check (initialDiagram , newDiagram );
1008
+ String listNodeDescription = this .descriptionNameGenerator .getCompartmentItemName (parentEClass , containmentReference );
1009
+ new CheckNodeInCompartment (this .diagramDescriptionIdProvider , this .diagramComparator )
1010
+ .withParentLabel (parentLabel )
1011
+ .withCompartmentName (ACTIONS_COMPARTMENT )
1012
+ .hasNodeDescriptionName (listNodeDescription )
1013
+ .hasCompartmentCount (0 )
1014
+ .check (initialDiagram , newDiagram );
1015
+ String freeFormNodeDescription = this .descriptionNameGenerator .getNodeName (childEClass );
1016
+ new CheckNodeInCompartment (this .diagramDescriptionIdProvider , this .diagramComparator )
1017
+ .withParentLabel (parentLabel )
1018
+ .withCompartmentName ("action flow" )
1019
+ .hasNodeDescriptionName (freeFormNodeDescription )
1020
+ .hasCompartmentCount (4 )
1021
+ .check (initialDiagram , newDiagram );
1022
+ };
1023
+ this .checkDiagram (diagramChecker );
1024
+ this .checkEditingContext (this .getElementInParentSemanticChecker (parentLabel , containmentReference , childEClass ));
1025
+ }
1026
+
937
1027
@ Sql (scripts = { "/scripts/syson-test-database.sql" }, executionPhase = Sql .ExecutionPhase .BEFORE_TEST_METHOD )
938
1028
@ Sql (scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql .ExecutionPhase .AFTER_TEST_METHOD , config = @ SqlConfig (transactionMode = SqlConfig .TransactionMode .ISOLATED ))
939
1029
@ ParameterizedTest
0 commit comments