From 04308e35d9274e3f9e55963c64d0401f09355b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Giraudet?= Date: Mon, 2 Feb 2026 14:01:43 +0100 Subject: [PATCH] [cleanup] Inline StepVerifier logic in GVSNSCTests and cleanup deprecated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Théo Giraudet --- .../checkers/DiagramCheckerService.java | 136 +--- .../view/GVSubNodeAnalysisCreationTests.java | 4 +- ...GVSubNodeInterconnectionCreationTests.java | 4 +- .../GVSubNodeRequirementCreationTests.java | 2 +- .../view/GVSubNodeStructureCreationTests.java | 678 +++++++++++------- .../view/GVSubNodeTemporalCreationTests.java | 2 +- .../testers/DirectEditInitialLabelTester.java | 63 -- .../diagrams/testers/DirectEditTester.java | 169 ----- .../diagrams/NodeCreationTestsService.java | 156 ---- 9 files changed, 429 insertions(+), 785 deletions(-) diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/checkers/DiagramCheckerService.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/checkers/DiagramCheckerService.java index 6f73a969a..a5b503176 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/checkers/DiagramCheckerService.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/checkers/DiagramCheckerService.java @@ -46,42 +46,6 @@ public DiagramCheckerService(DiagramComparator diagramComparator, IDescriptionNa this.descriptionNameGenerator = descriptionNameGenerator; } - /** - * Returns a checker that verifies a child node was created on the diagram. - * - * @param previousDiagram - * the reference to the previous diagram state - * @param diagramDescriptionIdProvider - * the provider for diagram description IDs - * @param parentLabel - * the label of the parent node - * @param childEClass - * the EClass of the expected child node - * @param compartmentCount - * the expected number of compartments - * @return the diagram checker - * @deprecated this function will be removed when all the tests will be migrated to follow the same format as Sirius Web. - * Please, use {@link #childNodeGraphicalChecker(AtomicReference, DiagramDescriptionIdProvider, String, EClass, int)} instead. - */ - @Deprecated - public IDiagramChecker getChildNodeGraphicalChecker(AtomicReference previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, String parentLabel, EClass childEClass, - int compartmentCount) { - return (initialDiagram, newDiagram) -> { - int createdNodesExpectedCount = 1 + compartmentCount; - new CheckDiagramElementCount(this.diagramComparator) - .hasNewNodeCount(createdNodesExpectedCount) - .hasNewEdgeCount(0) - .check(previousDiagram.get(), newDiagram); - - String newNodeDescriptionName = this.descriptionNameGenerator.getNodeName(childEClass); - new CheckChildNode(diagramDescriptionIdProvider, this.diagramComparator) - .withParentLabel(parentLabel) - .hasNodeDescriptionName(newNodeDescriptionName) - .hasCompartmentCount(compartmentCount) - .check(previousDiagram.get(), newDiagram); - }; - } - /** * Returns a consumer that checks a child node was created on the diagram. * @@ -115,44 +79,6 @@ public Consumer childNodeGraphicalChecker(AtomicReference previ }); } - /** - * Returns a checker that verifies a node was created in a compartment. - * - * @param previousDiagram - * the reference to the previous diagram state - * @param diagramDescriptionIdProvider - * the provider for diagram description IDs - * @param parentLabel - * the label of the parent node - * @param parentEClass - * the EClass of the parent node - * @param containmentReference - * the containment reference for the compartment item - * @param compartmentName - * the name of the compartment - * @return the diagram checker - * @deprecated this function will be removed when all the tests will be migrated to follow the same format as Sirius Web. - * Please, use {@link #compartmentNodeGraphicalChecker(AtomicReference, DiagramDescriptionIdProvider, String, EClass, EReference, String)} instead. - */ - @Deprecated - public IDiagramChecker getCompartmentNodeGraphicalChecker(AtomicReference previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, String parentLabel, - EClass parentEClass, EReference containmentReference, String compartmentName) { - return (initialDiagram, newDiagram) -> { - new CheckDiagramElementCount(this.diagramComparator) - .hasNewNodeCount(1) - .hasNewEdgeCount(0) - .check(previousDiagram.get(), newDiagram); - - String newNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); - new CheckNodeInCompartment(diagramDescriptionIdProvider, this.diagramComparator) - .withParentLabel(parentLabel) - .withCompartmentName(compartmentName) - .hasNodeDescriptionName(newNodeDescriptionName) - .hasCompartmentCount(0) - .check(previousDiagram.get(), newDiagram); - }; - } - /** * Returns a consumer that checks a node was created in a compartment. * @@ -168,15 +94,17 @@ public IDiagramChecker getCompartmentNodeGraphicalChecker(AtomicReference compartmentNodeGraphicalChecker(AtomicReference previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, String parentLabel, - EClass parentEClass, EReference containmentReference, String compartmentName) { + EClass parentEClass, EReference containmentReference, String compartmentName, boolean onlyNewVisibleNodesAndEdges) { return assertRefreshedDiagramThat(newDiagram -> { new CheckDiagramElementCount(this.diagramComparator) .hasNewNodeCount(1) .hasNewEdgeCount(0) - .check(previousDiagram.get(), newDiagram); + .check(previousDiagram.get(), newDiagram, onlyNewVisibleNodesAndEdges); String newNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); new CheckNodeInCompartment(diagramDescriptionIdProvider, this.diagramComparator) @@ -188,62 +116,6 @@ public Consumer compartmentNodeGraphicalChecker(AtomicReference }); } - /** - * Returns a checker that verifies a sibling node was created on the diagram. - * - * @param previousDiagram - * the reference to the previous diagram state - * @param diagramDescriptionIdProvider - * the provider for diagram description IDs - * @param childEClass - * the EClass of the expected child node - * @param compartmentCount - * the expected number of compartments - * @return the diagram checker - * @deprecated this function will be removed when all the tests will be migrated to follow the same format as Sirius Web. - * Please, use {@link #siblingNodeGraphicalChecker(AtomicReference previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, EClass childEClass, int compartmentCount)} instead. - */ - @Deprecated - public IDiagramChecker getSiblingNodeGraphicalChecker(AtomicReference previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, EClass childEClass, - int compartmentCount) { - return this.getSiblingNodeGraphicalChecker(previousDiagram, diagramDescriptionIdProvider, childEClass, compartmentCount, 1); - } - - /** - * Returns a checker that verifies a sibling node was created on the diagram. - * - * @param previousDiagram - * the reference to the previous diagram state - * @param diagramDescriptionIdProvider - * the provider for diagram description IDs - * @param childEClass - * the EClass of the expected child node - * @param compartmentCount - * the expected number of compartments - * @param newNodesCount - * the expected number of new nodes - * @return the diagram checker - * @deprecated this function will be removed when all the tests will be migrated to follow the same format as Sirius Web. - * Please, use {@link #siblingNodeGraphicalChecker(AtomicReference previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, EClass childEClass, int compartmentCount, int newNodesCount)} instead. - */ - @Deprecated - public IDiagramChecker getSiblingNodeGraphicalChecker(AtomicReference previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, EClass childEClass, - int compartmentCount, int newNodesCount) { - return (initialDiagram, newDiagram) -> { - int createdNodesExpectedCount = newNodesCount + compartmentCount; - new CheckDiagramElementCount(this.diagramComparator) - .hasNewNodeCount(createdNodesExpectedCount) - .hasNewEdgeCount(1) - .check(previousDiagram.get(), newDiagram); - - String newNodeDescriptionName = this.descriptionNameGenerator.getNodeName(childEClass); - new CheckNodeOnDiagram(diagramDescriptionIdProvider, this.diagramComparator) - .hasNodeDescriptionName(newNodeDescriptionName) - .hasCompartmentCount(compartmentCount) - .check(previousDiagram.get(), newDiagram); - }; - } - /** * Returns a consumer that checks a sibling node was created on the diagram. * diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeAnalysisCreationTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeAnalysisCreationTests.java index 61568001f..9898f4d27 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeAnalysisCreationTests.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeAnalysisCreationTests.java @@ -325,7 +325,7 @@ public void createCaseDefinitionChildNodes(EClass childEClass, String compartmen EClass parentEClass = SysmlPackage.eINSTANCE.getCaseDefinition(); String parentLabel = "CaseDefinition"; Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); - Consumer diagramCheck = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, compartmentName); + Consumer diagramCheck = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, compartmentName, false); Runnable semanticCheck = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); StepVerifier.create(flux) @@ -471,7 +471,7 @@ public void createUseCaseDefinitionChildNodes(EClass childEClass, String compart EClass parentEClass = SysmlPackage.eINSTANCE.getUseCaseDefinition(); String parentLabel = "UseCaseDefinition"; Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); - Consumer diagramCheck = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, compartmentName); + Consumer diagramCheck = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, compartmentName, false); Runnable semanticCheck = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); StepVerifier.create(flux) diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeInterconnectionCreationTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeInterconnectionCreationTests.java index 2fe80387f..a12d31de3 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeInterconnectionCreationTests.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeInterconnectionCreationTests.java @@ -280,7 +280,7 @@ public void createAllocationUsageChildNodes(EClass childEClass, String compartme String parentLabel = "allocation"; Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); Consumer diagramCheck = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, - compartmentName); + compartmentName, false); Runnable semanticCheck = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); StepVerifier.create(flux) @@ -379,7 +379,7 @@ public void createAllocationDefinitionChildNodes(EClass childEClass, String comp String parentLabel = "AllocationDefinition"; Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); Consumer diagramCheck = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, - compartmentName); + compartmentName, false); Runnable semanticCheck = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); StepVerifier.create(flux) diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeRequirementCreationTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeRequirementCreationTests.java index 153b76a4c..214b03a64 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeRequirementCreationTests.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeRequirementCreationTests.java @@ -723,7 +723,7 @@ public void createConstraintDefinitionChildNodes(EClass childEClass, String comp String parentLabel = "ConstraintDefinition"; Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); Consumer diagramCheck = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, - compartmentName); + compartmentName, false); Runnable semanticCheck = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); StepVerifier.create(flux) diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeStructureCreationTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeStructureCreationTests.java index 757b1ef16..89d0c4894 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeStructureCreationTests.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeStructureCreationTests.java @@ -12,10 +12,13 @@ *******************************************************************************/ package org.eclipse.syson.application.controllers.diagrams.general.view; +import static org.eclipse.sirius.components.diagrams.tests.DiagramEventPayloadConsumer.assertRefreshedDiagramThat; + import java.time.Duration; import java.util.List; import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; import java.util.stream.Stream; import org.eclipse.emf.ecore.EClass; @@ -26,16 +29,15 @@ import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolVariableType; import org.eclipse.sirius.components.core.api.IObjectSearchService; import org.eclipse.sirius.components.diagrams.Diagram; -import org.eclipse.sirius.components.view.diagram.DiagramDescription; import org.eclipse.sirius.components.view.emf.diagram.IDiagramIdProvider; import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; import org.eclipse.syson.AbstractIntegrationTests; +import org.eclipse.syson.GivenSysONServer; import org.eclipse.syson.application.controller.editingContext.checkers.SemanticCheckerService; import org.eclipse.syson.application.controllers.diagrams.checkers.CheckBorderNode; import org.eclipse.syson.application.controllers.diagrams.checkers.CheckDiagramElementCount; import org.eclipse.syson.application.controllers.diagrams.checkers.CheckNodeInCompartment; import org.eclipse.syson.application.controllers.diagrams.checkers.DiagramCheckerService; -import org.eclipse.syson.application.controllers.diagrams.checkers.IDiagramChecker; import org.eclipse.syson.application.controllers.diagrams.testers.ToolTester; import org.eclipse.syson.application.controllers.utils.TestNameGenerator; import org.eclipse.syson.application.data.GeneralViewWithTopNodesTestProjectData; @@ -45,25 +47,21 @@ import org.eclipse.syson.services.diagrams.DiagramDescriptionIdProvider; import org.eclipse.syson.services.diagrams.NodeCreationTestsService; import org.eclipse.syson.services.diagrams.api.IGivenDiagramDescription; -import org.eclipse.syson.services.diagrams.api.IGivenDiagramReference; import org.eclipse.syson.services.diagrams.api.IGivenDiagramSubscription; import org.eclipse.syson.standard.diagrams.view.SDVDescriptionNameGenerator; import org.eclipse.syson.sysml.SysmlPackage; import org.eclipse.syson.util.IDescriptionNameGenerator; import org.eclipse.syson.util.SysONRepresentationDescriptionIdentifiers; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.jdbc.SqlConfig; import org.springframework.transaction.annotation.Transactional; +import reactor.core.publisher.Flux; import reactor.test.StepVerifier; -import reactor.test.StepVerifier.Step; /** * Tests the creation of "Structure" sub nodes section in the General View diagram. @@ -81,9 +79,6 @@ public class GVSubNodeStructureCreationTests extends AbstractIntegrationTests { @Autowired private IGivenInitialServerState givenInitialServerState; - @Autowired - private IGivenDiagramReference givenDiagram; - @Autowired private IGivenDiagramDescription givenDiagramDescription; @@ -105,18 +100,10 @@ public class GVSubNodeStructureCreationTests extends AbstractIntegrationTests { @Autowired private DiagramComparator diagramComparator; - private DiagramDescriptionIdProvider diagramDescriptionIdProvider; - - private Step verifier; - - private AtomicReference diagram; - - private DiagramDescription diagramDescription; + private final IDescriptionNameGenerator descriptionNameGenerator = new SDVDescriptionNameGenerator(); private NodeCreationTestsService creationTestsService; - private final IDescriptionNameGenerator descriptionNameGenerator = new SDVDescriptionNameGenerator(); - private DiagramCheckerService diagramCheckerService; private SemanticCheckerService semanticCheckerService; @@ -269,422 +256,595 @@ private static Stream directedPortsInPartDefinitionChildNodeParameter .map(TestNameGenerator::namedArguments); } - @BeforeEach - public void setUp() { - this.givenInitialServerState.initialize(); + private Flux givenSubscriptionToDiagram() { var diagramEventInput = new DiagramEventInput(UUID.randomUUID(), GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, GeneralViewWithTopNodesTestProjectData.GraphicalIds.DIAGRAM_ID); - var flux = this.givenDiagramSubscription.subscribe(diagramEventInput); - this.verifier = StepVerifier.create(flux); - this.diagram = this.givenDiagram.getDiagram(this.verifier); - this.diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, - SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); - this.diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(this.diagramDescription, this.diagramIdProvider); + return this.givenDiagramSubscription.subscribe(diagramEventInput); + } + + @BeforeEach + public void setUp() { + this.givenInitialServerState.initialize(); this.creationTestsService = new NodeCreationTestsService(this.nodeCreationTester, this.descriptionNameGenerator, GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID); this.diagramCheckerService = new DiagramCheckerService(this.diagramComparator, this.descriptionNameGenerator); this.semanticCheckerService = new SemanticCheckerService(this.semanticRunnableFactory, this.objectSearchService, GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, GeneralViewWithTopNodesTestProjectData.SemanticIds.PACKAGE_1_ID); } - @AfterEach - public void tearDown() { - if (this.verifier != null) { - this.verifier.thenCancel() - .verify(Duration.ofSeconds(10)); - } - } - - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("attributeDefinitionChildNodeParameters") public void createAttributeDefinitionSubNodes(EClass childEClass, String compartmentName, EReference containmentReference) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getAttributeDefinition(); String parentLabel = "AttributeDefinition"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, - childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { - new CheckDiagramElementCount(this.diagramComparator) - .hasNewNodeCount(1) - .hasNewEdgeCount(0) - .check(initialDiagram, newDiagram, true); - String newNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) - .withParentLabel(parentLabel) - .withCompartmentName(compartmentName) - .hasNodeDescriptionName(newNodeDescriptionName) - .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), - this.verifier); + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, + compartmentName, true); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("attributeUsageChildNodeParameters") public void createAttributeUsageSubNodes(EClass childEClass, String compartmentName, EReference containmentReference) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getAttributeUsage(); String parentLabel = "attribute"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, - childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { - new CheckDiagramElementCount(this.diagramComparator) - .hasNewNodeCount(1) - .hasNewEdgeCount(0) - .check(initialDiagram, newDiagram, true); - String newNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) - .withParentLabel(parentLabel) - .withCompartmentName(compartmentName) - .hasNodeDescriptionName(newNodeDescriptionName) - .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), - this.verifier); + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, + compartmentName, true); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("enumerationDefinitionChildNodeParameters") public void createEnumerationDefinitionSubNodes(EClass childEClass, String compartmentName, EReference containmentReference) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getEnumerationDefinition(); String parentLabel = "EnumerationDefinition"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { - new CheckDiagramElementCount(this.diagramComparator) - .hasNewNodeCount(1) - .hasNewEdgeCount(0) - .check(initialDiagram, newDiagram, true); - String newNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) - .withParentLabel(parentLabel) - .withCompartmentName(compartmentName) - .hasNodeDescriptionName(newNodeDescriptionName) - .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, + compartmentName, false); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("itemDefinitionSiblingNodeParameters") public void createItemDefinitionSiblingNodes(EClass childEClass, EReference containmentReference, int compartmentCount) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getItemDefinition(); String parentLabel = "ItemDefinition"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - this.diagramCheckerService.checkDiagram(this.diagramCheckerService.getSiblingNodeGraphicalChecker(this.diagram, this.diagramDescriptionIdProvider, childEClass, compartmentCount), - this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = this.diagramCheckerService.siblingNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, childEClass, compartmentCount); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("itemDefinitionChildNodeParameters") public void createItemDefinitionSubNodes(EClass childEClass, String compartmentName, EReference containmentReference) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getItemDefinition(); String parentLabel = "ItemDefinition"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { - new CheckDiagramElementCount(this.diagramComparator) - .hasNewNodeCount(1) - .hasNewEdgeCount(0) - .check(initialDiagram, newDiagram, true); - String newNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) - .withParentLabel(parentLabel) - .withCompartmentName(compartmentName) - .hasNodeDescriptionName(newNodeDescriptionName) - .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, + compartmentName, true); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("itemUsageSiblingNodeParameters") public void createItemUsageSiblingNodes(EClass childEClass, EReference containmentReference, int compartmentCount) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getItemUsage(); String parentLabel = "item"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - this.diagramCheckerService.checkDiagram(this.diagramCheckerService.getSiblingNodeGraphicalChecker(this.diagram, this.diagramDescriptionIdProvider, childEClass, compartmentCount), - this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = this.diagramCheckerService.siblingNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, childEClass, compartmentCount); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("itemUsageChildNodeParameters") public void createItemUsageChildNodes(EClass childEClass, String compartmentName, EReference containmentReference) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getItemUsage(); String parentLabel = "item"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { - new CheckDiagramElementCount(this.diagramComparator) - .hasNewNodeCount(1) - .hasNewEdgeCount(0) - .check(initialDiagram, newDiagram, true); - String newNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) - .withParentLabel(parentLabel) - .withCompartmentName(compartmentName) - .hasNodeDescriptionName(newNodeDescriptionName) - .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, + compartmentName, true); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("itemUsageBorderAndChildNodeParameters") public void createItemUsageBorderAndChildNodes(EClass childEClass, String compartmentName, EReference containmentReference, EClass borderNodeType) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getItemUsage(); String parentLabel = "item"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { + + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = assertRefreshedDiagramThat(newDiagram -> { new CheckDiagramElementCount(this.diagramComparator) .hasNewNodeCount(1) .hasNewBorderNodeCount(1) .hasNewEdgeCount(0) - .check(initialDiagram, newDiagram, true); + .check(diagram.get(), newDiagram, true); String compartmentNodeDescription = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) + new CheckNodeInCompartment(diagramDescriptionIdProvider, this.diagramComparator) .withParentLabel(parentLabel) .withCompartmentName(compartmentName) .hasNodeDescriptionName(compartmentNodeDescription) .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); + .check(diagram.get(), newDiagram); String borderNodeDescription = this.descriptionNameGenerator.getBorderNodeName(borderNodeType, containmentReference); - new CheckBorderNode(this.diagramDescriptionIdProvider, this.diagramComparator) + new CheckBorderNode(diagramDescriptionIdProvider, this.diagramComparator) .withParentLabel(parentLabel) .hasBorderNodeDescriptionName(borderNodeDescription) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + .check(diagram.get(), newDiagram); + }); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("packageChildNodeParameters") public void createPackageChildNodes(EClass childEClass, EReference containmentReference, int compartmentCount) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getPackage(); String parentLabel = "Package"; List variables = List.of(); if (SysmlPackage.eINSTANCE.getNamespaceImport().equals(childEClass)) { variables = List.of(new ToolVariable("selectedObject", GeneralViewWithTopNodesTestProjectData.SemanticIds.PACKAGE_1_ID, ToolVariableType.OBJECT_ID)); } - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass, variables); - this.diagramCheckerService.checkDiagram( - this.diagramCheckerService.getChildNodeGraphicalChecker(this.diagram, this.diagramDescriptionIdProvider, parentLabel, childEClass, compartmentCount), this.diagram, - this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + + List finalVariables = variables; + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass, finalVariables); + + Consumer diagramChecker = this.diagramCheckerService.childNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, childEClass, compartmentCount); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("partDefinitionChildNodeParameters") public void createPartDefinitionChildNodes(EClass childEClass, String compartmentName, EReference containmentReference) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getPartDefinition(); String parentLabel = "PartDefinition"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { - new CheckDiagramElementCount(this.diagramComparator) - .hasNewNodeCount(1) - .hasNewEdgeCount(0) - .check(initialDiagram, newDiagram, true); - String newNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) - .withParentLabel(parentLabel) - .withCompartmentName(compartmentName) - .hasNodeDescriptionName(newNodeDescriptionName) - .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, + compartmentName, true); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("partDefinitionSiblingNodeParameters") public void createPartDefinitionSiblingNodes(EClass childEClass, EReference containmentReference) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getPartDefinition(); String parentLabel = "PartDefinition"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = assertRefreshedDiagramThat(newDiagram -> { int createdNodesExpectedCount = 1; new CheckDiagramElementCount(this.diagramComparator) .hasNewNodeCount(createdNodesExpectedCount) .hasNewEdgeCount(1) - .check(initialDiagram, newDiagram, true); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + .check(diagram.get(), newDiagram, true); + }); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("partDefinitionSiblingAndChildNodeParameters") public void createPartDefinitionSiblingAndChildNodes(EClass childEClass, String compartmentName, EReference containmentReference, int expectedNumberOfNewNodes, int expectedNumberOfNewEdges, String compartmentNodeDecriptionNameSuffix) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getPartDefinition(); String parentLabel = "PartDefinition"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { + + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = assertRefreshedDiagramThat(newDiagram -> { new CheckDiagramElementCount(this.diagramComparator) .hasNewNodeCount(expectedNumberOfNewNodes) .hasNewEdgeCount(expectedNumberOfNewEdges) - .check(initialDiagram, newDiagram); + .check(diagram.get(), newDiagram); String compartmentItemNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference) + compartmentNodeDecriptionNameSuffix; - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) + new CheckNodeInCompartment(diagramDescriptionIdProvider, this.diagramComparator) .withParentLabel(parentLabel) .withCompartmentName(compartmentName) .hasNodeDescriptionName(compartmentItemNodeDescriptionName) .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + .check(diagram.get(), newDiagram); + }); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("partUsageChildNodeParameters") public void createPartUsageChildNodes(EClass childEClass, String compartmentName, EReference containmentReference) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getPartUsage(); String parentLabel = "part"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { - new CheckDiagramElementCount(this.diagramComparator) - .hasNewNodeCount(1) - .hasNewEdgeCount(0) - .check(initialDiagram, newDiagram, true); - String newNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) - .withParentLabel(parentLabel) - .withCompartmentName(compartmentName) - .hasNodeDescriptionName(newNodeDescriptionName) - .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, + compartmentName, true); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("partUsageSiblingNodeParameters") public void createPartUsageSiblingNodes(EClass childEClass, EReference containmentReference, int compartmentCount) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getPartUsage(); String parentLabel = "part"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - this.diagramCheckerService.checkDiagram(this.diagramCheckerService.getSiblingNodeGraphicalChecker(this.diagram, this.diagramDescriptionIdProvider, childEClass, compartmentCount), - this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = this.diagramCheckerService.siblingNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, childEClass, compartmentCount); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("partUsageSiblingAndChildNodeParameters") public void createPartUsageSiblingAndChildNodes(EClass childEClass, String compartmentName, EReference containmentReference, int expectedNumberOfNewNodes, int expectedNumberOfNewEdges, String compartmentNodeDecriptionNameSuffix) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getPartUsage(); String parentLabel = "part"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, childEClass); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { + + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); + + Consumer diagramChecker = assertRefreshedDiagramThat(newDiagram -> { new CheckDiagramElementCount(this.diagramComparator) .hasNewNodeCount(expectedNumberOfNewNodes) .hasNewEdgeCount(expectedNumberOfNewEdges) - .check(initialDiagram, newDiagram); + .check(diagram.get(), newDiagram); String compartmentItemNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference) + compartmentNodeDecriptionNameSuffix; - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) + new CheckNodeInCompartment(diagramDescriptionIdProvider, this.diagramComparator) .withParentLabel(parentLabel) .withCompartmentName(compartmentName) .hasNodeDescriptionName(compartmentItemNodeDescriptionName) .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + .check(diagram.get(), newDiagram); + }); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } - @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, - config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) - @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }) @ParameterizedTest @MethodSource("directedPortsInPartDefinitionChildNodeParameters") public void createDirectedPortsInPartDefinitionChildNodeParameters(EClass childEClass, String compartmentName, EReference containmentReference, String creationToolName) { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + AtomicReference diagram = new AtomicReference<>(); + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); + EClass parentEClass = SysmlPackage.eINSTANCE.getPartDefinition(); String parentLabel = "PartDefinition"; - this.creationTestsService.createNode(this.verifier, this.diagramDescriptionIdProvider, this.diagram, parentEClass, parentLabel, creationToolName); - IDiagramChecker diagramChecker = (initialDiagram, newDiagram) -> { + + Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, creationToolName); + + Consumer diagramChecker = assertRefreshedDiagramThat(newDiagram -> { new CheckDiagramElementCount(this.diagramComparator) .hasNewNodeCount(1) .hasNewBorderNodeCount(1) .hasNewEdgeCount(0) - .check(initialDiagram, newDiagram, true); + .check(diagram.get(), newDiagram, true); String compartmentNodeDescription = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference); - new CheckNodeInCompartment(this.diagramDescriptionIdProvider, this.diagramComparator) + new CheckNodeInCompartment(diagramDescriptionIdProvider, this.diagramComparator) .withParentLabel(parentLabel) .withCompartmentName(compartmentName) .hasNodeDescriptionName(compartmentNodeDescription) .hasCompartmentCount(0) - .check(initialDiagram, newDiagram); + .check(diagram.get(), newDiagram); String borderNodeDescription = this.descriptionNameGenerator.getBorderNodeName(childEClass, containmentReference); - new CheckBorderNode(this.diagramDescriptionIdProvider, this.diagramComparator) + new CheckBorderNode(diagramDescriptionIdProvider, this.diagramComparator) .withParentLabel(parentLabel) .hasBorderNodeDescriptionName(borderNodeDescription) - .check(initialDiagram, newDiagram); - }; - this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier); - this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass), this.verifier); + .check(diagram.get(), newDiagram); + }); + + Runnable semanticChecker = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(createNodeRunnable) + .consumeNextWith(diagramChecker) + .then(semanticChecker) + .thenCancel() + .verify(Duration.ofSeconds(10)); } } diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeTemporalCreationTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeTemporalCreationTests.java index 7d52bf30e..0364566f4 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeTemporalCreationTests.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVSubNodeTemporalCreationTests.java @@ -166,7 +166,7 @@ public void createOccurrenceUsageChildNodes(EClass childEClass, String compartme String parentLabel = "occurrence"; Runnable createNodeRunnable = this.creationTestsService.createNode(diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass); Consumer diagramCheck = this.diagramCheckerService.compartmentNodeGraphicalChecker(diagram, diagramDescriptionIdProvider, parentLabel, parentEClass, containmentReference, - compartmentName); + compartmentName, false); Runnable semanticCheck = this.semanticCheckerService.checkEditingContext(this.semanticCheckerService.getElementInParentSemanticChecker(parentLabel, containmentReference, childEClass)); StepVerifier.create(flux) diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/testers/DirectEditInitialLabelTester.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/testers/DirectEditInitialLabelTester.java index 9cddca220..ff0246a89 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/testers/DirectEditInitialLabelTester.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/testers/DirectEditInitialLabelTester.java @@ -21,13 +21,10 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; -import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload; import org.eclipse.sirius.components.diagrams.Diagram; import org.eclipse.sirius.components.diagrams.tests.graphql.InitialDirectEditElementLabelQueryRunner; import org.eclipse.sirius.components.diagrams.tests.navigation.DiagramNavigator; -import reactor.test.StepVerifier.Step; - /** * Tester that checks the initial label used as input of the DirectEdit tool. * @@ -44,66 +41,6 @@ public DirectEditInitialLabelTester(InitialDirectEditElementLabelQueryRunner ini this.editingContextId = Objects.requireNonNull(editingContextId); } - /** - * Checks the initial direct edit label on a bordered node's outside label. - * - * @param verifier - * the verifier to chain the check to - * @param diagram - * the diagram reference - * @param mainNodeId - * the id of the node holding the outside label - * @param expectedLabel - * the expected initial label - * @deprecated use {@link #checkDirectEditInitialLabelOnBorderedNode(AtomicReference, String, String)} instead. - */ - @Deprecated - public void checkDirectEditInitialLabelOnBorderedNode(Step verifier, AtomicReference diagram, String mainNodeId, String expectedLabel) { - this.checkDirectEditInitialLabel(verifier, diagram, () -> { - DiagramNavigator diagramNavigator = new DiagramNavigator(diagram.get()); - return diagramNavigator.nodeWithId(mainNodeId).getNode().getOutsideLabels().get(0).id(); - }, expectedLabel); - } - - /** - * Checks the initial direct edit label on a node's inside label. - * - * @param verifier - * the verifier to chain the check to - * @param diagram - * the diagram reference - * @param mainNodeId - * the id of the node holding the inside label - * @param expectedLabel - * the expected initial label - * @deprecated use {@link #checkDirectEditInitialLabelOnNode(AtomicReference, String, String)} instead. - */ - @Deprecated - public void checkDirectEditInitialLabelOnNode(Step verifier, AtomicReference diagram, String mainNodeId, String expectedLabel) { - this.checkDirectEditInitialLabel(verifier, diagram, () -> { - DiagramNavigator diagramNavigator = new DiagramNavigator(diagram.get()); - return diagramNavigator.nodeWithId(mainNodeId).getNode().getInsideLabel().getId(); - }, expectedLabel); - } - - /** - * Checks the initial direct edit label using a custom label ID supplier. - * - * @param verifier - * the verifier to chain the check to - * @param diagram - * the diagram reference - * @param labelId - * a supplier that provides the label ID - * @param expectedLabel - * the expected initial label - * @deprecated use {@link #checkDirectEditInitialLabel(AtomicReference, Supplier, String)} instead. - */ - @Deprecated - public void checkDirectEditInitialLabel(Step verifier, AtomicReference diagram, Supplier labelId, String expectedLabel) { - verifier.then(this.createInitialLabelCheckRunnable(diagram, labelId, expectedLabel)); - } - /** * Creates a runnable that checks the initial direct edit label on a bordered node's outside label. * diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/testers/DirectEditTester.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/testers/DirectEditTester.java index e1b7e4b5f..adcc400d6 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/testers/DirectEditTester.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/testers/DirectEditTester.java @@ -13,29 +13,22 @@ package org.eclipse.syson.application.controllers.diagrams.testers; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.fail; import com.jayway.jsonpath.JsonPath; import java.util.Objects; -import java.util.Optional; import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; import java.util.function.Function; -import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload; import org.eclipse.sirius.components.collaborative.diagrams.dto.EditLabelInput; import org.eclipse.sirius.components.collaborative.diagrams.dto.EditLabelSuccessPayload; import org.eclipse.sirius.components.diagrams.Diagram; import org.eclipse.sirius.components.diagrams.InsideLabel; -import org.eclipse.sirius.components.diagrams.Label; import org.eclipse.sirius.components.diagrams.OutsideLabel; import org.eclipse.sirius.components.diagrams.tests.graphql.EditLabelMutationRunner; import org.eclipse.sirius.components.diagrams.tests.navigation.DiagramNavigator; -import reactor.test.StepVerifier.Step; - /** * Tester that checks the execution of a DirectEdit tool. * @@ -52,135 +45,6 @@ public DirectEditTester(EditLabelMutationRunner editLabelMutationRunner, String this.editingContextId = Objects.requireNonNull(editingContextId); } - /** - * Run a direct edit and check the resulting label for an {@link InsideLabel}. - * - * @param verifier - * the verifier - * @param diagram - * the diagram - * @param mainNodeId - * the id of the node holding the inside label - * @param inputLabel - * the input label to be used for the direct edit - * @param expectedInsideLabel - * the expected inside label - * @deprecated use {@link #directEditInsideLabel(AtomicReference, String, String)} instead. - */ - @Deprecated - public void checkDirectEditInsideLabel(Step verifier, AtomicReference diagram, String mainNodeId, String inputLabel, String expectedInsideLabel) { - Consumer checker = payload -> Optional.of(payload) - .map(DiagramRefreshedEventPayload::diagram) - .ifPresentOrElse(newDiagram -> { - DiagramNavigator diagramNavigator = new DiagramNavigator(newDiagram); - - InsideLabel newLabel = diagramNavigator.nodeWithId(mainNodeId).getNode().getInsideLabel(); - assertThat(newLabel.getText()).isEqualTo(expectedInsideLabel); - }, () -> fail("Missing diagram")); - - this.checkDirectEdit(verifier, diagram, inputLabel, d -> this.getInsideLabelId(mainNodeId, d), checker); - } - - /** - * Run a direct edit and check the resulting label for an {@link OutsideLabel} (only check the first one available). - * - * @param verifier - * the verifier - * @param diagram - * the diagram - * @param mainNodeId - * the id of the node holding the outside label - * @param inputLabel - * the input label to be used for the direct edit - * @param expectedOutsideLabel - * the expected outside label - * @deprecated use {@link #directEditOutsideLabel(AtomicReference, String, String)} instead. - */ - @Deprecated - public void checkDirectEditOutsideLabel(Step verifier, AtomicReference diagram, String mainNodeId, String inputLabel, String expectedOutsideLabel) { - Consumer checker = payload -> Optional.of(payload) - .map(DiagramRefreshedEventPayload::diagram) - .ifPresentOrElse(newDiagram -> { - DiagramNavigator diagramNavigator = new DiagramNavigator(newDiagram); - - OutsideLabel newLabel = diagramNavigator.nodeWithId(mainNodeId).getNode().getOutsideLabels().get(0); - assertThat(newLabel.text()).isEqualTo(expectedOutsideLabel); - }, () -> fail("Missing diagram")); - - this.checkDirectEdit(verifier, diagram, inputLabel, d -> this.getOutsideLabelId(mainNodeId, d), checker); - } - - /** - * Runs a direct edit and checks the resulting label for an edge centered label. - * - * @param verifier - * the verifier - * @param diagram - * the diagram - * @param edgeId - * the id of the edge holding the centered label - * @param inputLabel - * the input label to be used for the direct edit - * @param expectedCenteredLabel - * the expected centered label - * @deprecated use {@link #directEditCenteredEdgeLabel(AtomicReference, String, String)} instead. - */ - @Deprecated - public void checkDirectEditCenteredEdgeLabel(Step verifier, AtomicReference diagram, String edgeId, String inputLabel, - String expectedCenteredLabel) { - Consumer checker = payload -> Optional.of(payload) - .map(DiagramRefreshedEventPayload::diagram) - .ifPresentOrElse(newDiagram -> { - DiagramNavigator diagramNavigator = new DiagramNavigator(newDiagram); - - Label newLabel = diagramNavigator.edgeWithId(edgeId).getEdge().getCenterLabel(); - assertThat(newLabel.text()).isEqualTo(expectedCenteredLabel); - }, () -> fail("Missing diagram")); - this.checkDirectEdit(verifier, diagram, inputLabel, d -> this.getCenteredLabelId(edgeId, d), checker); - } - - /** - * Run a direct edit and check the resulting label for an {@link InsideLabel} (only check the first one available). - * - * @param verifier - * the verifier - * @param diagram - * the diagram - * @param mainNodeId - * the id of the node holding the inside label - * @param inputLabel - * the input label to be used for the direct edit - * @param checker - * a check to be done after the diagram re-render - * @deprecated use {@link #directEditInsideLabel(AtomicReference, String, String)} instead. - */ - @Deprecated - public void checkDirectEditInsideLabel(Step verifier, AtomicReference diagram, String mainNodeId, String inputLabel, - Consumer checker) { - this.checkDirectEdit(verifier, diagram, inputLabel, d -> this.getInsideLabelId(mainNodeId, d), checker); - } - - /** - * Run a direct edit and check the resulting label for an {@link OutsideLabel} (only check the first one available). - * - * @param verifier - * the verifier - * @param diagram - * the diagram - * @param mainNodeId - * the id of the node holding the outside label - * @param inputLabel - * the input label to be used for the direct edit - * @param checker - * a check to be done after the diagram re-render - * @deprecated use {@link #directEditOutsideLabel(AtomicReference, String, String)} instead. - */ - @Deprecated - public void checkDirectEditOutsideLabel(Step verifier, AtomicReference diagram, String mainNodeId, String inputLabel, - Consumer checker) { - this.checkDirectEdit(verifier, diagram, inputLabel, d -> this.getOutsideLabelId(mainNodeId, d), checker); - } - /** * Creates a runnable that executes a direct edit on an {@link InsideLabel}. * @@ -236,39 +100,6 @@ private Runnable createDirectEditRunnable(AtomicReference diagram, Stri }; } - /** - * Executes a direct edit mutation and chains the result verification to the provided verifier. - * - * @param verifier - * the {@link Step} verifier to chain the direct edit execution to - * @param diagram - * the diagram reference containing the label to edit - * @param inputLabel - * the new label value to set via direct edit - * @param labelIdProvider - * a function that retrieves the label ID from the diagram - * @param diagramConsumer - * a consumer to verify the diagram after the direct edit completes - * @deprecated use {@link #createDirectEditRunnable(AtomicReference, String, Function)} instead. - */ - @Deprecated - private void checkDirectEdit(Step verifier, AtomicReference diagram, String inputLabel, Function labelIdProvider, - Consumer diagramConsumer) { - Runnable requestDirectEdit = () -> { - - final String labelId = labelIdProvider.apply(diagram.get()); - - EditLabelInput input = new EditLabelInput(UUID.randomUUID(), this.editingContextId, diagram.get().getId(), labelId, inputLabel); - var result = this.editLabelMutationRunner.run(input); - - String typename = JsonPath.read(result.data(), "$.data.editLabel.__typename"); - assertThat(typename).isEqualTo(EditLabelSuccessPayload.class.getSimpleName()); - }; - - verifier.then(requestDirectEdit); - verifier.consumeNextWith(diagramConsumer); - } - private String getInsideLabelId(String mainNodeId, Diagram d) { DiagramNavigator diagramNavigator = new DiagramNavigator(d); return diagramNavigator.nodeWithId(mainNodeId).getNode().getInsideLabel().getId(); diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/services/diagrams/NodeCreationTestsService.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/services/diagrams/NodeCreationTestsService.java index 1dece7b61..e5b9ed6c1 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/services/diagrams/NodeCreationTestsService.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/services/diagrams/NodeCreationTestsService.java @@ -17,13 +17,11 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.emf.ecore.EClass; -import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload; import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolVariable; import org.eclipse.sirius.components.diagrams.Diagram; import org.eclipse.syson.application.controllers.diagrams.testers.ToolTester; import org.eclipse.syson.util.IDescriptionNameGenerator; -import reactor.test.StepVerifier.Step; /** * Service class for CreationTests classes. @@ -44,160 +42,6 @@ public NodeCreationTestsService(ToolTester nodeCreationTester, IDescriptionNameG this.descriptionNameGenerator = Objects.requireNonNull(descriptionNameGenerator); } - /** - * Creates a node using a creation tool. - * - * @param verifier - * the verifier to chain the node creation to - * @param diagramDescriptionIdProvider - * the diagram description ID provider - * @param diagram - * the diagram reference - * @param parentEClass - * the EClass of the parent node - * @param parentLabel - * the label of the parent node - * @param childEClass - * the EClass of the child node to create - * @deprecated use {@link #createNode(DiagramDescriptionIdProvider, AtomicReference, EClass, String, EClass)} instead. - */ - @Deprecated - public void createNode(Step verifier, DiagramDescriptionIdProvider diagramDescriptionIdProvider, - AtomicReference diagram, EClass parentEClass, String parentLabel, EClass childEClass) { - this.createNode(verifier, diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, childEClass, List.of()); - } - - /** - * Creates a node using a creation tool with variables. - * - * @param verifier - * the verifier to chain the node creation to - * @param diagramDescriptionIdProvider - * the diagram description ID provider - * @param diagram - * the diagram reference - * @param parentEClass - * the EClass of the parent node - * @param parentLabel - * the label of the parent node - * @param childEClass - * the EClass of the child node to create - * @param variables - * the tool variables - * @deprecated use {@link #createNode(DiagramDescriptionIdProvider, AtomicReference, EClass, String, EClass, List)} instead. - */ - @Deprecated - public void createNode(Step verifier, DiagramDescriptionIdProvider diagramDescriptionIdProvider, - AtomicReference diagram, EClass parentEClass, String parentLabel, EClass childEClass, List variables) { - this.createNode(verifier, diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, this.descriptionNameGenerator.getCreationToolName(childEClass), variables); - } - - /** - * Creates a node using a named tool. - * - * @param verifier - * the verifier to chain the node creation to - * @param diagramDescriptionIdProvider - * the diagram description ID provider - * @param diagram - * the diagram reference - * @param parentEClass - * the EClass of the parent node - * @param parentLabel - * the label of the parent node - * @param toolName - * the name of the creation tool - * @deprecated use {@link #createNode(DiagramDescriptionIdProvider, AtomicReference, EClass, String, String)} instead. - */ - @Deprecated - public void createNode(Step verifier, DiagramDescriptionIdProvider diagramDescriptionIdProvider, - AtomicReference diagram, EClass parentEClass, String parentLabel, String toolName) { - this.createNode(verifier, diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, toolName, List.of()); - } - - /** - * Creates a node using a named tool with variables. - * - * @param verifier - * the verifier to chain the node creation to - * @param diagramDescriptionIdProvider - * the diagram description ID provider - * @param diagram - * the diagram reference - * @param parentEClass - * the EClass of the parent node - * @param parentLabel - * the label of the parent node - * @param toolName - * the name of the creation tool - * @param variables - * the tool variables - * @deprecated use {@link #createNode(DiagramDescriptionIdProvider, AtomicReference, EClass, String, String, List)} instead. - */ - @Deprecated - public void createNode(Step verifier, DiagramDescriptionIdProvider diagramDescriptionIdProvider, - AtomicReference diagram, EClass parentEClass, String parentLabel, String toolName, List variables) { - String creationToolId = diagramDescriptionIdProvider.getNodeToolId(this.descriptionNameGenerator.getNodeName(parentEClass), toolName); - verifier.then(() -> this.toolTester.invokeTool(this.editingContextId, - diagram, - parentLabel, - creationToolId, - variables)); - } - - /** - * Creates a node on an edge using a named tool. - * - * @param verifier - * the verifier to chain the node creation to - * @param diagramDescriptionIdProvider - * the diagram description ID provider - * @param diagram - * the diagram reference - * @param parentEClass - * the EClass of the parent edge - * @param parentLabel - * the label of the parent edge - * @param toolName - * the name of the creation tool - * @deprecated use {@link #createNodeOnEdge(DiagramDescriptionIdProvider, AtomicReference, EClass, String, String)} instead. - */ - @Deprecated - public void createNodeOnEdge(Step verifier, DiagramDescriptionIdProvider diagramDescriptionIdProvider, - AtomicReference diagram, EClass parentEClass, String parentLabel, String toolName) { - this.createNodeOnEdge(verifier, diagramDescriptionIdProvider, diagram, parentEClass, parentLabel, toolName, List.of()); - } - - /** - * Creates a node on an edge using a named tool with variables. - * - * @param verifier - * the verifier to chain the node creation to - * @param diagramDescriptionIdProvider - * the diagram description ID provider - * @param diagram - * the diagram reference - * @param parentEClass - * the EClass of the parent edge - * @param parentLabel - * the label of the parent edge - * @param toolName - * the name of the creation tool - * @param variables - * the tool variables - * @deprecated use {@link #createNodeOnEdge(DiagramDescriptionIdProvider, AtomicReference, EClass, String, String, List)} instead. - */ - @Deprecated - public void createNodeOnEdge(Step verifier, DiagramDescriptionIdProvider diagramDescriptionIdProvider, - AtomicReference diagram, EClass parentEClass, String parentLabel, String toolName, List variables) { - String creationToolId = diagramDescriptionIdProvider.getNodeCreationToolIdOnEdge(this.descriptionNameGenerator.getEdgeName(parentEClass), toolName); - verifier.then(() -> this.toolTester.createNodeOnEdge(this.editingContextId, - diagram, - parentLabel, - creationToolId, - variables)); - } - /** * Creates a runnable that invokes a node creation tool. *