Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ private SELF appendDo(Consumer<DBuilder> configurer) {
configurer.accept(doBuilder);

final List<TaskItem> newItems = doBuilder.build().getDo();
if (newItems == null || newItems.isEmpty()) return self();
if (newItems == null || newItems.isEmpty()) {
throw new IllegalStateException(
"Task list must contain at least one task. "
+ "Use .tasks(d -> d.set(...)) or similar to define tasks.");
}
Comment on lines +139 to +143

final List<TaskItem> merged =
new ArrayList<>(this.workflow.getDo() != null ? this.workflow.getDo() : List.of());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import io.serverlessworkflow.api.types.AuthenticationPolicyUnion;
Expand Down Expand Up @@ -112,6 +113,17 @@ void testUseAuthenticationsBasic() {
assertNotNull(union.getBasicAuthenticationPolicy(), "BasicAuthenticationPolicy should be set");
}

@Test
void testEmptyTasksThrows() {
assertThrows(IllegalStateException.class, () -> WorkflowBuilder.workflow().tasks().build());
}

@Test
void testEmptyTasksConsumerThrows() {
assertThrows(
IllegalStateException.class, () -> WorkflowBuilder.workflow().tasks(d -> {}).build());
}

@Test
void testDoTaskSetAndForEach() {
Workflow wf =
Expand Down
Loading