diff --git a/experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/FuncDSL.java b/experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/FuncDSL.java index 44bbad1e..f06d8d90 100644 --- a/experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/FuncDSL.java +++ b/experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/FuncDSL.java @@ -2213,6 +2213,18 @@ public static Consumer on( return DSL.all(filters); } + /** + * Creates an 'all' event consumption strategy using a specific event type string. + * + * @param eventType the event type + * @return a consumer configuring the event strategy builder + * @see DSL#all(Consumer[]) + */ + public static Consumer> allOfType( + String eventType) { + return DSL.all(DSL.event().type(eventType)); + } + /** * @see DSL#any(Consumer[]) */ diff --git a/experimental/fluent/func/src/test/java/io/serverlessworkflow/fluent/func/FuncDSLScheduleTest.java b/experimental/fluent/func/src/test/java/io/serverlessworkflow/fluent/func/FuncDSLScheduleTest.java index 9c2f98c4..0bfe8f8b 100644 --- a/experimental/fluent/func/src/test/java/io/serverlessworkflow/fluent/func/FuncDSLScheduleTest.java +++ b/experimental/fluent/func/src/test/java/io/serverlessworkflow/fluent/func/FuncDSLScheduleTest.java @@ -16,6 +16,7 @@ package io.serverlessworkflow.fluent.func; import static io.serverlessworkflow.fluent.func.dsl.FuncDSL.after; +import static io.serverlessworkflow.fluent.func.dsl.FuncDSL.allOfType; import static io.serverlessworkflow.fluent.func.dsl.FuncDSL.cron; import static io.serverlessworkflow.fluent.func.dsl.FuncDSL.every; import static io.serverlessworkflow.fluent.func.dsl.FuncDSL.on; @@ -124,4 +125,25 @@ void schedule_on_event_sets_schedule() { schedule.getOn().getOneEventConsumptionStrategy().getOne().getWith().getType(), "Event type should match"); } + + @Test + @DisplayName( + "schedule(on(allOfType(event))) configures an 'on' schedule with 'all' event consumption strategy") + void schedule_on_allOfType_event_sets_schedule() { + Workflow wf = + FuncWorkflowBuilder.workflow("schedule-on-allOfType-event") + .schedule(on(allOfType("org.acme.processing"))) + .build(); + + Schedule schedule = wf.getSchedule(); + assertNotNull(schedule, "Schedule should be configured"); + assertNotNull(schedule.getOn(), "On configuration should be set"); + assertNotNull( + schedule.getOn().getAllEventConsumptionStrategy(), + "All consumption strategy should be set"); + assertEquals( + "org.acme.processing", + schedule.getOn().getAllEventConsumptionStrategy().getAll().get(0).getWith().getType(), + "Event type should match in the filter"); + } }