Skip to content

Commit 359b339

Browse files
flatombeAxelRICHARD
authored andcommitted
[tests] Fix JavaServiceIsCalledChecker not collecting all AQL expression
Bug: #960 Signed-off-by: Florent Latombe <florent.latombe@obeo.fr>
1 parent b440e66 commit 359b339

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

backend/application/syson-application/src/test/java/org/eclipse/syson/JavaServiceIsCalledChecker.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024 Obeo.
2+
* Copyright (c) 2024, 2025 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
@@ -107,11 +107,9 @@ private Collection<String> collectAQLExpressionsInDiagramDescription(DiagramDesc
107107

108108
expressions.add(diagramDescription.getPreconditionExpression());
109109

110-
List<Tool> diagramTools = Optional.ofNullable(diagramDescription.getPalette()).stream()
111-
.flatMap(palette -> EMFUtils.allContainedObjectOfType(palette, Tool.class))
112-
.toList();
110+
final List<Tool> allDiagramTools = EMFUtils.allContainedObjectOfType(diagramDescription, Tool.class).toList();
113111

114-
for (Tool diagramTool : diagramTools) {
112+
for (Tool diagramTool : allDiagramTools) {
115113
expressions.add(diagramTool.getPreconditionExpression());
116114
for (Operation bodyOperation : diagramTool.getBody()) {
117115
EMFUtils.allContainedObjectOfType(bodyOperation, ChangeContext.class)
@@ -210,11 +208,9 @@ private Collection<String> collectAQLExpressionsInEdgeDescription(EdgeDescriptio
210208
Optional.ofNullable(edgeDescription.getPreconditionExpression())
211209
.map(expressions::add);
212210

213-
List<Tool> edgeTools = Optional.ofNullable(edgeDescription.getPalette()).stream()
214-
.flatMap(palette -> EMFUtils.allContainedObjectOfType(palette, Tool.class))
215-
.toList();
211+
final List<Tool> allEdgeTools = EMFUtils.allContainedObjectOfType(edgeDescription, Tool.class).toList();
216212

217-
for (Tool edgeTool : edgeTools) {
213+
for (Tool edgeTool : allEdgeTools) {
218214
expressions.add(edgeTool.getPreconditionExpression());
219215
if (edgeTool instanceof LabelEditTool labelEditTool) {
220216
expressions.add(labelEditTool.getInitialDirectEditLabelExpression());

backend/metamodel/syson-sysml-metamodel/src/main/java/org/eclipse/syson/sysml/helper/EMFUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ public static Stream<Notifier> eAllContentSteamWithSelf(ResourceSet rs) {
168168
*/
169169
public static <T extends EObject> Stream<T> allContainedObjectOfType(Notifier self, Class<T> type) {
170170
final Stream<T> result;
171-
if (self instanceof EObject) {
172-
result = eAllContentStreamWithSelf((EObject) self).filter(e -> type.isInstance(e)).map(e -> type.cast(e));
173-
} else if (self instanceof Resource) {
174-
result = eAllContentSteamWithSelf((Resource) self).filter(e -> type.isInstance(e)).map(e -> type.cast(e));
175-
} else if (self instanceof ResourceSet) {
176-
result = eAllContentSteamWithSelf((ResourceSet) self).filter(e -> type.isInstance(e))
171+
if (self instanceof EObject eObject) {
172+
result = eAllContentStreamWithSelf(eObject).filter(e -> type.isInstance(e)).map(e -> type.cast(e));
173+
} else if (self instanceof Resource resource) {
174+
result = eAllContentSteamWithSelf(resource).filter(e -> type.isInstance(e)).map(e -> type.cast(e));
175+
} else if (self instanceof ResourceSet resourceSet) {
176+
result = eAllContentSteamWithSelf(resourceSet).filter(e -> type.isInstance(e))
177177
.map(e -> type.cast(e));
178178
} else {
179179
result = Stream.empty();

0 commit comments

Comments
 (0)