Conversation
There was a problem hiding this comment.
Pull request overview
Enhances the fluent workflow DSL to allow creating task configurers with explicit task names (instead of auto-generated UUIDs), improving readability and enabling use of reserved/duplicate names in workflow definitions.
Changes:
- Added
DSLoverloads for major task types to accept an explicitnameparameter (e.g.,set(name, ...),call(name, ...),emit(name, ...), etc.). - Updated/expanded
WorkflowBuilderTestto validate explicitly named tasks, including naming a task"set"and verifying multiple task types can be named.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/dsl/DSL.java | Adds named overloads for task factory helpers returning TasksConfigurer. |
| fluent/spec/src/test/java/io/serverlessworkflow/fluent/spec/WorkflowBuilderTest.java | Adds tests exercising named-task DSL usage and validating task names/types in the built workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * Create a {@link TasksConfigurer} that adds an OpenAPI call task with an explicit name. | ||
| * | ||
| * @param name the task name | ||
| * @param configurer OpenAPI configurer | ||
| * @return a {@link TasksConfigurer} that adds a CallOpenAPI task | ||
| */ | ||
| public static TasksConfigurer call(String name, CallOpenAPIConfigurer configurer) { | ||
| return list -> list.openapi(name, configurer); | ||
| } |
There was a problem hiding this comment.
The new overload call(String name, CallOpenAPIConfigurer) isn’t exercised by the test suite (current tests cover only the HTTP variant). Add a unit test that builds a workflow using call("name", openapi()...) and asserts the TaskItem name and that CallTask.callOpenAPI is present/configured, to prevent regressions in this overload.
fjtirado
left a comment
There was a problem hiding this comment.
@ricardozanini This adds the possibility of setting the task name through the dsl, but I think we also need to generate a consistent task name rathern than a random one when the user does not specify one.
I propose to use "taskType"+autoIncrementId, where the counter start at for every new defitinion, this way, the task name will always be the same if the definition is unchanged
Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/dsl/DSL.java:699
- The Javadoc for
emit(Consumer<EmitTaskBuilder>)has stray*characters at the ends of sentences (e.g., "using a custom configurer. *" and similar). This renders poorly and may trigger Javadoc lint warnings; please remove the trailing*characters so the comment is valid Javadoc.
/**
* Adds an {@code emit} task to the workflow's task sequence using a custom configurer. *
*
* <p>This method is typically used in conjunction with {@link #produced()} to fluently define the
* properties of the event being emitted. *
*
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| d -> | ||
| d.set("set", "$.value = 'test'").set("set", s -> s.expr("$.another = 'value'"))) |
There was a problem hiding this comment.
testTaskNamedSet() is described as verifying naming via the DSL, but it only uses the DoTaskBuilder#set(String, ...) instance methods (which already support explicit names). To specifically cover this PR’s new DSL overloads, consider either rewriting this test to use the static DSL.set("set", ...) helpers (like the next test does) or removing/renaming it to avoid redundant coverage.
| d -> | |
| d.set("set", "$.value = 'test'").set("set", s -> s.expr("$.another = 'value'"))) | |
| doTasks( | |
| set("set", "$.value = 'test'"), | |
| set("set", s -> s.expr("$.another = 'value'")))) |
This pull request enhances the Serverless Workflow fluent DSL by adding support for assigning explicit names to all major task types, improving clarity and flexibility when building workflows. It introduces new overloaded static methods in the
DSLclass to allow specifying task names, and adds comprehensive tests to ensure these features work as intended.DSL Enhancements for Named Tasks:
Added overloaded static methods in
DSL.javafor all major task types (call,set,emit,listen,forEach,fork,switchCase,raise,tryCatch) to allow specifying explicit task names when building workflows. These methods improve the expressiveness and maintainability of workflow definitions. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]Restored and documented the
emit(String, Consumer<EmitTaskBuilder>)method inDSL.javato match the new naming pattern for consistency.Testing Improvements:
WorkflowBuilderTest.javato verify that tasks can be named (including using reserved words like"set"), and to check that all task types accept and correctly handle explicit names via the DSL.WorkflowBuilderTest.javato cover the newly overloaded DSL methods, improving test readability and maintainability.