feat: support to subflows on the Java DSL#1213
feat: support to subflows on the Java DSL#1213matheusandre1 wants to merge 4 commits intoserverlessworkflow:mainfrom
Conversation
ac6bdf9 to
98a4bf7
Compare
3f75faa to
8a790b2
Compare
mcruzdev
left a comment
There was a problem hiding this comment.
It looks great @matheusandre1, could you add a test running a workflow with your changes?
Signed-off-by: Matheus André <92062874+matheusandre1@users.noreply.github.com>
e118bae to
c9388bf
Compare
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/dsl/WorkflowSpec.java
Show resolved
Hide resolved
ricardozanini
left a comment
There was a problem hiding this comment.
Looks solid, we just need to add the Function to the input or it's useless for the FuncDSL (unless jq scripting).
@ricardozanini The Function should be located at the experimental module, I think it can be another PR. |
ricardozanini
left a comment
There was a problem hiding this comment.
Indeed, the Function can be added to a new PR - or directly to this one. Not sure why not. I do the DSL changes in both sides all the time since one influence the other.
|
@mcruzdev aproove? |
|
Hi @matheusandre1, when a said test I would like something like Executing the new DSL method with a WorkflowApplication: try (WorkflowApplication app = WorkflowApplication.builder().build()) {
WorkflowDefinition def = app.workflowDefinition(workflow);
WorkflowModel model = def.instance(10L).start().join();
Number number = model.asNumber().orElseThrow();
softly.assertThat(number.longValue()).isEqualTo(25L);
}The test you added is so good, but I think we need to test executing too. |
|
I'm going to do it. |
90e72b7 to
37add85
Compare
| Workflow workflow = | ||
| FuncWorkflowBuilder.workflow("enrichOutputWithTaskOutputTest") | ||
| .tasks( | ||
| function( |
There was a problem hiding this comment.
Hi @matheusandre1, it is close. You need to test what you added here. Instead use the enrichOutputWithTaskTest workflow use that one you added on testDoTaskRunWorkflow test:
Workflow wf =
WorkflowBuilder.workflow("parentFlow")
.tasks(
d ->
d.workflow(
"runChild",
w ->
w.namespace("org.acme")
.name("childFlow")
.version("1.0.0")
.input(Map.of("id", 42, "region", "us-east"))
.await(false)
.returnType(RunTaskConfiguration.ProcessReturnType.NONE)))
.build();Signed-off-by: Matheus André Galvão Da Silva <matheusandr2@gmail.com>
37add85 to
b607231
Compare
...ava/io/serverless/workflow/impl/executors/func/FuncDSLDataFlowTransformationHelpersTest.java
Outdated
Show resolved
Hide resolved
...ava/io/serverless/workflow/impl/executors/func/FuncDSLDataFlowTransformationHelpersTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Matheus André Galvão Da Silva <matheusandr2@gmail.com>
9002a5e to
de80b45
Compare
| } catch (Exception e) { | ||
| throw new RuntimeException("Workflow execution failed", e); | ||
| } |
There was a problem hiding this comment.
You can remove that catch and use join rather than get
In any case, rather than catching and trowing runtime, you can declara that the test function throw any checked exception that might be raised by the code within the function
There was a problem hiding this comment.
ok, understand, thank you
| assertEquals("1", result.get("counter").toString()); | ||
| assertEquals("helloWorld", result.get("greeting").toString()); |
There was a problem hiding this comment.
you can change to assertThat() and remove the call toString
Many thanks for submitting your Pull Request ❤️!
What this PR does / why we need it:
Closes: #1151
Special notes for reviewers:
Additional information (if needed):