-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[KOGITO-7924] ForEach working with WorkItemHandler #2465
Conversation
0c8a6e0
to
9f0c19c
Compare
9f0c19c
to
be58769
Compare
e512f66
to
9a8fb2d
Compare
@@ -107,4 +114,31 @@ public static Optional<String> fallbackVarToName(String expr) { | |||
int indexOf = expr.lastIndexOf('.'); | |||
return indexOf < 0 ? Optional.empty() : Optional.of(expr.substring(indexOf + 1)); | |||
} | |||
|
|||
public static JsonNode addVariablesFromContext(JsonNode context, KogitoProcessContext processInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, it will be better to rather than cloning and adding the engine variables to the model being evaluated, for JQ and JsonPath to read variable value from the process instance,. if needed by the expression.
There are two problems though:
- Jq library we are using does not support that, see Change scope constructor from private to protected eiiches/jackson-jq#221
- The spec example treats the loop variable as it was part of the workflow model. This is not really true, because it should not be visible. So rather than
.item
the expression should look$item
See ForEach item loop variable usage in expression serverlessworkflow/specification#682
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I just left 2 nitpicking comments.
...s-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/VariableInfo.java
Outdated
Show resolved
Hide resolved
...-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/ForEachRestIT.java
Outdated
Show resolved
Hide resolved
Although not strictly related with this issue, I moved to draft because I want to add more test (in particular action data filter, I want to stress for each and I think is a good chance) |
Update quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/ForEachRestIT.java Co-authored-by: Helber Belmiro <[email protected]> Update kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/VariableInfo.java Co-authored-by: Helber Belmiro <[email protected]>
4529897
to
d823f76
Compare
"divisor" : ".divisor" | ||
} | ||
}, | ||
"actionDataFilter" : { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing an actionDataFilter.
Only results manipulation make sense inside a foreach loop (result are kept in loop variable)
(tests) - kogito-runtimes job Test results:
Those are the test failures: org.kie.kogito.quarkus.workflows.ExpressionRestFromImageIT.testExpressionRestjava.lang.AssertionError:1 expectation failed. Expected status code <201> but was <500>. at org.kie.kogito.quarkus.workflows.ExpressionRestFromImageIT.testExpressionRest(ExpressionRestFromImageIT.java:39) org.kie.kogito.quarkus.workflows.ExpressionRestIT.testExpressionRestjava.lang.AssertionError:1 expectation failed. Expected status code <201> but was <500>. at org.kie.kogito.quarkus.workflows.ExpressionRestIT.testExpressionRest(ExpressionRestIT.java:40) |
d823f76
to
11e2d27
Compare
SonarCloud Quality Gate failed. |
ForEach was only working with ActionNodes. This change will allow it to work with any NodeInstance (in theory), In practise, we have either WorkItemNode or ActionNode and this is the scenario a test was added for.