Skip to content

feat: support to subflows on the Java DSL#1213

Open
matheusandre1 wants to merge 3 commits intoserverlessworkflow:mainfrom
matheusandre1:issue-1151
Open

feat: support to subflows on the Java DSL#1213
matheusandre1 wants to merge 3 commits intoserverlessworkflow:mainfrom
matheusandre1:issue-1151

Conversation

@matheusandre1
Copy link

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):

@matheusandre1 matheusandre1 marked this pull request as ready for review March 7, 2026 01:01
@matheusandre1 matheusandre1 requested a review from fjtirado as a code owner March 7, 2026 01:01
Copilot AI review requested due to automatic review settings March 7, 2026 01:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copy link
Collaborator

@mcruzdev mcruzdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great @matheusandre1, could you add a test running a workflow with your changes?

Copilot AI review requested due to automatic review settings March 10, 2026 22:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copy link
Member

@ricardozanini ricardozanini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid, we just need to add the Function to the input or it's useless for the FuncDSL (unless jq scripting).

@fjtirado
Copy link
Collaborator

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.

Copy link
Member

@ricardozanini ricardozanini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@matheusandre1
Copy link
Author

@mcruzdev aproove?

@mcruzdev
Copy link
Collaborator

mcruzdev commented Mar 23, 2026

Hi @matheusandre1, when a said test I would like something like FuncDSLDataFlowTransformationHelpersTest#test_input_with_outputAs.

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.

Copilot AI review requested due to automatic review settings March 23, 2026 19:49
@matheusandre1
Copy link
Author

I'm going to do it.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Workflow workflow =
FuncWorkflowBuilder.workflow("enrichOutputWithTaskOutputTest")
.tasks(
function(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 <[email protected]>
Copilot AI review requested due to automatic review settings March 23, 2026 22:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@fjtirado fjtirado requested a review from mcruzdev March 24, 2026 08:12
Long.class)
.outputAs(
(object, workflowContext, taskContextData) -> {
Long taskOutput = output(taskContextData, Long.class);
Copy link
Collaborator

@fjtirado fjtirado Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually the object passed to the task is the task ouput, so you should write (Long taskOutput, worlflowContext, taskContextData) and avoid the call to output(taskContextData, Long.class);`
@mcruzdev please make sure the usage docs CLEARLY reflec this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation update makes sense, we can do it in another pull request.

I think we need to remove this test, it is duplicated, there is another test that do the same thing in the codebase (@matheusandre1 please remove it).

(object, workflowContext, taskContextData) -> {
Long taskOutput = output(taskContextData, Long.class);
softly.assertThat(taskOutput).isEqualTo(15L);
Long input = input(workflowContext, Long.class);
Copy link
Collaborator

@fjtirado fjtirado Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, althoug kind of weird, but I guess make sense in a test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support to subflows on the Java DSL

5 participants