Skip to content

Commit 45e4b48

Browse files
gcoutableAxelRICHARD
authored andcommitted
[cleanup] Reduce uses of deprecated (for removal) in tests
Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
1 parent 597e290 commit 45e4b48

26 files changed

Lines changed: 528 additions & 491 deletions

CHANGELOG.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
- [cleanup] The definition of the tools specific to the requirements table has been moved to the backend.
1010
As a result, the following GraphQL mutations have been removed `exposeRequirements` and `createRequirement`.
11+
- [test] Reduce our call to `DiagramNavigator#nodeWithTargetObjectLabel` which has been deprecated for removal.
12+
+ The API of `ToolTester#invokeTool` and `NodeCreationTestsService#createNode` has been updated accordingly to take a `targetObjectId` instead of a `label`.
1113

1214
=== Dependency update
1315

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/checkers/CheckBorderNode.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2025 Obeo.
2+
* Copyright (c) 2025, 2026 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -35,7 +35,7 @@ public class CheckBorderNode implements IDiagramChecker {
3535

3636
private final DiagramComparator diagramComparator;
3737

38-
private String parentLabel;
38+
private String parentTargetObjectId;
3939

4040
private String borderNodeDescriptionName;
4141

@@ -44,8 +44,8 @@ public CheckBorderNode(DiagramDescriptionIdProvider diagramDescriptionIdProvider
4444
this.diagramComparator = diagramComparator;
4545
}
4646

47-
public CheckBorderNode withParentLabel(String expectedParentLabel) {
48-
this.parentLabel = expectedParentLabel;
47+
public CheckBorderNode withParentTargetObjectId(String expectedParentTargetObjectId) {
48+
this.parentTargetObjectId = expectedParentTargetObjectId;
4949
return this;
5050
}
5151

@@ -58,7 +58,7 @@ public CheckBorderNode hasBorderNodeDescriptionName(String expectedBorderNodeDes
5858
public void check(Diagram previousDiagram, Diagram newDiagram) {
5959
List<Node> newNodes = this.diagramComparator.newNodes(previousDiagram, newDiagram);
6060
DiagramNavigator diagramNavigator = new DiagramNavigator(newDiagram);
61-
var parentNode = diagramNavigator.nodeWithTargetObjectLabel(this.parentLabel).getNode();
61+
var parentNode = diagramNavigator.nodeWithTargetObjectId(this.parentTargetObjectId).getNode();
6262
assertThat(parentNode.getBorderNodes()).anySatisfy(borderNode -> {
6363
String borderNodeDescriptionId = this.diagramDescriptionIdProvider.getNodeDescriptionId(this.borderNodeDescriptionName);
6464
assertThat(borderNode).hasDescriptionId(borderNodeDescriptionId);

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/checkers/CheckChildNode.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024, 2025 Obeo.
2+
* Copyright (c) 2024, 2026 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -35,7 +35,7 @@ public class CheckChildNode implements IDiagramChecker {
3535

3636
private final DiagramComparator diagramComparator;
3737

38-
private String parentLabel;
38+
private String parentTargetObjectId;
3939

4040
private String parentNodeId;
4141

@@ -48,8 +48,8 @@ public CheckChildNode(DiagramDescriptionIdProvider diagramDescriptionIdProvider,
4848
this.diagramComparator = Objects.requireNonNull(diagramComparator);
4949
}
5050

51-
public CheckChildNode withParentLabel(String expectedParentLabel) {
52-
this.parentLabel = expectedParentLabel;
51+
public CheckChildNode withParentTargetObjectId(String expectedParentTargetObjectId) {
52+
this.parentTargetObjectId = expectedParentTargetObjectId;
5353
return this;
5454
}
5555

@@ -76,7 +76,7 @@ public void check(Diagram previousDiagram, Diagram newDiagram) {
7676
if (this.parentNodeId != null) {
7777
parentNode = diagramNavigator.nodeWithId(this.parentNodeId).getNode();
7878
} else {
79-
parentNode = diagramNavigator.nodeWithTargetObjectLabel(this.parentLabel).getNode();
79+
parentNode = diagramNavigator.nodeWithTargetObjectId(this.parentTargetObjectId).getNode();
8080
}
8181
assertThat(parentNode).isNotNull();
8282
assertThat(parentNode.getChildNodes()).anySatisfy(childNode -> {

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/checkers/CheckNodeInCompartment.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024, 2025 Obeo.
2+
* Copyright (c) 2024, 2026 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -36,7 +36,7 @@ public class CheckNodeInCompartment implements IDiagramChecker {
3636

3737
private final DiagramComparator diagramComparator;
3838

39-
private String parentLabel;
39+
private String targetObjectId;
4040

4141
private String compartmentName;
4242

@@ -51,8 +51,8 @@ public CheckNodeInCompartment(DiagramDescriptionIdProvider diagramDescriptionIdP
5151
this.diagramComparator = diagramComparator;
5252
}
5353

54-
public CheckNodeInCompartment withParentLabel(String expectedParentLabel) {
55-
this.parentLabel = expectedParentLabel;
54+
public CheckNodeInCompartment withTargetObjectId(String expectedTargetObjectId) {
55+
this.targetObjectId = expectedTargetObjectId;
5656
return this;
5757
}
5858

@@ -80,7 +80,7 @@ public CheckNodeInCompartment isRevealed() {
8080
public void check(Diagram previousDiagram, Diagram newDiagram) {
8181
List<Node> newNodes = this.diagramComparator.newNodes(previousDiagram, newDiagram);
8282
DiagramNavigator diagramNavigator = new DiagramNavigator(newDiagram);
83-
var compartmentNode = diagramNavigator.nodeWithTargetObjectLabel(this.parentLabel)
83+
var compartmentNode = diagramNavigator.nodeWithTargetObjectId(this.targetObjectId)
8484
.childNodeWithLabel(this.compartmentName)
8585
.getNode();
8686
assertThat(compartmentNode.getChildNodes()).anySatisfy(childNode -> {

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/checkers/DiagramCheckerService.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public DiagramCheckerService(DiagramComparator diagramComparator, IDescriptionNa
5353
* the reference to the previous diagram state
5454
* @param diagramDescriptionIdProvider
5555
* the provider for diagram description IDs
56-
* @param parentLabel
57-
* the label of the parent node
56+
* @param parentTargetObjectId
57+
* the parent target object ID
5858
* @param childEClass
5959
* the EClass of the expected child node
6060
* @param compartmentCount
@@ -65,7 +65,7 @@ public DiagramCheckerService(DiagramComparator diagramComparator, IDescriptionNa
6565
* the expected total number of new border nodes
6666
* @return a consumer that performs the graphical check
6767
*/
68-
public Consumer<Object> childNodeGraphicalChecker(AtomicReference<Diagram> previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, String parentLabel, EClass childEClass,
68+
public Consumer<Object> childNodeGraphicalChecker(AtomicReference<Diagram> previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, String parentTargetObjectId, EClass childEClass,
6969
int compartmentCount, int newNodesCount, int newBorderNodesCount) {
7070
return assertRefreshedDiagramThat(newDiagram -> {
7171
new CheckDiagramElementCount(this.diagramComparator)
@@ -76,7 +76,7 @@ public Consumer<Object> childNodeGraphicalChecker(AtomicReference<Diagram> previ
7676

7777
String newNodeDescriptionName = this.descriptionNameGenerator.getNodeName(childEClass);
7878
new CheckChildNode(diagramDescriptionIdProvider, this.diagramComparator)
79-
.withParentLabel(parentLabel)
79+
.withParentTargetObjectId(parentTargetObjectId)
8080
.hasNodeDescriptionName(newNodeDescriptionName)
8181
.hasCompartmentCount(compartmentCount)
8282
.check(previousDiagram.get(), newDiagram);
@@ -90,8 +90,8 @@ public Consumer<Object> childNodeGraphicalChecker(AtomicReference<Diagram> previ
9090
* the reference to the previous diagram state
9191
* @param diagramDescriptionIdProvider
9292
* the provider for diagram description IDs
93-
* @param parentLabel
94-
* the label of the parent node
93+
* @param parentTargetObjectId
94+
* the parent target object ID
9595
* @param parentEClass
9696
* the EClass of the parent node
9797
* @param containmentReference
@@ -102,7 +102,7 @@ public Consumer<Object> childNodeGraphicalChecker(AtomicReference<Diagram> previ
102102
* check only new nodes and edges that are visible on the diagram
103103
* @return a consumer that performs the graphical check
104104
*/
105-
public Consumer<Object> compartmentNodeGraphicalChecker(AtomicReference<Diagram> previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, String parentLabel,
105+
public Consumer<Object> compartmentNodeGraphicalChecker(AtomicReference<Diagram> previousDiagram, DiagramDescriptionIdProvider diagramDescriptionIdProvider, String parentTargetObjectId,
106106
EClass parentEClass, EReference containmentReference, String compartmentName, boolean onlyNewVisibleNodesAndEdges) {
107107
return assertRefreshedDiagramThat(newDiagram -> {
108108
new CheckDiagramElementCount(this.diagramComparator)
@@ -112,7 +112,7 @@ public Consumer<Object> compartmentNodeGraphicalChecker(AtomicReference<Diagram>
112112

113113
String newNodeDescriptionName = this.descriptionNameGenerator.getCompartmentItemName(parentEClass, containmentReference);
114114
new CheckNodeInCompartment(diagramDescriptionIdProvider, this.diagramComparator)
115-
.withParentLabel(parentLabel)
115+
.withTargetObjectId(parentTargetObjectId)
116116
.withCompartmentName(compartmentName)
117117
.hasNodeDescriptionName(newNodeDescriptionName)
118118
.hasCompartmentCount(0)

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/compartments/ActionTransitionUsagesTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.eclipse.sirius.components.view.emf.diagram.IDiagramIdProvider;
3131
import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState;
3232
import org.eclipse.syson.AbstractIntegrationTests;
33+
import org.eclipse.syson.GivenSysONServer;
3334
import org.eclipse.syson.application.controllers.diagrams.testers.ToolTester;
3435
import org.eclipse.syson.application.data.ActionTransitionUsagesProjectData;
3536
import org.eclipse.syson.services.diagrams.DiagramDescriptionIdProvider;
@@ -47,8 +48,6 @@
4748
import org.junit.jupiter.api.Test;
4849
import org.springframework.beans.factory.annotation.Autowired;
4950
import org.springframework.boot.test.context.SpringBootTest;
50-
import org.springframework.test.context.jdbc.Sql;
51-
import org.springframework.test.context.jdbc.SqlConfig;
5251
import org.springframework.test.context.transaction.TestTransaction;
5352
import org.springframework.transaction.annotation.Transactional;
5453

@@ -114,10 +113,8 @@ public void tearDown() {
114113
}
115114
}
116115

117-
@Sql(scripts = { ActionTransitionUsagesProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
118-
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
119-
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
120116
@DisplayName("GIVEN a model with TransitionUsage ending on 'start' or 'done' ActionUsage, WHEN adding existing nested element on the parent of the TransitionUsage, THEN the 'start' and 'done' node should be added to the ActionFlow compartment.")
117+
@GivenSysONServer({ ActionTransitionUsagesProjectData.SCRIPT_PATH })
121118
@Test
122119
public void addExistingNestedElementsOnActionUsage() {
123120
TestTransaction.flagForCommit();
@@ -126,7 +123,7 @@ public void addExistingNestedElementsOnActionUsage() {
126123
"Add existing nested elements");
127124
assertThat(toolId).as("The tool 'Add existing elements' should exist on Action Usage").isNotNull();
128125

129-
this.verifier.then(() -> this.nodeCreationTester.invokeTool(ActionTransitionUsagesProjectData.EDITING_CONTEXT_ID, this.diagram, "a0", toolId));
126+
this.verifier.then(() -> this.nodeCreationTester.invokeTool(ActionTransitionUsagesProjectData.EDITING_CONTEXT_ID, this.diagram, ActionTransitionUsagesProjectData.SemanticIds.A0_ID, toolId));
130127

131128
Consumer<DiagramRefreshedEventPayload> updatedDiagramConsumer = payload -> Optional.of(payload)
132129
.map(DiagramRefreshedEventPayload::diagram)

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/compartments/StartActionTests.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2025 Obeo.
2+
* Copyright (c) 2025, 2026 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -28,6 +28,7 @@
2828
import org.eclipse.sirius.components.view.emf.diagram.IDiagramIdProvider;
2929
import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState;
3030
import org.eclipse.syson.AbstractIntegrationTests;
31+
import org.eclipse.syson.GivenSysONServer;
3132
import org.eclipse.syson.application.controllers.diagrams.testers.ToolTester;
3233
import org.eclipse.syson.application.data.GeneralViewWithTopNodesTestProjectData;
3334
import org.eclipse.syson.services.diagrams.DiagramDescriptionIdProvider;
@@ -43,8 +44,6 @@
4344
import org.junit.jupiter.api.Test;
4445
import org.springframework.beans.factory.annotation.Autowired;
4546
import org.springframework.boot.test.context.SpringBootTest;
46-
import org.springframework.test.context.jdbc.Sql;
47-
import org.springframework.test.context.jdbc.SqlConfig;
4847
import org.springframework.transaction.annotation.Transactional;
4948

5049
import reactor.core.publisher.Flux;
@@ -92,9 +91,7 @@ public void beforeEach() {
9291
}
9392

9493
@DisplayName("GIVEN an ActionUsage action1, WHEN using the 'New Start Action' tool is executed on action1, THEN the action flow compartment of action1 is revealed.")
95-
@Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
96-
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
97-
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
94+
@GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH })
9895
@Test
9996
public void addStartNode() {
10097
var flux = this.givenSubscriptionToDiagram();
@@ -117,7 +114,7 @@ public void addStartNode() {
117114
});
118115

119116
Runnable invokeTool = () -> {
120-
this.nodeCreationTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagram, "action", toolId);
117+
this.nodeCreationTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagram, GeneralViewWithTopNodesTestProjectData.SemanticIds.ACTION_USAGE_ID, toolId);
121118
};
122119

123120
Consumer<Object> updatedDiagramConsumer = assertRefreshedDiagramThat(diag -> {

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVActionDefinitionParameterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private void checkItemParameterOnActionDefinition() {
120120

121121
Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set);
122122

123-
Runnable newCreationTool = () -> this.nodeCreationTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagram, "UseCaseDefinition", creationToolId, variables);
123+
Runnable newCreationTool = () -> this.nodeCreationTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagram, GeneralViewWithTopNodesTestProjectData.SemanticIds.USE_CASE_DEFINITION_ID, creationToolId, variables);
124124

125125
Consumer<Object> updatedDiagramConsumer = assertRefreshedDiagramThat(newDiagram -> {
126126
new CheckDiagramElementCount(this.diagramComparator)

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVAddNewExhibitStateWithReferencedStateFromPartsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void testApplyNewExhibitStateWithReferencedStateToolFromPartUsage() {
127127
String creationToolId = diagramDescriptionIdProvider.getNodeToolId(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getPartUsage()), "New Exhibit State with referenced State");
128128
assertThat(creationToolId).as("The tool 'New Exhibit State with referenced State' should exist on a PartUsage").isNotNull();
129129

130-
Runnable invokeTool = () -> this.nodeCreationTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagram, "part", creationToolId,
130+
Runnable invokeTool = () -> this.nodeCreationTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagram, GeneralViewWithTopNodesTestProjectData.SemanticIds.PART_USAGE_ID, creationToolId,
131131
List.of(new ToolVariable("selectedObject", GeneralViewWithTopNodesTestProjectData.SemanticIds.STATE_USAGE_ID, ToolVariableType.OBJECT_ID)));
132132

133133
String[] newExhibitStateId = new String[1];

0 commit comments

Comments
 (0)