diff --git a/api/pom.xml b/api/pom.xml
index 429313935..55bb6964c 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -11,10 +11,7 @@
Open Workflow :: API
jar
Java SDK for Open Workflow Specification
-
- 3.6.2
-
-
+
org.openworkflow.sdk
@@ -102,7 +99,6 @@
org.codehaus.mojo
build-helper-maven-plugin
- ${version.build-helper-maven-plugin}
add-mixin
diff --git a/api/src/main/java/org/openworkflow/sdk/api/ObjectMapperFactory.java b/api/src/main/java/org/openworkflow/sdk/api/ObjectMapperFactory.java
index 82922112a..36a8f038d 100644
--- a/api/src/main/java/org/openworkflow/sdk/api/ObjectMapperFactory.java
+++ b/api/src/main/java/org/openworkflow/sdk/api/ObjectMapperFactory.java
@@ -66,10 +66,9 @@ private static > T configu
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
.disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
.addModule(validationModule)
- .changeDefaultPropertyInclusion(
- v ->
- v.withValueInclusion(JsonInclude.Include.NON_NULL)
- .withContentInclusion(JsonInclude.Include.NON_NULL))
+ .changeDefaultPropertyInclusion(v ->
+ v.withValueInclusion(JsonInclude.Include.NON_NULL)
+ .withContentInclusion(JsonInclude.Include.NON_NULL))
.addModule(new JacksonMixInModule())
.findAndAddModules();
}
diff --git a/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/BaseWorkflowBuilder.java b/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/BaseWorkflowBuilder.java
index cc55e4b3a..fac13e771 100644
--- a/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/BaseWorkflowBuilder.java
+++ b/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/BaseWorkflowBuilder.java
@@ -102,10 +102,9 @@ public final SELF use(Consumer... configurers) {
private SELF use(List> configurers) {
final UseBuilder builder = new UseBuilder();
- configurers.forEach(
- c -> {
- if (c != null) c.accept(builder);
- });
+ configurers.forEach(c -> {
+ if (c != null) c.accept(builder);
+ });
this.workflow.setUse(builder.build());
return self();
}
diff --git a/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/AbstractEventFilterSpec.java b/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/AbstractEventFilterSpec.java
index df23b92d0..2f3524fda 100644
--- a/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/AbstractEventFilterSpec.java
+++ b/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/AbstractEventFilterSpec.java
@@ -50,10 +50,9 @@ public SELF correlate(
@Override
public void accept(EVENT_FILTER filterBuilder) {
- filterBuilder.with(
- pb -> {
- getPropertySteps().forEach(step -> step.accept(pb));
- });
+ filterBuilder.with(pb -> {
+ getPropertySteps().forEach(step -> step.accept(pb));
+ });
filterSteps.forEach(step -> step.accept(filterBuilder));
}
diff --git a/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/CallHttpSpec.java b/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/CallHttpSpec.java
index 40fbd6ea8..960ffa521 100644
--- a/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/CallHttpSpec.java
+++ b/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/CallHttpSpec.java
@@ -47,15 +47,14 @@ public void accept(CallHttpTaskBuilder builder) {
@Override
public CallHttpSpec andThen(Consumer super CallHttpTaskBuilder> after) {
Objects.requireNonNull(after, "after");
- steps.add(
- fluent -> {
- if (!(fluent instanceof CallHttpTaskBuilder builder)) {
- throw new IllegalArgumentException(
- "andThen requires CallHttpTaskBuilder, got: "
- + (fluent == null ? "null" : fluent.getClass().getName()));
- }
- after.accept(builder);
- });
+ steps.add(fluent -> {
+ if (!(fluent instanceof CallHttpTaskBuilder builder)) {
+ throw new IllegalArgumentException(
+ "andThen requires CallHttpTaskBuilder, got: "
+ + (fluent == null ? "null" : fluent.getClass().getName()));
+ }
+ after.accept(builder);
+ });
return this;
}
}
diff --git a/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/DSL.java b/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/DSL.java
index d0795dfb4..12a9fad36 100644
--- a/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/DSL.java
+++ b/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/DSL.java
@@ -432,11 +432,8 @@ public static AuthenticationConfigurer oidc(
String clientId,
String clientSecret) {
return a ->
- a.openIDConnect(
- o ->
- o.authority(authority)
- .grant(grant)
- .client(c -> c.id(clientId).secret(clientSecret)));
+ a.openIDConnect(o ->
+ o.authority(authority).grant(grant).client(c -> c.id(clientId).secret(clientSecret)));
}
public static AuthenticationConfigurer oidc(String secret) {
@@ -472,11 +469,8 @@ public static AuthenticationConfigurer oauth2(
String clientId,
String clientSecret) {
return a ->
- a.openIDConnect(
- o ->
- o.authority(authority)
- .grant(grant)
- .client(c -> c.id(clientId).secret(clientSecret)));
+ a.openIDConnect(o ->
+ o.authority(authority).grant(grant).client(c -> c.id(clientId).secret(clientSecret)));
}
public static AuthenticationConfigurer oauth2(String secret) {
@@ -514,11 +508,10 @@ public static AuthenticationConfigurer oauth2(
String clientSecret,
Consumer endpoints) {
return a ->
- a.oauth2(
- o -> {
- o.authority(authority).grant(grant).client(c -> c.id(clientId).secret(clientSecret));
- o.endpoints(endpoints);
- });
+ a.oauth2(o -> {
+ o.authority(authority).grant(grant).client(c -> c.id(clientId).secret(clientSecret));
+ o.endpoints(endpoints);
+ });
}
/**
diff --git a/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/RaiseSpec.java b/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/RaiseSpec.java
index 6bf81532a..4d92b402b 100644
--- a/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/RaiseSpec.java
+++ b/fluent/spec/src/main/java/org/openworkflow/sdk/fluent/spec/dsl/RaiseSpec.java
@@ -58,9 +58,8 @@ public RaiseSpec then(Consumer step) {
@Override
public void accept(RaiseTaskBuilder b) {
- b.error(
- err -> {
- for (var s : steps) s.accept(err);
- });
+ b.error(err -> {
+ for (var s : steps) s.accept(err);
+ });
}
}
diff --git a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/TaskItemDefaultNamingTest.java b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/TaskItemDefaultNamingTest.java
index 6ba2f08d9..eb67ad01e 100644
--- a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/TaskItemDefaultNamingTest.java
+++ b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/TaskItemDefaultNamingTest.java
@@ -69,16 +69,14 @@ void testTopLevelDoListAutoNaming() {
void testNestedTryCatchTaskAutoNaming() {
Workflow wf =
WorkflowBuilder.workflow("flowAutoNameTryCatch")
- .tasks(
- d ->
- d.tryCatch(
- null,
- t ->
- t.tryHandler(
- tb ->
- tb.set(null, s -> s.expr("$.start = true"))
- .http(null, http().get().endpoint("http://test"))
- .set(null, s -> s.expr("$.end = true")))))
+ .tasks(d ->
+ d.tryCatch(
+ null,
+ t ->
+ t.tryHandler(tb ->
+ tb.set(null, s -> s.expr("$.start = true"))
+ .http(null, http().get().endpoint("http://test"))
+ .set(null, s -> s.expr("$.end = true")))))
.build();
List topItems = wf.getDo();
@@ -102,18 +100,16 @@ void testNestedTryCatchTaskAutoNaming() {
void testNestedForEachTaskAutoNaming() {
Workflow wf =
WorkflowBuilder.workflow("flowAutoNameForEach")
- .tasks(
- d ->
- d.forEach(
- null,
- f ->
- f.each("item")
- .in("$.list")
- // Define tasks to be executed for each item in the forEach loop
- .tasks(
- tb ->
- tb.http(null, http().post().endpoint("http://test"))
- .set(null, s -> s.expr("$.processed = true")))))
+ .tasks(d ->
+ d.forEach(
+ null,
+ f ->
+ f.each("item")
+ .in("$.list")
+ // Define tasks to be executed for each item in the forEach loop
+ .tasks(tb ->
+ tb.http(null, http().post().endpoint("http://test"))
+ .set(null, s -> s.expr("$.processed = true")))))
.build();
List topItems = wf.getDo();
@@ -150,16 +146,14 @@ void testWaitTaskAutoNamingAndDuration() {
void testNestedForkTaskAutoNaming() {
Workflow wf =
WorkflowBuilder.workflow("flowAutoNameFork")
- .tasks(
- d ->
- d.fork(
- null,
- f ->
- f.branches(
- b ->
- b.set(null, s -> s.expr("$.a = 1"))
- .set(null, s -> s.expr("$.a = 2"))
- .http(null, http().get().endpoint("http://b")))))
+ .tasks(d ->
+ d.fork(
+ null,
+ f ->
+ f.branches(b ->
+ b.set(null, s -> s.expr("$.a = 1"))
+ .set(null, s -> s.expr("$.a = 2"))
+ .http(null, http().get().endpoint("http://b")))))
.build();
List topItems = wf.getDo();
@@ -186,25 +180,21 @@ void testDeterministicNamingAcrossInstances() {
// Build the first workflow instance
Workflow wf1 =
WorkflowBuilder.workflow("workflowOne")
- .tasks(
- d ->
- d.set(null, s -> s.expr("$.a = 1"))
- .http(null, http().get().endpoint("http://example.com"))
- .emit("customEmit", e -> e.event(ev -> ev.type("test")))
- .tryCatch(
- null, t -> t.tryHandler(tb -> tb.set(null, s -> s.expr("$.b = 2")))))
+ .tasks(d ->
+ d.set(null, s -> s.expr("$.a = 1"))
+ .http(null, http().get().endpoint("http://example.com"))
+ .emit("customEmit", e -> e.event(ev -> ev.type("test")))
+ .tryCatch(null, t -> t.tryHandler(tb -> tb.set(null, s -> s.expr("$.b = 2")))))
.build();
// Build the second workflow instance with the exact same task structure
Workflow wf2 =
WorkflowBuilder.workflow("workflowTwo")
- .tasks(
- d ->
- d.set(null, s -> s.expr("$.a = 1"))
- .http(null, http().get().endpoint("http://example.com"))
- .emit("customEmit", e -> e.event(ev -> ev.type("test")))
- .tryCatch(
- null, t -> t.tryHandler(tb -> tb.set(null, s -> s.expr("$.b = 2")))))
+ .tasks(d ->
+ d.set(null, s -> s.expr("$.a = 1"))
+ .http(null, http().get().endpoint("http://example.com"))
+ .emit("customEmit", e -> e.event(ev -> ev.type("test")))
+ .tryCatch(null, t -> t.tryHandler(tb -> tb.set(null, s -> s.expr("$.b = 2")))))
.build();
List tasks1 = wf1.getDo();
@@ -235,15 +225,12 @@ void testMultipleTasksAppendsMaintainOffset() {
Workflow wf =
WorkflowBuilder.workflow("flowMultipleAppends")
// First invocation: list is empty, offset is 0
- .tasks(
- d ->
- d.set(null, s -> s.expr("$.a = 1"))
- .http(null, http().get().endpoint("http://a")))
+ .tasks(d ->
+ d.set(null, s -> s.expr("$.a = 1")).http(null, http().get().endpoint("http://a")))
// Second invocation: list has 2 items, offset passed to builder should be 2
- .tasks(
- d ->
- d.set(null, s -> s.expr("$.b = 2"))
- .emit("", e -> e.event(ev -> ev.type("test.event"))))
+ .tasks(d ->
+ d.set(null, s -> s.expr("$.b = 2"))
+ .emit("", e -> e.event(ev -> ev.type("test.event"))))
.build();
List items = wf.getDo();
@@ -263,17 +250,16 @@ void testMultipleTasksAppendsMaintainOffset() {
void testForkTaskMultipleBranchesAppends() {
Workflow wf =
WorkflowBuilder.workflow("flowForkMultipleAppends")
- .tasks(
- d ->
- d.fork(
- null,
- f ->
- // 1. First call: list is empty, offset is 0
- f.branches(b -> b.set(null, s -> s.expr("$.a = 1")))
- // 2. Second call: list has 1 item, offset should be 1
- .branches(b -> b.set(null, s -> s.expr("$.b = 2")))
- // 3. Third call: list has 2 items, offset should be 2
- .branches(b -> b.http(null, http().get().endpoint("http://test")))))
+ .tasks(d ->
+ d.fork(
+ null,
+ f ->
+ // 1. First call: list is empty, offset is 0
+ f.branches(b -> b.set(null, s -> s.expr("$.a = 1")))
+ // 2. Second call: list has 1 item, offset should be 1
+ .branches(b -> b.set(null, s -> s.expr("$.b = 2")))
+ // 3. Third call: list has 2 items, offset should be 2
+ .branches(b -> b.http(null, http().get().endpoint("http://test")))))
.build();
List topItems = wf.getDo();
@@ -298,19 +284,18 @@ void testForkTaskMultipleBranchesAppends() {
void testForEachTaskMultipleTasksAppends() {
Workflow wf =
WorkflowBuilder.workflow("flowForMultipleAppends")
- .tasks(
- d ->
- d.forEach(
- null,
- f ->
- f.each("item")
- .in("$.list")
- // 1. First call: list is empty, offset is 0
- .tasks(tb -> tb.set(null, s -> s.expr("$.a = 1")))
- // 2. Second call: list has 1 item, offset should be 1
- .tasks(tb -> tb.set(null, s -> s.expr("$.b = 2")))
- // 3. Third call: list has 2 items, offset should be 2
- .tasks(tb -> tb.http(null, http().get().endpoint("http://test")))))
+ .tasks(d ->
+ d.forEach(
+ null,
+ f ->
+ f.each("item")
+ .in("$.list")
+ // 1. First call: list is empty, offset is 0
+ .tasks(tb -> tb.set(null, s -> s.expr("$.a = 1")))
+ // 2. Second call: list has 1 item, offset should be 1
+ .tasks(tb -> tb.set(null, s -> s.expr("$.b = 2")))
+ // 3. Third call: list has 2 items, offset should be 2
+ .tasks(tb -> tb.http(null, http().get().endpoint("http://test")))))
.build();
List topItems = wf.getDo();
@@ -363,24 +348,19 @@ void testSubscriptionIteratorMultipleTasksAppends() {
void testTryCatchMultipleTasksAppends() {
Workflow wf =
WorkflowBuilder.workflow("flowTryCatchMultipleAppends")
- .tasks(
- d ->
- d.tryCatch(
- null,
- t ->
- // Multiple tryHandler calls
- t.tryHandler(tb -> tb.set(null, s -> s.expr("$.a = 1")))
- .tryHandler(tb -> tb.set(null, s -> s.expr("$.b = 2")))
- .catchHandler(
- c ->
- c.errorsWith(eb -> eb.type("CustomError"))
- // Multiple doTasks calls inside the catch
- .doTasks(cb -> cb.set(null, s -> s.expr("$.c = 3")))
- .doTasks(
- cb ->
- cb.http(
- null,
- http().get().endpoint("http://test"))))))
+ .tasks(d ->
+ d.tryCatch(
+ null,
+ t ->
+ // Multiple tryHandler calls
+ t.tryHandler(tb -> tb.set(null, s -> s.expr("$.a = 1")))
+ .tryHandler(tb -> tb.set(null, s -> s.expr("$.b = 2")))
+ .catchHandler(c ->
+ c.errorsWith(eb -> eb.type("CustomError"))
+ // Multiple doTasks calls inside the catch
+ .doTasks(cb -> cb.set(null, s -> s.expr("$.c = 3")))
+ .doTasks(cb ->
+ cb.http(null, http().get().endpoint("http://test"))))))
.build();
List topItems = wf.getDo();
@@ -412,22 +392,17 @@ void testTryCatchMultipleTasksAppends() {
void testListenTaskSubscriptionIteratorMultipleTasksAppends() {
Workflow wf =
WorkflowBuilder.workflow("flowListenMultipleAppends")
- .tasks(
- d ->
- d.listen(
- null, // Auto-names the listen task
- l ->
- l.forEach(
- sub ->
- // 1. First call: list is empty, offset is 0
- sub.tasks(tb -> tb.set(null, s -> s.expr("$.a = 1")))
- // 2. Second call: list has 1 item, offset should be 1
- .tasks(tb -> tb.set(null, s -> s.expr("$.b = 2")))
- // 3. Third call: list has 2 items, offset should be 2
- .tasks(
- tb ->
- tb.http(
- null, http().get().endpoint("http://test"))))))
+ .tasks(d ->
+ d.listen(
+ null, // Auto-names the listen task
+ l ->
+ l.forEach(sub ->
+ // 1. First call: list is empty, offset is 0
+ sub.tasks(tb -> tb.set(null, s -> s.expr("$.a = 1")))
+ // 2. Second call: list has 1 item, offset should be 1
+ .tasks(tb -> tb.set(null, s -> s.expr("$.b = 2")))
+ // 3. Third call: list has 2 items, offset should be 2
+ .tasks(tb -> tb.http(null, http().get().endpoint("http://test"))))))
.build();
List topItems = wf.getDo();
@@ -455,21 +430,20 @@ null, http().get().endpoint("http://test"))))))
void testNamedForkBranchesWrapDoTaskAndPreserveBranchName() {
Workflow wf =
WorkflowBuilder.workflow("flowNamedForkBranch")
- .tasks(
- d ->
- d.fork(
- null,
- f ->
- f.branch(
- "helloBranch",
- b ->
- b.wait(null, w -> w.wait(Duration.ofMillis(10)))
- .set(null, s -> s.expr("$.value = 1")))
- .branch(
- "byeBranch",
- b ->
- b.wait(null, w -> w.wait(Duration.ofMillis(10)))
- .set(null, s -> s.expr("$.value = 2")))))
+ .tasks(d ->
+ d.fork(
+ null,
+ f ->
+ f.branch(
+ "helloBranch",
+ b ->
+ b.wait(null, w -> w.wait(Duration.ofMillis(10)))
+ .set(null, s -> s.expr("$.value = 1")))
+ .branch(
+ "byeBranch",
+ b ->
+ b.wait(null, w -> w.wait(Duration.ofMillis(10)))
+ .set(null, s -> s.expr("$.value = 2")))))
.build();
List topItems = wf.getDo();
diff --git a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/UseAuthenticationsBuilderTest.java b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/UseAuthenticationsBuilderTest.java
index 174a20bf3..590996be8 100644
--- a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/UseAuthenticationsBuilderTest.java
+++ b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/UseAuthenticationsBuilderTest.java
@@ -85,14 +85,12 @@ void digest_shorthand_creates_digest_policy() {
void oidc_shorthand_without_client_creates_oidc_policy() {
Workflow wf =
WorkflowBuilder.workflow("f")
- .use(
- u ->
- u.authentications(
- a ->
- a.oidc(
- "myOidc",
- "https://auth.example.com/",
- OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS)))
+ .use(u ->
+ u.authentications(a ->
+ a.oidc(
+ "myOidc",
+ "https://auth.example.com/",
+ OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS)))
.build();
AuthenticationPolicyUnion union =
@@ -115,16 +113,14 @@ void oidc_shorthand_without_client_creates_oidc_policy() {
void oidc_shorthand_with_client_creates_oidc_policy() {
Workflow wf =
WorkflowBuilder.workflow("f")
- .use(
- u ->
- u.authentications(
- a ->
- a.oidc(
- "myOidc",
- "https://auth.example.com/",
- OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
- "client-id",
- "client-secret")))
+ .use(u ->
+ u.authentications(a ->
+ a.oidc(
+ "myOidc",
+ "https://auth.example.com/",
+ OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
+ "client-id",
+ "client-secret")))
.build();
AuthenticationPolicyUnion union =
@@ -148,16 +144,14 @@ void oidc_shorthand_with_client_creates_oidc_policy() {
void oauth2_shorthand_with_client_creates_oidc_policy() {
Workflow wf =
WorkflowBuilder.workflow("f")
- .use(
- u ->
- u.authentications(
- a ->
- a.oauth2(
- "myAuth",
- "https://auth.example.com/",
- OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
- "cid",
- "csecret")))
+ .use(u ->
+ u.authentications(a ->
+ a.oauth2(
+ "myAuth",
+ "https://auth.example.com/",
+ OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
+ "cid",
+ "csecret")))
.build();
AuthenticationPolicyUnion union =
@@ -181,17 +175,15 @@ void oauth2_shorthand_with_client_creates_oidc_policy() {
void oauth2_shorthand_with_custom_endpoints() {
Workflow wf =
WorkflowBuilder.workflow("f")
- .use(
- u ->
- u.authentications(
- a ->
- a.oauth2(
- "myAuth",
- "https://auth.example.com/",
- OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
- "cid",
- "csecret",
- e -> e.token("/custom/token"))))
+ .use(u ->
+ u.authentications(a ->
+ a.oauth2(
+ "myAuth",
+ "https://auth.example.com/",
+ OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
+ "cid",
+ "csecret",
+ e -> e.token("/custom/token"))))
.build();
AuthenticationPolicyUnion union =
@@ -216,18 +208,16 @@ void oauth2_shorthand_with_custom_endpoints() {
void oauth2_full_builder_shorthand() {
Workflow wf =
WorkflowBuilder.workflow("f")
- .use(
- u ->
- u.authentications(
- a ->
- a.oauth2(
- "myAuth",
- o ->
- o.endpoints(e -> e.token("/t").revocation("/r"))
- .authority("https://auth.example.com/")
- .grant(OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS)
- .scopes("read", "write")
- .client(c -> c.id("cid").secret("csecret")))))
+ .use(u ->
+ u.authentications(a ->
+ a.oauth2(
+ "myAuth",
+ o ->
+ o.endpoints(e -> e.token("/t").revocation("/r"))
+ .authority("https://auth.example.com/")
+ .grant(OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS)
+ .scopes("read", "write")
+ .client(c -> c.id("cid").secret("csecret")))))
.build();
AuthenticationPolicyUnion union =
@@ -251,22 +241,20 @@ void oauth2_full_builder_shorthand() {
void multiple_named_authentications_via_chaining() {
Workflow wf =
WorkflowBuilder.workflow("f")
- .use(
- u ->
- u.authentications(
- a ->
- a.oauth2(
- "joogle",
- "https://joogle.example.com/",
- OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
- "joogle-id",
- "joogle-secret")
- .oauth2(
- "jahoo",
- "https://jahoo.example.com/",
- OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
- "jahoo-id",
- "jahoo-secret")))
+ .use(u ->
+ u.authentications(a ->
+ a.oauth2(
+ "joogle",
+ "https://joogle.example.com/",
+ OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
+ "joogle-id",
+ "joogle-secret")
+ .oauth2(
+ "jahoo",
+ "https://jahoo.example.com/",
+ OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
+ "jahoo-id",
+ "jahoo-secret")))
.build();
UseAuthentications auths = wf.getUse().getAuthentications();
@@ -296,18 +284,16 @@ void multiple_named_authentications_via_chaining() {
void mixed_auth_types_via_chaining() {
Workflow wf =
WorkflowBuilder.workflow("f")
- .use(
- u ->
- u.authentications(
- a ->
- a.basic("b", "user", "pass")
- .bearer("t", "token-123")
- .oauth2(
- "o",
- "https://auth.example.com/",
- OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
- "cid",
- "csecret")))
+ .use(u ->
+ u.authentications(a ->
+ a.basic("b", "user", "pass")
+ .bearer("t", "token-123")
+ .oauth2(
+ "o",
+ "https://auth.example.com/",
+ OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS,
+ "cid",
+ "csecret")))
.build();
UseAuthentications auths = wf.getUse().getAuthentications();
diff --git a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/WorkflowBuilderTest.java b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/WorkflowBuilderTest.java
index 983312b29..d8b899110 100644
--- a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/WorkflowBuilderTest.java
+++ b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/WorkflowBuilderTest.java
@@ -103,18 +103,16 @@ void testWorkflowDocumentExplicit() {
void testTaskMetadata() {
Workflow wf =
WorkflowBuilder.workflow("flowWithTaskMetadata")
- .tasks(
- d ->
- d.set(
- "described",
- s ->
- s.expr("$.value = 'test'")
- .metadata(
- m ->
- m.description("Exit when counter reaches 10")
- .put("exitConditionDescription", "counter == 10")
- .put("weight", 42)))
- .set("plain", s -> s.expr("$.other = 'value'")))
+ .tasks(d ->
+ d.set(
+ "described",
+ s ->
+ s.expr("$.value = 'test'")
+ .metadata(m ->
+ m.description("Exit when counter reaches 10")
+ .put("exitConditionDescription", "counter == 10")
+ .put("weight", 42)))
+ .set("plain", s -> s.expr("$.other = 'value'")))
.build();
List items = wf.getDo();
@@ -164,10 +162,9 @@ void testEmptyTasksConsumerThrows() {
void testDoTaskSetAndForEach() {
Workflow wf =
WorkflowBuilder.workflow("flowDo")
- .tasks(
- d ->
- d.set("initCtx", "$.foo = 'bar'")
- .forEach("item", f -> f.each("item").at("index").in("$.list")))
+ .tasks(d ->
+ d.set("initCtx", "$.foo = 'bar'")
+ .forEach("item", f -> f.each("item").at("index").in("$.list")))
.build();
List items = wf.getDo();
@@ -190,9 +187,8 @@ void testTaskNamedSet() {
// Test that we can now name a task "set" using the DSL
Workflow wf =
WorkflowBuilder.workflow("flowWithSetTask")
- .tasks(
- d ->
- d.set("set", "$.value = 'test'").set("set", s -> s.expr("$.another = 'value'")))
+ .tasks(d ->
+ d.set("set", "$.value = 'test'").set("set", s -> s.expr("$.another = 'value'")))
.build();
List items = wf.getDo();
@@ -252,11 +248,8 @@ void testAllTasksWithExplicitNames() {
listen(
"listen",
l ->
- l.to(
- to ->
- to.one(
- f ->
- f.with(p -> p.type("com.test.event").source("test"))))),
+ l.to(to ->
+ to.one(f -> f.with(p -> p.type("com.test.event").source("test"))))),
forEach("forEach", f -> f.each("item").in("$.items")),
fork("fork", f -> f.compete(false)),
switchCase("switch", cases().onDefault(FlowDirectiveEnum.CONTINUE)),
@@ -300,21 +293,20 @@ void testAllTasksWithExplicitNames() {
void testDoTaskMultipleTypes() {
Workflow wf =
WorkflowBuilder.workflow("flowMixed")
- .tasks(
- d ->
- d.set("init", s -> s.expr("$.init = true"))
- .forEach("items", f -> f.each("item").in("$.list"))
- .switchCase("choice", cases().onDefault(FlowDirectiveEnum.CONTINUE))
- .raise(
- "alert",
- r -> {
- // no-op configuration
- })
- .fork(
- "parallel",
- f -> {
- // no-op configuration
- }))
+ .tasks(d ->
+ d.set("init", s -> s.expr("$.init = true"))
+ .forEach("items", f -> f.each("item").in("$.list"))
+ .switchCase("choice", cases().onDefault(FlowDirectiveEnum.CONTINUE))
+ .raise(
+ "alert",
+ r -> {
+ // no-op configuration
+ })
+ .fork(
+ "parallel",
+ f -> {
+ // no-op configuration
+ }))
.build();
List items = wf.getDo();
@@ -351,21 +343,16 @@ void testDoTaskMultipleTypes() {
void testDoTaskListenOne() {
Workflow wf =
WorkflowBuilder.workflow("flowListen")
- .tasks(
- d ->
- d.listen(
- "waitCheck",
- l ->
- l.to(
- to ->
- to.one(
- f ->
- f.with(p -> p.type("com.fake.pet").source("mySource"))
- .correlate(
- "orderId",
- c ->
- c.from("$.data.orderId")
- .expect("$.input.orderId"))))))
+ .tasks(d ->
+ d.listen(
+ "waitCheck",
+ l ->
+ l.to(to ->
+ to.one(f ->
+ f.with(p -> p.type("com.fake.pet").source("mySource"))
+ .correlate(
+ "orderId",
+ c -> c.from("$.data.orderId").expect("$.input.orderId"))))))
.build();
List items = wf.getDo();
@@ -436,20 +423,16 @@ void testDoTaskEmitEvent() {
void testDoTaskTryCatchWithRetry() {
Workflow wf =
WorkflowBuilder.workflow("flowTry")
- .tasks(
- d ->
- d.tryCatch(
- "tryBlock",
- t ->
- t.tryHandler(tb -> tb.set("init", s -> s.expr("$.start = true")))
- .catchHandler(
- c ->
- c.when("$.errorType == 'TEMP' ")
- .retry(
- r ->
- r.when("$.retryCount < 3")
- .limit(
- l -> l.attempt(at -> at.count(3)))))))
+ .tasks(d ->
+ d.tryCatch(
+ "tryBlock",
+ t ->
+ t.tryHandler(tb -> tb.set("init", s -> s.expr("$.start = true")))
+ .catchHandler(c ->
+ c.when("$.errorType == 'TEMP' ")
+ .retry(r ->
+ r.when("$.retryCount < 3")
+ .limit(l -> l.attempt(at -> at.count(3)))))))
.build();
List items = wf.getDo();
@@ -484,20 +467,17 @@ void testDoTaskTryCatchWithRetry() {
void testDoTaskTryCatchErrorsFiltering() {
Workflow wf =
WorkflowBuilder.workflow("flowCatch")
- .tasks(
- d ->
- d.tryCatch(
- "tryBlock",
- t ->
- t.tryHandler(tb -> tb.set("foo", s -> s.expr("$.foo = 'bar'")))
- .catchHandler(
- c ->
- c.exceptWhen("$.status == 500")
- .errorsWith(
- eb ->
- eb.type("ServerError")
- .status(500)
- .instance("http://errors/5xx")))))
+ .tasks(d ->
+ d.tryCatch(
+ "tryBlock",
+ t ->
+ t.tryHandler(tb -> tb.set("foo", s -> s.expr("$.foo = 'bar'")))
+ .catchHandler(c ->
+ c.exceptWhen("$.status == 500")
+ .errorsWith(eb ->
+ eb.type("ServerError")
+ .status(500)
+ .instance("http://errors/5xx")))))
.build();
TaskItem item = wf.getDo().get(0);
@@ -582,14 +562,13 @@ void testWorkflowInputInlineSchemaAndFromObject() {
void testDoTaskCallHTTPBasic() {
Workflow wf =
WorkflowBuilder.workflow("flowCallBasic")
- .tasks(
- d ->
- d.http(
- "basicCall",
- http()
- .post()
- .uri(URI.create("http://example.com/api"))
- .andThen(b -> b.body(Map.of("foo", "bar")))))
+ .tasks(d ->
+ d.http(
+ "basicCall",
+ http()
+ .post()
+ .uri(URI.create("http://example.com/api"))
+ .andThen(b -> b.body(Map.of("foo", "bar")))))
.build();
List items = wf.getDo();
assertEquals(1, items.size(), "Should have one HTTP call task");
@@ -608,11 +587,10 @@ void testDoTaskCallHTTPBasic() {
void testDoTaskCallHTTPHeadersConsumerAndMap() {
Workflow wf =
WorkflowBuilder.workflow("flowCallHeaders")
- .tasks(
- d ->
- d.http(
- "hdrCall",
- http().get().endpoint("${uriExpr}").headers(Map.of("A", "1", "B", "2"))))
+ .tasks(d ->
+ d.http(
+ "hdrCall",
+ http().get().endpoint("${uriExpr}").headers(Map.of("A", "1", "B", "2"))))
.build();
CallHTTP call = wf.getDo().get(0).getTask().getCallTask().getCallHTTP();
HTTPHeaders hh = call.getWith().getHeaders().getHTTPHeaders();
@@ -621,10 +599,8 @@ void testDoTaskCallHTTPHeadersConsumerAndMap() {
Workflow wf2 =
WorkflowBuilder.workflow()
- .tasks(
- d ->
- d.http(
- http().get().endpoint("${ expr }").headers(Map.of("X", "10", "Y", "20"))))
+ .tasks(d ->
+ d.http(http().get().endpoint("${ expr }").headers(Map.of("X", "10", "Y", "20"))))
.build();
CallHTTP call2 = wf2.getDo().get(0).getTask().getCallTask().getCallHTTP();
HTTPHeaders hh2 = call2.getWith().getHeaders().getHTTPHeaders();
@@ -636,14 +612,13 @@ void testDoTaskCallHTTPHeadersConsumerAndMap() {
void testDoTaskCallHTTPQueryMap() {
Workflow wf =
WorkflowBuilder.workflow("flowCallQuery")
- .tasks(
- d ->
- d.http(
- "qryCall",
- http()
- .get()
- .endpoint("${ exprUri }")
- .andThen(q -> q.query(Map.of("k1", "v1", "k2", "v2")))))
+ .tasks(d ->
+ d.http(
+ "qryCall",
+ http()
+ .get()
+ .endpoint("${ exprUri }")
+ .andThen(q -> q.query(Map.of("k1", "v1", "k2", "v2")))))
.build();
HTTPQuery hq =
wf.getDo().get(0).getTask().getCallTask().getCallHTTP().getWith().getQuery().getHTTPQuery();
@@ -652,13 +627,9 @@ void testDoTaskCallHTTPQueryMap() {
Workflow wf2 =
WorkflowBuilder.workflow()
- .tasks(
- d ->
- d.http(
- c ->
- c.method("GET")
- .endpoint("http://uri")
- .query(Map.of("q1", "x", "q2", "y"))))
+ .tasks(d ->
+ d.http(c ->
+ c.method("GET").endpoint("http://uri").query(Map.of("q1", "x", "q2", "y"))))
.build();
HTTPQuery hq2 =
wf2.getDo()
@@ -688,15 +659,14 @@ void testDoTaskCallHTTPQuerySingleKeyValue() {
void testDoTaskCallHTTPRedirectAndOutput() {
Workflow wf =
WorkflowBuilder.workflow("flowCallOpts")
- .tasks(
- d ->
- d.http(
- "optCall",
- c ->
- c.method("DELETE")
- .endpoint("${ expr }")
- .redirect(true)
- .output(HTTPArguments.HTTPOutput.RESPONSE)))
+ .tasks(d ->
+ d.http(
+ "optCall",
+ c ->
+ c.method("DELETE")
+ .endpoint("${ expr }")
+ .redirect(true)
+ .output(HTTPArguments.HTTPOutput.RESPONSE)))
.build();
CallHTTP call = wf.getDo().get(0).getTask().getCallTask().getCallHTTP();
assertTrue(call.getWith().isRedirect(), "Redirect should be true");
@@ -710,17 +680,16 @@ void testDoTaskCallHTTPRedirectAndOutput() {
void testDoTaskRunWorkflow() {
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)))
+ .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();
var runTask = wf.getDo().get(0).getTask().getRunTask();
diff --git a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/DSLTest.java b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/DSLTest.java
index d32313b3e..e594a16b6 100644
--- a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/DSLTest.java
+++ b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/DSLTest.java
@@ -69,13 +69,12 @@ public void when_new_http_call_task() {
public void when_listen_all_then_emit() {
Workflow wf =
WorkflowBuilder.workflow("myFlow", "myNs", "1.2.3")
- .tasks(
- t ->
- t.listen(
- to().all(
- event().type("org.acme.listen"),
- event().type("org.example.listen")))
- .emit(produced("org.example.emit")))
+ .tasks(t ->
+ t.listen(
+ to().all(
+ event().type("org.acme.listen"),
+ event().type("org.example.listen")))
+ .emit(produced("org.example.emit")))
.build();
// Sanity
@@ -139,12 +138,11 @@ public void when_listen_any_with_until() {
Workflow wf =
WorkflowBuilder.workflow("f", "ns", "1")
- .tasks(
- t ->
- t.listen(
- to().any(event().type("A"), event().type("B"))
- .until(untilExpr)
- .andThen(c -> c.read(ListenTaskConfiguration.ListenAndReadAs.RAW))))
+ .tasks(t ->
+ t.listen(
+ to().any(event().type("A"), event().type("B"))
+ .until(untilExpr)
+ .andThen(c -> c.read(ListenTaskConfiguration.ListenAndReadAs.RAW))))
.build();
var to = wf.getDo().get(0).getTask().getListenTask().getListen().getTo();
@@ -167,15 +165,13 @@ public void when_listen_any_with_until() {
public void when_listen_one() {
Workflow wf =
WorkflowBuilder.workflow("f", "ns", "1")
- .tasks(
- t ->
- t.listen(
- to().one(
- event()
- .type("only-once")
- .correlate(
- "workflowInstanceId",
- c -> c.from("$.metadata.instanceId")))))
+ .tasks(t ->
+ t.listen(
+ to().one(
+ event()
+ .type("only-once")
+ .correlate(
+ "workflowInstanceId", c -> c.from("$.metadata.instanceId")))))
.build();
var to = wf.getDo().get(0).getTask().getListenTask().getListen().getTo();
@@ -197,10 +193,8 @@ public void when_listen_one() {
public void when_raise_with_string_type_and_status() {
Workflow wf =
WorkflowBuilder.workflow("f", "ns", "1")
- .tasks(
- t ->
- t.raise(
- error("org.acme.Error", 422).title("Unprocessable").detail("Bad input")))
+ .tasks(t ->
+ t.raise(error("org.acme.Error", 422).title("Unprocessable").detail("Bad input")))
.build();
var err = wf.getDo().get(0).getTask().getRaiseTask().getRaise().getError();
diff --git a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/DSLTimeoutTest.java b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/DSLTimeoutTest.java
index 9439c7af3..9163f65c1 100644
--- a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/DSLTimeoutTest.java
+++ b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/DSLTimeoutTest.java
@@ -126,17 +126,15 @@ public void when_all_timeout_shortcuts_are_applied() {
@Test
public void when_mixing_expression_and_inline_throws_exception() {
- assertThatThrownBy(
- () ->
- WorkflowBuilder.workflow("failFlow", "myNs", "1.0.0")
- .timeout(t -> t.duration("PT15M").duration(d -> d.minutes(15))))
+ assertThatThrownBy(() ->
+ WorkflowBuilder.workflow("failFlow", "myNs", "1.0.0")
+ .timeout(t -> t.duration("PT15M").duration(d -> d.minutes(15))))
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("Duration expression already set");
- assertThatThrownBy(
- () ->
- WorkflowBuilder.workflow("failFlow", "myNs", "1.0.0")
- .timeout(t -> t.duration(d -> d.minutes(15)).duration("PT15M")))
+ assertThatThrownBy(() ->
+ WorkflowBuilder.workflow("failFlow", "myNs", "1.0.0")
+ .timeout(t -> t.duration(d -> d.minutes(15)).duration("PT15M")))
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("Duration already specified");
}
diff --git a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/TryCatchDslTest.java b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/TryCatchDslTest.java
index ec1daf75b..aac95f588 100644
--- a/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/TryCatchDslTest.java
+++ b/fluent/spec/src/test/java/org/openworkflow/sdk/fluent/spec/dsl/TryCatchDslTest.java
@@ -40,24 +40,23 @@ public class TryCatchDslTest {
void when_try_with_tasks_and_catch_when_with_retry_and_tasks() {
Workflow wf =
WorkflowBuilder.workflow("f", "ns", "1")
- .tasks(
- t ->
- t.tryCatch(
- tryCatch()
- // try block (one HTTP call)
- .tasks(call(http().get().endpoint(EXPR_ENDPOINT)))
- // catch block
- .catches()
- .when("$.error == true")
- .errors(Errors.RUNTIME, 500)
- .tasks(emit("org.acme.failed"))
- .retry()
- .when("$.retries < 3")
- .limit("PT5S")
- .jitter("PT0.1S", "PT0.5S")
- .done() // back to TryCatchSpec
- .done() // back to TrySpec
- ))
+ .tasks(t ->
+ t.tryCatch(
+ tryCatch()
+ // try block (one HTTP call)
+ .tasks(call(http().get().endpoint(EXPR_ENDPOINT)))
+ // catch block
+ .catches()
+ .when("$.error == true")
+ .errors(Errors.RUNTIME, 500)
+ .tasks(emit("org.acme.failed"))
+ .retry()
+ .when("$.retries < 3")
+ .limit("PT5S")
+ .jitter("PT0.1S", "PT0.5S")
+ .done() // back to TryCatchSpec
+ .done() // back to TrySpec
+ ))
.build();
// --- locate Try task ---
@@ -113,21 +112,20 @@ void when_try_with_multiple_tasks_and_catch_except_when_with_uri_error_filter()
Workflow wf =
WorkflowBuilder.workflow("g", "ns", "1")
- .tasks(
- t ->
- t.tryCatch(
- tryCatch()
- // try with two tasks
- .tasks(
- call(http().get().endpoint(EXPR_ENDPOINT)),
- set("$.status = \"IN_FLIGHT\""))
- // catch with exceptWhen + explicit URI error filter + status
- .catches()
- .exceptWhen("$.code == 502")
- .errors(errType, 502)
- .tasks(emit("org.acme.recover"))
- .done() // back to TrySpec
- ))
+ .tasks(t ->
+ t.tryCatch(
+ tryCatch()
+ // try with two tasks
+ .tasks(
+ call(http().get().endpoint(EXPR_ENDPOINT)),
+ set("$.status = \"IN_FLIGHT\""))
+ // catch with exceptWhen + explicit URI error filter + status
+ .catches()
+ .exceptWhen("$.code == 502")
+ .errors(errType, 502)
+ .tasks(emit("org.acme.recover"))
+ .done() // back to TrySpec
+ ))
.build();
var tryTask = wf.getDo().get(0).getTask().getTryTask();
@@ -167,19 +165,18 @@ void when_try_with_multiple_tasks_and_catch_except_when_with_uri_error_filter()
void when_try_with_catch_and_simple_retry_limit_only() {
Workflow wf =
WorkflowBuilder.workflow("r", "ns", "1")
- .tasks(
- t ->
- t.tryCatch(
- tryCatch()
- .tasks(call(http().get().endpoint(EXPR_ENDPOINT)))
- .catches()
- .when("$.fail == true")
- .errors(Errors.COMMUNICATION, 503)
- .retry()
- .limit("PT2S")
- .done()
- .tasks(emit("org.acme.retrying"))
- .done()))
+ .tasks(t ->
+ t.tryCatch(
+ tryCatch()
+ .tasks(call(http().get().endpoint(EXPR_ENDPOINT)))
+ .catches()
+ .when("$.fail == true")
+ .errors(Errors.COMMUNICATION, 503)
+ .retry()
+ .limit("PT2S")
+ .done()
+ .tasks(emit("org.acme.retrying"))
+ .done()))
.build();
var tryTask = wf.getDo().get(0).getTask().getTryTask();
@@ -316,11 +313,10 @@ void when_try_catch_match_details() {
error(URI.create("https://example.com/errors/transient"), 503)
.detail("Enforcement Failure - invalid email")))
.catches()
- .errors(
- e ->
- e.type("https://example.com/errors/transient")
- .status(503)
- .details("Enforcement Failure - invalid email"))
+ .errors(e ->
+ e.type("https://example.com/errors/transient")
+ .status(503)
+ .details("Enforcement Failure - invalid email"))
.tasks(set("handleError", s -> s.put("recovered", true)))
.done()))
.build();
@@ -435,15 +431,14 @@ void when_try_catch_reusable_retry() {
WorkflowBuilder.workflow("try-catch-retry-reusable", "test", "0.1.0")
.use(
use()
- .retries(
- r ->
- r.retry(
- "default",
- policy ->
- policy
- .delay("PT0.01S")
- .backoff(b -> b.constant("c", "10"))
- .limit(l -> l.attempt(a -> a.count(5))))))
+ .retries(r ->
+ r.retry(
+ "default",
+ policy ->
+ policy
+ .delay("PT0.01S")
+ .backoff(b -> b.constant("c", "10"))
+ .limit(l -> l.attempt(a -> a.count(5))))))
.tasks(
tryCatch(
"tryGetPet",
@@ -698,25 +693,23 @@ void when_try_catch_backoff_constant_then_oneof_value_is_set() {
@Test
void when_backoff_builder_mixes_variants_then_throws() {
- assertThatThrownBy(
- () ->
- WorkflowBuilder.workflow("mixed-backoff", "test", "0.1.0")
- .tasks(
- tryCatch(
- "tryTask",
- tryCatch()
- .tasks(call(http().get().endpoint("http://localhost:9797")))
- .catches()
- .errors(Errors.COMMUNICATION, 404)
- .retry()
- .backoff(
- b -> {
- b.constant("c", "10");
- b.exponential("e", "1.5");
- })
- .done()
- .done()))
- .build())
+ assertThatThrownBy(() ->
+ WorkflowBuilder.workflow("mixed-backoff", "test", "0.1.0")
+ .tasks(
+ tryCatch(
+ "tryTask",
+ tryCatch()
+ .tasks(call(http().get().endpoint("http://localhost:9797")))
+ .catches()
+ .errors(Errors.COMMUNICATION, 404)
+ .retry()
+ .backoff(b -> {
+ b.constant("c", "10");
+ b.exponential("e", "1.5");
+ })
+ .done()
+ .done()))
+ .build())
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("Only one backoff variant");
}
diff --git a/generators/types/src/main/java/org/openworkflow/sdk/generator/AllAnyOneOfSchemaRule.java b/generators/types/src/main/java/org/openworkflow/sdk/generator/AllAnyOneOfSchemaRule.java
index 0f880b368..e9d39e8b8 100644
--- a/generators/types/src/main/java/org/openworkflow/sdk/generator/AllAnyOneOfSchemaRule.java
+++ b/generators/types/src/main/java/org/openworkflow/sdk/generator/AllAnyOneOfSchemaRule.java
@@ -311,14 +311,13 @@ private JDefinedClass wrapAll(
private JDefinedClass populateRef(
JDefinedClass definedClass, Optional refType, Schema parentSchema) {
- refType.ifPresent(
- type -> {
- if (type instanceof JClass classType) {
- definedClass._extends(classType);
- } else {
- wrapIt(parentSchema, definedClass, Optional.empty(), type, null);
- }
- });
+ refType.ifPresent(type -> {
+ if (type instanceof JClass classType) {
+ definedClass._extends(classType);
+ } else {
+ wrapIt(parentSchema, definedClass, Optional.empty(), type, null);
+ }
+ });
if (definedClass.constructors().hasNext()
&& definedClass.getConstructor(new JType[0]) == null) {
@@ -354,13 +353,12 @@ private JVar setupMethod(
Optional valueField,
JFieldVar instanceField) {
JVar methodParam = method.param(instanceField.type(), instanceField.name());
- valueField.ifPresent(
- v -> {
- method.body().assign(JExpr._this().ref(v), methodParam);
- method
- .annotate(definedClass.owner().ref(OneOfSetter.class))
- .param("value", instanceField.type());
- });
+ valueField.ifPresent(v -> {
+ method.body().assign(JExpr._this().ref(v), methodParam);
+ method
+ .annotate(definedClass.owner().ref(OneOfSetter.class))
+ .param("value", instanceField.type());
+ });
return methodParam;
}
diff --git a/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AExecutor.java b/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AExecutor.java
index ba92ab502..83e449c5a 100644
--- a/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AExecutor.java
+++ b/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AExecutor.java
@@ -68,24 +68,21 @@ public CompletableFuture apply(
}
},
workflowContext.definition().application().executorService())
- .thenCompose(
- agentCard -> {
- logger.debug("Agent card is {}", agentCard);
- try {
- return dispatcher.apply(
- agentCard,
- Client.builder(agentCard)
- .clientConfig(new ClientConfig.Builder().build())
- .withTransport(JSONRPCTransport.class, new JSONRPCTransportConfig())
- .build(),
- mapResolver
- .map(m -> m.apply(workflowContext, taskContext, input))
- .orElse(Map.of()),
- workflowContext,
- taskContext);
- } catch (A2AClientException ex) {
- throw A2AUtils.workflowException(taskContext.position(), ex);
- }
- });
+ .thenCompose(agentCard -> {
+ logger.debug("Agent card is {}", agentCard);
+ try {
+ return dispatcher.apply(
+ agentCard,
+ Client.builder(agentCard)
+ .clientConfig(new ClientConfig.Builder().build())
+ .withTransport(JSONRPCTransport.class, new JSONRPCTransportConfig())
+ .build(),
+ mapResolver.map(m -> m.apply(workflowContext, taskContext, input)).orElse(Map.of()),
+ workflowContext,
+ taskContext);
+ } catch (A2AClientException ex) {
+ throw A2AUtils.workflowException(taskContext.position(), ex);
+ }
+ });
}
}
diff --git a/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AExecutorBuilder.java b/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AExecutorBuilder.java
index d01923882..5462adcb7 100644
--- a/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AExecutorBuilder.java
+++ b/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AExecutorBuilder.java
@@ -54,14 +54,12 @@ public CallableTaskFactory init(
A2ARequestDispatcher dispatcher =
switch (args.getMethod()) {
case MESSAGE_SEND ->
- new MessageDispatcher(
- (workflowContext, taskContext, completableFuture) ->
- new MessageSendConsumer(workflowContext.definition(), completableFuture));
+ new MessageDispatcher((workflowContext, taskContext, completableFuture) ->
+ new MessageSendConsumer(workflowContext.definition(), completableFuture));
case MESSAGE_STREAM ->
- new MessageDispatcher(
- (workflowContext, taskContext, completableFuture) ->
- new MessageStreamConsumer(
- workflowContext.definition(), completableFuture, taskContext.position()));
+ new MessageDispatcher((workflowContext, taskContext, completableFuture) ->
+ new MessageStreamConsumer(
+ workflowContext.definition(), completableFuture, taskContext.position()));
case TASKS_LIST -> new ListTaskDispatcher();
case TASKS_GET -> new GetTaskDispatcher();
case TASKS_CANCEL -> new CancelTaskDispatcher();
diff --git a/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AUtils.java b/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AUtils.java
index 96fdcfa32..9ea537aef 100644
--- a/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AUtils.java
+++ b/impl/a2a/src/main/java/org/openworkflow/sdk/impl/executors/a2a/A2AUtils.java
@@ -84,17 +84,16 @@ static T isInstanceOrThrow(Object obj, Class instanceClass, Supplier T isInstanceOrDefault(Object obj, Class instanceClass, Supplier defaultValue) {
return isInstance(obj, instanceClass)
- .orElseGet(
- () -> {
- if (obj != null) {
- logger.warn(
- "Object {} is expected to be of class {} but it is of class {}. Using provided default",
- obj,
- instanceClass.getName(),
- obj.getClass().getName());
- }
- return defaultValue.get();
- });
+ .orElseGet(() -> {
+ if (obj != null) {
+ logger.warn(
+ "Object {} is expected to be of class {} but it is of class {}. Using provided default",
+ obj,
+ instanceClass.getName(),
+ obj.getClass().getName());
+ }
+ return defaultValue.get();
+ });
}
private static Optional isInstance(Object obj, Class instanceClass) {
diff --git a/impl/container/src/main/java/org/openworkflow/sdk/impl/container/executors/ContainerEnvironmentPropertySetter.java b/impl/container/src/main/java/org/openworkflow/sdk/impl/container/executors/ContainerEnvironmentPropertySetter.java
index eb360e084..e3d459dd8 100644
--- a/impl/container/src/main/java/org/openworkflow/sdk/impl/container/executors/ContainerEnvironmentPropertySetter.java
+++ b/impl/container/src/main/java/org/openworkflow/sdk/impl/container/executors/ContainerEnvironmentPropertySetter.java
@@ -51,9 +51,8 @@ public void accept(
WorkflowModel model) {
envResolver
.map(env -> env.apply(workflowContext, taskContext, model))
- .ifPresent(
- envs ->
- command.withEnv(
- envs.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).toList()));
+ .ifPresent(envs ->
+ command.withEnv(
+ envs.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).toList()));
}
}
diff --git a/impl/container/src/main/java/org/openworkflow/sdk/impl/container/executors/VolumesPropertySetter.java b/impl/container/src/main/java/org/openworkflow/sdk/impl/container/executors/VolumesPropertySetter.java
index dedae00c4..934d54681 100644
--- a/impl/container/src/main/java/org/openworkflow/sdk/impl/container/executors/VolumesPropertySetter.java
+++ b/impl/container/src/main/java/org/openworkflow/sdk/impl/container/executors/VolumesPropertySetter.java
@@ -64,11 +64,10 @@ public void accept(
.getHostConfig()
.withBinds(
binds.stream()
- .map(
- r ->
- new Bind(
- r.host().apply(workflowContext, taskContext, model),
- new Volume(r.container.apply(workflowContext, taskContext, model))))
+ .map(r ->
+ new Bind(
+ r.host().apply(workflowContext, taskContext, model),
+ new Volume(r.container.apply(workflowContext, taskContext, model))))
.toList());
}
}
diff --git a/impl/container/src/test/java/org/openworkflow/sdk/impl/test/ContainerTest.java b/impl/container/src/test/java/org/openworkflow/sdk/impl/test/ContainerTest.java
index a086eef35..898e81579 100644
--- a/impl/container/src/test/java/org/openworkflow/sdk/impl/test/ContainerTest.java
+++ b/impl/container/src/test/java/org/openworkflow/sdk/impl/test/ContainerTest.java
@@ -166,14 +166,8 @@ public void onNext(Frame frame) {
public void testContainerTimeout() throws IOException {
String containerName = "hello-world-timeout";
Workflow workflow = readWorkflowFromClasspath("workflows-samples/container-timeout.yaml");
- assertThatThrownBy(
- () ->
- app.workflowDefinition(workflow)
- .instance(Map.of())
- .start()
- .join()
- .asMap()
- .orElseThrow());
+ assertThatThrownBy(() ->
+ app.workflowDefinition(workflow).instance(Map.of()).start().join().asMap().orElseThrow());
assertTrue(isContainerGone(containerName));
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/CollectionConversionUtils.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/CollectionConversionUtils.java
index 643b7ee63..7478951e3 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/CollectionConversionUtils.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/CollectionConversionUtils.java
@@ -52,10 +52,9 @@ else if (clazz.isArray()) {
primitiveArray,
i++,
convert(item, componentType, converter)
- .orElseThrow(
- () ->
- new IllegalArgumentException(
- "Cannot convert " + item + " into class " + componentType)));
+ .orElseThrow(() ->
+ new IllegalArgumentException(
+ "Cannot convert " + item + " into class " + componentType)));
}
return Optional.of(clazz.cast(primitiveArray));
} else {
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/CompositeExpressionFactory.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/CompositeExpressionFactory.java
index 4321f2487..aa7594eec 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/CompositeExpressionFactory.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/CompositeExpressionFactory.java
@@ -40,9 +40,8 @@ private T processFactories(
.sorted(Comparator.comparingInt(f -> f.priority(desc)))
.findFirst()
.map(consumer::apply)
- .orElseThrow(
- () ->
- new IllegalArgumentException("No expression factory found for expression " + desc));
+ .orElseThrow(() ->
+ new IllegalArgumentException("No expression factory found for expression " + desc));
}
@Override
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/LifecycleEventsUtils.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/LifecycleEventsUtils.java
index c3a130b17..1df444b82 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/LifecycleEventsUtils.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/LifecycleEventsUtils.java
@@ -44,20 +44,17 @@ public static CompletableFuture> publishEvent(
for (Collection listeners :
workflowContext.definition().application().listenersByPriority()) {
result =
- result.thenCompose(
- __ ->
- CompletableFuture.allOf(
- listeners.stream()
- .map(
- v ->
- function
- .apply(v)
- .exceptionally(
- ex -> {
- logger.error("Error while executing listener", ex);
- return null;
- }))
- .toArray(CompletableFuture[]::new)));
+ result.thenCompose(__ ->
+ CompletableFuture.allOf(
+ listeners.stream()
+ .map(v ->
+ function
+ .apply(v)
+ .exceptionally(ex -> {
+ logger.error("Error while executing listener", ex);
+ return null;
+ }))
+ .toArray(CompletableFuture[]::new)));
}
return result;
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowApplication.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowApplication.java
index cebbcd89d..c7d1fc716 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowApplication.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowApplication.java
@@ -494,10 +494,9 @@ public WorkflowApplication build() {
if (modelFactory == null) {
modelFactory =
loadFirst(WorkflowModelFactory.class)
- .orElseThrow(
- () ->
- new IllegalStateException(
- "WorkflowModelFactory instance has to be set in WorkflowApplication or present in the classpath"));
+ .orElseThrow(() ->
+ new IllegalStateException(
+ "WorkflowModelFactory instance has to be set in WorkflowApplication or present in the classpath"));
}
if (contextFactory == null) {
contextFactory = modelFactory;
@@ -516,14 +515,13 @@ public WorkflowApplication build() {
if (eventConsumer == null) {
eventConsumer =
loadFirst(EventConsumer.class)
- .orElseGet(
- () -> {
- InMemoryEvents inMemory = new InMemoryEvents(executorFactory);
- if (eventPublishers.isEmpty()) {
- eventPublishers.add(inMemory);
- }
- return inMemory;
- });
+ .orElseGet(() -> {
+ InMemoryEvents inMemory = new InMemoryEvents(executorFactory);
+ if (eventPublishers.isEmpty()) {
+ eventPublishers.add(inMemory);
+ }
+ return inMemory;
+ });
}
if (idFactory == null) {
idFactory = new MonotonicUlidWorkflowInstanceIdFactory();
@@ -533,23 +531,22 @@ public WorkflowApplication build() {
if (cronResolverFactory == null) {
cronResolverFactory =
loadFirst(CronResolverFactory.class)
- .orElseGet(
- () ->
- new CronResolverFactory() {
- private CronResolver emptyResolver =
- new CronResolver() {
- @Override
- public Optional nextExecution() {
- throw new UnsupportedOperationException(
- "Missing CronResolverFactory, please add openworkflow-impl-cron dependency to your classpath");
- }
- };
-
- @Override
- public CronResolver parseCron(String cron) {
- return emptyResolver;
- }
- });
+ .orElseGet(() ->
+ new CronResolverFactory() {
+ private CronResolver emptyResolver =
+ new CronResolver() {
+ @Override
+ public Optional nextExecution() {
+ throw new UnsupportedOperationException(
+ "Missing CronResolverFactory, please add openworkflow-impl-cron dependency to your classpath");
+ }
+ };
+
+ @Override
+ public CronResolver parseCron(String cron) {
+ return emptyResolver;
+ }
+ });
}
schedulerExecutorService = Executors.newSingleThreadScheduledExecutor();
scheduler = new DefaultWorkflowScheduler(schedulerExecutorService, cronResolverFactory);
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowMutableInstance.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowMutableInstance.java
index 55abf0d4c..1a3ba0a49 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowMutableInstance.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowMutableInstance.java
@@ -77,16 +77,14 @@ protected WorkflowMutableInstance(WorkflowDefinition definition, String id, Work
@Override
public CompletableFuture start() {
- return startExecution(
- () -> {
- startedAt = Instant.now();
- return status(WorkflowStatus.RUNNING)
- .thenCompose(
- __ ->
- publishEvent(
- workflowContext,
- l -> l.onWorkflowStarted(new WorkflowStartedEvent(workflowContext))));
- });
+ return startExecution(() -> {
+ startedAt = Instant.now();
+ return status(WorkflowStatus.RUNNING)
+ .thenCompose(__ ->
+ publishEvent(
+ workflowContext,
+ l -> l.onWorkflowStarted(new WorkflowStartedEvent(workflowContext))));
+ });
}
protected final CompletableFuture startExecution(
@@ -122,43 +120,39 @@ public boolean cancel(boolean mayInterruptIfRunning) {
if (isInitializer) {
runnable
.get()
- .thenCompose(
- v ->
- TaskExecutorHelper.processTaskList(
- workflowContext.definition().startTask(),
- workflowContext,
- Optional.empty(),
- workflowContext
- .definition()
- .inputFilter()
- .map(f -> f.apply(workflowContext, null, input))
- .orElse(input))
- .whenComplete(this::setCompleteDate)
- .thenApply(this::filterAndValidate)
- .thenCompose(this::publishCompletionEvents)
- .exceptionallyCompose(this::handleException))
+ .thenCompose(v ->
+ TaskExecutorHelper.processTaskList(
+ workflowContext.definition().startTask(),
+ workflowContext,
+ Optional.empty(),
+ workflowContext
+ .definition()
+ .inputFilter()
+ .map(f -> f.apply(workflowContext, null, input))
+ .orElse(input))
+ .whenComplete(this::setCompleteDate)
+ .thenApply(this::filterAndValidate)
+ .thenCompose(this::publishCompletionEvents)
+ .exceptionallyCompose(this::handleException))
.handle(this::cleanUpWaitingListeners)
.thenCompose(Function.identity())
- .whenComplete(
- (result, ex) -> {
- if (ex != null) {
- future.completeExceptionally(
- ex instanceof CompletionException ? ex.getCause() : ex);
- } else {
- future.complete(result);
- }
- });
+ .whenComplete((result, ex) -> {
+ if (ex != null) {
+ future.completeExceptionally(ex instanceof CompletionException ? ex.getCause() : ex);
+ } else {
+ future.complete(result);
+ }
+ });
}
return future;
}
private CompletableFuture publishCompletionEvents(WorkflowModel model) {
return status(WorkflowStatus.COMPLETED)
- .thenCompose(
- __ ->
- publishEvent(
- workflowContext,
- l -> l.onWorkflowCompleted(new WorkflowCompletedEvent(workflowContext, model))))
+ .thenCompose(__ ->
+ publishEvent(
+ workflowContext,
+ l -> l.onWorkflowCompleted(new WorkflowCompletedEvent(workflowContext, model))))
.thenApply(__ -> model);
}
@@ -197,11 +191,10 @@ private CompletableFuture handleException(Throwable exception) {
return cause instanceof CancellationException
? CompletableFuture.failedFuture(cause)
: status(WorkflowStatus.FAULTED)
- .thenCompose(
- __ ->
- publishEvent(
- workflowContext,
- l -> l.onWorkflowFailed(new WorkflowFailedEvent(workflowContext, cause))))
+ .thenCompose(__ ->
+ publishEvent(
+ workflowContext,
+ l -> l.onWorkflowFailed(new WorkflowFailedEvent(workflowContext, cause))))
.thenCompose(__ -> CompletableFuture.failedFuture(exception));
}
@@ -260,10 +253,9 @@ public T outputAs(Class clazz) {
return output != null
? output
.as(clazz)
- .orElseThrow(
- () ->
- new IllegalArgumentException(
- "Output " + output + " cannot be converted to class " + clazz))
+ .orElseThrow(() ->
+ new IllegalArgumentException(
+ "Output " + output + " cannot be converted to class " + clazz))
: null;
}
@@ -316,13 +308,11 @@ public boolean suspend() {
if (result) {
outOfOrder(
publishStatusChange(prevState, WorkflowStatus.SUSPENDED)
- .thenCompose(
- changed ->
- publishEvent(
- changed,
- workflowContext,
- l ->
- l.onWorkflowSuspended(new WorkflowSuspendedEvent(workflowContext)))));
+ .thenCompose(changed ->
+ publishEvent(
+ changed,
+ workflowContext,
+ l -> l.onWorkflowSuspended(new WorkflowSuspendedEvent(workflowContext)))));
}
return result;
}
@@ -332,12 +322,11 @@ public CompletableFuture suspendFuture() {
WorkflowStatus prevState = internalSuspend();
return outOfOrder(
publishStatusChange(prevState, WorkflowStatus.SUSPENDED)
- .thenCompose(
- changed ->
- publishEvent(
- changed,
- workflowContext,
- l -> l.onWorkflowSuspended(new WorkflowSuspendedEvent(workflowContext)))));
+ .thenCompose(changed ->
+ publishEvent(
+ changed,
+ workflowContext,
+ l -> l.onWorkflowSuspended(new WorkflowSuspendedEvent(workflowContext)))));
}
private WorkflowStatus internalSuspend() {
@@ -365,12 +354,11 @@ public boolean resume() {
if (result) {
outOfOrder(
publishStatusChange(prevStatus, WorkflowStatus.RUNNING)
- .thenCompose(
- changed ->
- publishEvent(
- changed,
- workflowContext,
- l -> l.onWorkflowResumed(new WorkflowResumedEvent(workflowContext)))));
+ .thenCompose(changed ->
+ publishEvent(
+ changed,
+ workflowContext,
+ l -> l.onWorkflowResumed(new WorkflowResumedEvent(workflowContext)))));
}
return result;
}
@@ -380,12 +368,11 @@ public CompletableFuture resumeFuture() {
WorkflowStatus prevStatus = internalResume();
return outOfOrder(
publishStatusChange(prevStatus, WorkflowStatus.RUNNING)
- .thenCompose(
- change ->
- publishEvent(
- change,
- workflowContext,
- l -> l.onWorkflowResumed(new WorkflowResumedEvent(workflowContext)))));
+ .thenCompose(change ->
+ publishEvent(
+ change,
+ workflowContext,
+ l -> l.onWorkflowResumed(new WorkflowResumedEvent(workflowContext)))));
}
private WorkflowStatus internalResume() {
@@ -393,10 +380,9 @@ private WorkflowStatus internalResume() {
try {
statusLock.lock();
if (TaskExecutorHelper.isActive(status.get()) && suspended != null) {
- suspended.forEach(
- (k, v) -> {
- k.complete(v);
- });
+ suspended.forEach((k, v) -> {
+ k.complete(v);
+ });
suspended = null;
result = status.getAndSet(WorkflowStatus.RUNNING);
} else {
@@ -471,14 +457,11 @@ private CompletableFuture internalCancel() {
CompletableFuture result =
outOfOrder(
publishStatusChange(prevState, WorkflowStatus.CANCELLED)
- .thenCompose(
- changed ->
- publishEvent(
- changed,
- workflowContext,
- l ->
- l.onWorkflowCancelled(
- new WorkflowCancelledEvent(workflowContext)))));
+ .thenCompose(changed ->
+ publishEvent(
+ changed,
+ workflowContext,
+ l -> l.onWorkflowCancelled(new WorkflowCancelledEvent(workflowContext)))));
if (prevState != WorkflowStatus.CANCELLED && toCancel != null) {
toCancel.forEach(t -> t.cancel(true));
@@ -501,15 +484,14 @@ public void addCancelable(CompletableFuture> cancelable) {
} else {
cancelables.add(cancelable);
statusLock.unlock();
- cancelable.thenAccept(
- __ -> {
- try {
- statusLock.lock();
- cancelables.remove(cancelable);
- } finally {
- statusLock.unlock();
- }
- });
+ cancelable.thenAccept(__ -> {
+ try {
+ statusLock.lock();
+ cancelables.remove(cancelable);
+ } finally {
+ statusLock.unlock();
+ }
+ });
}
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProvider.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProvider.java
index dac605d9d..2d0969070 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProvider.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProvider.java
@@ -53,19 +53,16 @@ public CompletableFuture validateAndGet(WorkflowContext workflow, TaskConte
List issuers = authRequestInfo.issuers();
if (!issuers.isEmpty()) {
future =
- future.whenComplete(
- (jwt, ex) -> {
- if (jwt != null) {
- jwt.issuer()
- .ifPresent(
- issuer -> {
- if (!issuers.contains(issuer)) {
- throw new IllegalStateException(
- "Token issuer is not valid: " + issuer);
- }
- });
- }
- });
+ future.whenComplete((jwt, ex) -> {
+ if (jwt != null) {
+ jwt.issuer()
+ .ifPresent(issuer -> {
+ if (!issuers.contains(issuer)) {
+ throw new IllegalStateException("Token issuer is not valid: " + issuer);
+ }
+ });
+ }
+ });
}
return future;
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/DefaultAuthProviderFactory.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/DefaultAuthProviderFactory.java
index 363527a09..3c5ac055a 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/DefaultAuthProviderFactory.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/DefaultAuthProviderFactory.java
@@ -65,11 +65,10 @@ private Optional buildFromPolicy(
digestAuthProvider(app, workflow, authenticationPolicy.getDigestAuthenticationPolicy()));
}
return OAuthUtils.from(authenticationPolicy)
- .map(
- policyData ->
- policyData.scheme() == OAuthScheme.OPENID_CONNECT
- ? openIdAuthProvider(app, workflow, policyData)
- : oAuth2AuthProvider(app, workflow, policyData));
+ .map(policyData ->
+ policyData.scheme() == OAuthScheme.OPENID_CONNECT
+ ? openIdAuthProvider(app, workflow, policyData)
+ : oAuth2AuthProvider(app, workflow, policyData));
}
protected AuthProvider oAuth2AuthProvider(
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/DigestAuthProvider.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/DigestAuthProvider.java
index 5d5aefbf4..1effd3401 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/DigestAuthProvider.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/DigestAuthProvider.java
@@ -104,12 +104,12 @@ public static DigestServerInfo from(String header) {
private static enum Algorithm {
MD5,
MD5SESSS
- };
+ }
private static enum QOP {
AUTH,
AUTH_INT,
- };
+ }
private static final String HEX = "%08x";
private final WorkflowValueResolver userFilter;
@@ -147,14 +147,13 @@ public CompletableFuture content(
return app.httpRequestFactory()
.request(app, WorkflowHttpRequestInfo.builder(method).build(uri))
.invoke(workflow, task)
- .thenApply(
- r -> {
- try {
- return processResponse(r, uri, method, workflow, task);
- } finally {
- r.close();
- }
- });
+ .thenApply(r -> {
+ try {
+ return processResponse(r, uri, method, workflow, task);
+ } finally {
+ r.close();
+ }
+ });
}
private String processResponse(
@@ -188,15 +187,14 @@ private String processResponse(
nonceCount,
serverInfo
.qop
- .map(
- qop ->
- calculateHash(
- ha1,
- serverInfo.nonce,
- nonceCount,
- clientNonce,
- qop.toString().toLowerCase(),
- ha2))
+ .map(qop ->
+ calculateHash(
+ ha1,
+ serverInfo.nonce,
+ nonceCount,
+ clientNonce,
+ qop.toString().toLowerCase(),
+ ha2))
.orElseGet(() -> calculateHash(ha1, serverInfo.nonce, ha2)));
} else {
throw new IllegalStateException(
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/AbstractTaskExecutor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/AbstractTaskExecutor.java
index 26978e529..4957f0266 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/AbstractTaskExecutor.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/AbstractTaskExecutor.java
@@ -215,61 +215,52 @@ public CompletableFuture apply(
completable =
completable
.thenCompose(workflowContext.instance()::suspendedCheck)
- .thenCompose(
- t -> {
- CompletableFuture> events =
- t.isRetrying()
- ? publishEvent(
- workflowContext,
- l ->
- l.onTaskRetried(
- new TaskRetriedEvent(workflowContext, taskContext)))
- : publishEvent(
- workflowContext,
- l ->
- l.onTaskStarted(
- new TaskStartedEvent(workflowContext, taskContext)));
- return events.thenApply(v -> t);
- })
- .thenApply(
- t -> {
- inputSchemaValidator.ifPresent(
- s -> validationError(s.validate(t.rawInput()), t));
- inputProcessor.ifPresent(
- p -> taskContext.input(p.apply(workflowContext, t, t.rawInput())));
- return t;
- })
+ .thenCompose(t -> {
+ CompletableFuture> events =
+ t.isRetrying()
+ ? publishEvent(
+ workflowContext,
+ l ->
+ l.onTaskRetried(new TaskRetriedEvent(workflowContext, taskContext)))
+ : publishEvent(
+ workflowContext,
+ l ->
+ l.onTaskStarted(
+ new TaskStartedEvent(workflowContext, taskContext)));
+ return events.thenApply(v -> t);
+ })
+ .thenApply(t -> {
+ inputSchemaValidator.ifPresent(s -> validationError(s.validate(t.rawInput()), t));
+ inputProcessor.ifPresent(
+ p -> taskContext.input(p.apply(workflowContext, t, t.rawInput())));
+ return t;
+ })
.thenCompose(t -> execute(workflowContext, t))
.thenCompose(workflowContext.instance()::cancelCheck)
- .thenApply(
- t -> {
- outputProcessor.ifPresent(
- p -> t.output(p.apply(workflowContext, t, t.rawOutput())));
- outputSchemaValidator.ifPresent(
- s -> validationError(s.validate(t.output()), t));
- contextProcessor.ifPresent(
- p ->
- workflowContext.context(
- p.apply(workflowContext, t, workflowContext.context())));
- contextSchemaValidator.ifPresent(
- s -> validationError(s.validate(workflowContext.context()), t));
- t.completedAt(Instant.now());
- return t;
- })
- .thenCompose(
- t ->
- publishEvent(
- workflowContext,
- l ->
- l.onTaskCompleted(
- new TaskCompletedEvent(workflowContext, taskContext)))
- .thenApply(__ -> t))
- .exceptionallyCompose(
- e ->
- handleException(
+ .thenApply(t -> {
+ outputProcessor.ifPresent(
+ p -> t.output(p.apply(workflowContext, t, t.rawOutput())));
+ outputSchemaValidator.ifPresent(s -> validationError(s.validate(t.output()), t));
+ contextProcessor.ifPresent(p ->
+ workflowContext.context(
+ p.apply(workflowContext, t, workflowContext.context())));
+ contextSchemaValidator.ifPresent(
+ s -> validationError(s.validate(workflowContext.context()), t));
+ t.completedAt(Instant.now());
+ return t;
+ })
+ .thenCompose(t ->
+ publishEvent(
workflowContext,
- taskContext,
- e instanceof CompletionException ? e.getCause() : e));
+ l ->
+ l.onTaskCompleted(
+ new TaskCompletedEvent(workflowContext, taskContext)))
+ .thenApply(__ -> t))
+ .exceptionallyCompose(e ->
+ handleException(
+ workflowContext,
+ taskContext,
+ e instanceof CompletionException ? e.getCause() : e));
if (timeout.isPresent()) {
completable =
completable
@@ -279,14 +270,13 @@ public CompletableFuture apply(
.orElseThrow()
.toMillis(),
TimeUnit.MILLISECONDS)
- .exceptionallyCompose(
- e ->
- CompletableFuture.failedFuture(
- new WorkflowException(
- WorkflowError.timeout()
- .instance(taskContext.position().jsonPointer())
- .build(),
- e)));
+ .exceptionallyCompose(e ->
+ CompletableFuture.failedFuture(
+ new WorkflowException(
+ WorkflowError.timeout()
+ .instance(taskContext.position().jsonPointer())
+ .build(),
+ e)));
}
return executeNext(completable, workflowContext);
} else {
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/CallFunctionExecutorBuilder.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/CallFunctionExecutorBuilder.java
index bc5d35f14..9cfd49fbd 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/CallFunctionExecutorBuilder.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/CallFunctionExecutorBuilder.java
@@ -110,10 +110,9 @@ private Task from(WorkflowDefinition definition, String name, byte[] content) {
.application()
.functionReader()
.map(v -> v.apply(name, content))
- .orElseThrow(
- () ->
- new IllegalStateException(
- "No converter from external resource to function found. Make sure a dependency that includes an implementation of FunctionReader is included"));
+ .orElseThrow(() ->
+ new IllegalStateException(
+ "No converter from external resource to function found. Make sure a dependency that includes an implementation of FunctionReader is included"));
}
@Override
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/DefaultTaskExecutorFactory.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/DefaultTaskExecutorFactory.java
index 664c5b4d6..c7ab39e03 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/DefaultTaskExecutorFactory.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/DefaultTaskExecutorFactory.java
@@ -92,9 +92,8 @@ private CallableTaskBuilder findCallTask(
callTasks.stream()
.filter(s -> s.accept(clazz))
.findFirst()
- .orElseThrow(
- () ->
- new UnsupportedOperationException(
- clazz.getName() + " not accepted by any of these builders " + callTasks));
+ .orElseThrow(() ->
+ new UnsupportedOperationException(
+ clazz.getName() + " not accepted by any of these builders " + callTasks));
}
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/EmitExecutor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/EmitExecutor.java
index 455d97119..0b3316c49 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/EmitExecutor.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/EmitExecutor.java
@@ -99,13 +99,12 @@ private CloudEvent buildCloudEvent(WorkflowContext workflow, TaskContext taskCon
.sourceFilter()
.map(filter -> filter.apply(workflow, taskContext, taskContext.input()))
.map(URI::create)
- .orElseGet(
- () ->
- workflow
- .definition()
- .application()
- .defaultEventSource()
- .apply(workflow, taskContext, taskContext.input())));
+ .orElseGet(() ->
+ workflow
+ .definition()
+ .application()
+ .defaultEventSource()
+ .apply(workflow, taskContext, taskContext.input())));
ceBuilder.withType(
props
.typeFilter()
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/ForkExecutor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/ForkExecutor.java
index b51ad4b1b..0e3661cd1 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/ForkExecutor.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/ForkExecutor.java
@@ -80,21 +80,19 @@ protected CompletableFuture internalExecute(
}
return CompletableFuture.allOf(
futures.values().toArray(new CompletableFuture>[futures.size()]))
- .thenApply(
- i ->
- combine(
- workflow,
- futures.entrySet().stream()
- .collect(Collectors.toMap(Entry::getKey, e -> e.getValue().join()))));
+ .thenApply(i ->
+ combine(
+ workflow,
+ futures.entrySet().stream()
+ .collect(Collectors.toMap(Entry::getKey, e -> e.getValue().join()))));
}
private WorkflowModel combine(WorkflowContext context, Map futures) {
Stream> sortedStream =
futures.entrySet().stream()
- .sorted(
- (arg1, arg2) ->
- arg1.getValue().completedAt().compareTo(arg2.getValue().completedAt()));
+ .sorted((arg1, arg2) ->
+ arg1.getValue().completedAt().compareTo(arg2.getValue().completedAt()));
return compete
? sortedStream.map(e -> e.getValue().output()).findFirst().orElseThrow()
: context
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/ListenExecutor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/ListenExecutor.java
index f9f0a0ccd..fd0b25196 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/ListenExecutor.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/ListenExecutor.java
@@ -128,15 +128,14 @@ protected EventRegistrationInfo buildInfo(
untilRegBuilders, (ce, f) -> f.complete(null), eventConsumer, workflow, task);
untilInfo
.completableFuture()
- .whenComplete(
- (__, e) -> {
- untilInfo.registrations().forEach(eventConsumer::unregister);
- if (e == null) {
- info.completableFuture().complete(null);
- } else {
- info.completableFuture().completeExceptionally(e);
- }
- });
+ .whenComplete((__, e) -> {
+ untilInfo.registrations().forEach(eventConsumer::unregister);
+ if (e == null) {
+ info.completableFuture().complete(null);
+ } else {
+ info.completableFuture().completeExceptionally(e);
+ }
+ });
}
return info;
}
@@ -191,10 +190,9 @@ protected CompletableFuture internalExecute(
workflow.instance().addCancelable(info.completableFuture());
return info.completableFuture()
.whenComplete((__, e) -> info.registrations().forEach(eventConsumer::unregister))
- .thenCompose(
- __ ->
- CompletableFuture.allOf(
- waitingListeners.toArray(new CompletableFuture[waitingListeners.size()])))
+ .thenCompose(__ ->
+ CompletableFuture.allOf(
+ waitingListeners.toArray(new CompletableFuture[waitingListeners.size()])))
.handle((__, ___) -> output);
}
@@ -225,10 +223,8 @@ private void processCe(
taskContext.variables().put(at, arrayNode.size());
}
TaskExecutorHelper.processTaskList(t, workflow, Optional.of(taskContext), node)
- .thenAccept(
- n ->
- internalProcessCe(
- n, arrayNode, workflow, taskContext, future, waitingListeners));
+ .thenAccept(n ->
+ internalProcessCe(n, arrayNode, workflow, taskContext, future, waitingListeners));
},
() -> internalProcessCe(node, arrayNode, workflow, taskContext, future, waitingListeners));
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunScriptExecutorBuilder.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunScriptExecutorBuilder.java
index 669729693..99f049549 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunScriptExecutorBuilder.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunScriptExecutorBuilder.java
@@ -77,10 +77,9 @@ public CallableTask build(RunScript taskConfiguration, WorkflowDefinition defini
application.serviceLoadedClasses(ScriptRunner.class).stream()
.filter(s -> s.identifier().equals(language))
.findFirst()
- .orElseThrow(
- () ->
- new IllegalStateException(
- "No script runner implementation found for language " + language)));
+ .orElseThrow(() ->
+ new IllegalStateException(
+ "No script runner implementation found for language " + language)));
}
@Override
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunShellExecutor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunShellExecutor.java
index ee6ed1d74..eecdd850d 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunShellExecutor.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunShellExecutor.java
@@ -76,28 +76,25 @@ public CompletableFuture apply(
shellArguments.forEach(f -> commandAndArgs.add(f.apply(workflowContext, taskContext, model)));
ProcessBuilder builder = new ProcessBuilder(commandAndArgs);
- shellDirectory.ifPresent(
- directory ->
- builder.directory(new File(directory.apply(workflowContext, taskContext, model))));
+ shellDirectory.ifPresent(directory ->
+ builder.directory(new File(directory.apply(workflowContext, taskContext, model))));
shellEnv.ifPresent(
map -> ScriptUtils.addEnviromment(builder, map.apply(workflowContext, taskContext, model)));
return returnType
- .map(
- type ->
- CompletableFuture.supplyAsync(
- () ->
- ScriptUtils.buildResultFromProcess(
- workflowContext.definition(), uncheckedStart(builder), type, model),
- workflowContext.definition().application().executorService()))
- .orElseGet(
- () -> {
- workflowContext
- .definition()
- .application()
- .executorService()
- .submit(() -> uncheckedStart(builder));
- return CompletableFuture.completedFuture(model);
- });
+ .map(type ->
+ CompletableFuture.supplyAsync(
+ () ->
+ ScriptUtils.buildResultFromProcess(
+ workflowContext.definition(), uncheckedStart(builder), type, model),
+ workflowContext.definition().application().executorService()))
+ .orElseGet(() -> {
+ workflowContext
+ .definition()
+ .application()
+ .executorService()
+ .submit(() -> uncheckedStart(builder));
+ return CompletableFuture.completedFuture(model);
+ });
}
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunTaskExecutor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunTaskExecutor.java
index bf831a2eb..2a7181847 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunTaskExecutor.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunTaskExecutor.java
@@ -41,10 +41,9 @@ protected RunTaskExecutorBuilder(
.filter(r -> r.accept(config.getClass()))
.findFirst()
.map(r -> r.build(config, definition))
- .orElseThrow(
- () ->
- new UnsupportedOperationException(
- "No runnable found for operation " + config.getClass()));
+ .orElseThrow(() ->
+ new UnsupportedOperationException(
+ "No runnable found for operation " + config.getClass()));
}
@Override
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/TaskExecutorHelper.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/TaskExecutorHelper.java
index e17b08948..aa1b5bfe4 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/TaskExecutorHelper.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/TaskExecutorHelper.java
@@ -40,11 +40,10 @@ public static CompletableFuture processTaskList(
WorkflowModel input) {
return taskExecutor
.apply(context, parentTask, input)
- .thenApply(
- t -> {
- parentTask.ifPresent(p -> p.rawOutput(t.output()));
- return t.output();
- });
+ .thenApply(t -> {
+ parentTask.ifPresent(p -> p.rawOutput(t.output()));
+ return t.output();
+ });
}
public static boolean isActive(WorkflowContext context) {
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/TryExecutor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/TryExecutor.java
index f0012ae81..7abc97b1e 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/TryExecutor.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/TryExecutor.java
@@ -257,29 +257,27 @@ private CompletableFuture handleException(
}
if (catchTaskExecutor.isPresent()) {
completable =
- completable.thenCompose(
- model ->
- TaskExecutorHelper.processTaskList(
- catchTaskExecutor.get(), workflow, Optional.of(taskContext), model));
+ completable.thenCompose(model ->
+ TaskExecutorHelper.processTaskList(
+ catchTaskExecutor.get(), workflow, Optional.of(taskContext), model));
}
if (retryIntervalExecutor.isPresent()) {
completable =
- completable.thenCompose(
- model -> {
- Optional> retryCompletable =
- retryIntervalExecutor.orElseThrow().retry(workflow, taskContext, model);
- if (retryCompletable.isPresent()) {
- return retryCompletable
- .orElseThrow()
- .thenCompose(innerModel -> doIt(workflow, taskContext, innerModel));
- } else if (catchTransition.isPresent()) {
- taskContext.transition(catchTransition.orElseThrow());
- return CompletableFuture.completedFuture(model);
- } else {
- return CompletableFuture.failedFuture(exception);
- }
- });
+ completable.thenCompose(model -> {
+ Optional> retryCompletable =
+ retryIntervalExecutor.orElseThrow().retry(workflow, taskContext, model);
+ if (retryCompletable.isPresent()) {
+ return retryCompletable
+ .orElseThrow()
+ .thenCompose(innerModel -> doIt(workflow, taskContext, innerModel));
+ } else if (catchTransition.isPresent()) {
+ taskContext.transition(catchTransition.orElseThrow());
+ return CompletableFuture.completedFuture(model);
+ } else {
+ return CompletableFuture.failedFuture(exception);
+ }
+ });
} else {
catchTransition.ifPresent(t -> taskContext.transition(t));
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutor.java
index 5f10044da..ace70db0e 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutor.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutor.java
@@ -77,12 +77,9 @@ public CompletableFuture apply(
while (iter.hasNext()) {
final String uri = iter.next();
future =
- future.exceptionallyCompose(
- i ->
- WorkflowHttpRequestHelper.executeRequest(
- httpInfoBuilder.build(URI.create(uri)),
- workflowContext,
- taskContext));
+ future.exceptionallyCompose(i ->
+ WorkflowHttpRequestHelper.executeRequest(
+ httpInfoBuilder.build(URI.create(uri)), workflowContext, taskContext));
}
return future;
},
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutorBuilder.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutorBuilder.java
index 6e4ea725c..7ff10ebc9 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutorBuilder.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutorBuilder.java
@@ -54,9 +54,8 @@ public CallableTaskFactory init(
private UnifiedOpenAPIReader reader(WorkflowApplication app) {
return app.additionalObject(UnifiedOpenAPIReader.UNIFIED_OPEN_API_READER)
- .orElseThrow(
- () ->
- new IllegalStateException(
- "Missing UnifiedOpenAPIReader, please make sure dependency openworkflow-impl-openapi is included"));
+ .orElseThrow(() ->
+ new IllegalStateException(
+ "Missing UnifiedOpenAPIReader, please make sure dependency openworkflow-impl-openapi is included"));
}
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIProcessor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIProcessor.java
index 006d83519..9267576c7 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIProcessor.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIProcessor.java
@@ -29,8 +29,7 @@ class OpenAPIProcessor {
OperationDefinition parse(UnifiedOpenAPI unifiedOpenAPI) {
Optional operationDefinition =
unifiedOpenAPI.findOperationById(this.operationId);
- return operationDefinition.orElseThrow(
- () ->
- new IllegalArgumentException("Operation with ID '" + this.operationId + "' not found"));
+ return operationDefinition.orElseThrow(() ->
+ new IllegalArgumentException("Operation with ID '" + this.operationId + "' not found"));
}
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationDefinition.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationDefinition.java
index 33c50dd7a..bfaed8f03 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationDefinition.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationDefinition.java
@@ -74,24 +74,23 @@ List getParameters() {
&& operation.hasParameters()) {
operation.parameters().stream()
.filter(p -> "body".equals(p.in()))
- .forEach(
- p -> {
- UnifiedOpenAPI.Schema schema = p.schema();
- if (schema != null && schema.hasRef()) {
- String ref = schema.ref();
- schema = openAPI.resolveSchema(ref);
- }
-
- if (schema != null && schema.hasProperties()) {
- Map properties = schema.properties();
- for (String fieldName : properties.keySet()) {
- UnifiedOpenAPI.Schema fieldSchema = properties.get(fieldName);
- boolean isRequired = schema.requiredFields().contains(fieldName);
- paramDefinitions.add(
- new ParameterDefinition(fieldName, "body", isRequired, fieldSchema));
- }
- }
- });
+ .forEach(p -> {
+ UnifiedOpenAPI.Schema schema = p.schema();
+ if (schema != null && schema.hasRef()) {
+ String ref = schema.ref();
+ schema = openAPI.resolveSchema(ref);
+ }
+
+ if (schema != null && schema.hasProperties()) {
+ Map properties = schema.properties();
+ for (String fieldName : properties.keySet()) {
+ UnifiedOpenAPI.Schema fieldSchema = properties.get(fieldName);
+ boolean isRequired = schema.requiredFields().contains(fieldName);
+ paramDefinitions.add(
+ new ParameterDefinition(fieldName, "body", isRequired, fieldSchema));
+ }
+ }
+ });
}
if (operation.hasRequestBody()) {
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/http/DefaultHttpRequest.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/http/DefaultHttpRequest.java
index a84cf0d5a..3ed6769f9 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/http/DefaultHttpRequest.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/http/DefaultHttpRequest.java
@@ -68,10 +68,8 @@ public CompletableFuture invoke(
httpInfo, builder::header, workflowContext, taskContext)
.thenCompose(
__ -> client.sendAsync(builder.build(), HttpResponse.BodyHandlers.ofByteArray()))
- .exceptionallyCompose(
- ex ->
- CompletableFuture.failedFuture(
- WorkflowHttpRequestHelper.fromError(ex, taskContext)))
+ .exceptionallyCompose(ex ->
+ CompletableFuture.failedFuture(WorkflowHttpRequestHelper.fromError(ex, taskContext)))
.thenApply(response -> new DefaultHttpResponse(app, taskContext, response));
}
@@ -92,20 +90,18 @@ private BodyPublisher buildBody() {
case WorkflowHttpContentType.APPLICATION_JSON ->
HttpRequest.BodyPublishers.ofByteArray(
body.asJson()
- .orElseThrow(
- () ->
- new IllegalStateException(
- "Underlying model needs to support json in order to use application-json content type")));
+ .orElseThrow(() ->
+ new IllegalStateException(
+ "Underlying model needs to support json in order to use application-json content type")));
case WorkflowHttpContentType.APPLICATION_X_WWW_FORM_URLENCODED ->
HttpRequest.BodyPublishers.ofString(
encodeMap(
httpInfo
.body()
.asMap()
- .orElseThrow(
- () ->
- new IllegalStateException(
- "Underlying model needs to support asMap in order to use form urlencoded content type")),
+ .orElseThrow(() ->
+ new IllegalStateException(
+ "Underlying model needs to support asMap in order to use form urlencoded content type")),
DefaultHttpRequest::encodeForm));
};
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/http/WorkflowHttpRequestHelper.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/http/WorkflowHttpRequestHelper.java
index 7160faf68..afdf36dee 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/http/WorkflowHttpRequestHelper.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/http/WorkflowHttpRequestHelper.java
@@ -39,20 +39,18 @@ public static CompletableFuture executeRequest(
WorkflowHttpRequestInfo requestInfo, WorkflowContext workflow, TaskContext taskContext) {
return asWorkflowHtppResponse(
requestInfo, workflow.definition().application(), workflow, taskContext)
- .thenApply(
- response -> {
- try {
- validateStatus(taskContext, requestInfo, response);
- return response
- .asWorkflowModel()
- .orElseThrow(
- () ->
- new IllegalStateException(
- "Unable to extract WorkflowModel from response " + response));
- } finally {
- response.close();
- }
- });
+ .thenApply(response -> {
+ try {
+ validateStatus(taskContext, requestInfo, response);
+ return response
+ .asWorkflowModel()
+ .orElseThrow(() ->
+ new IllegalStateException(
+ "Unable to extract WorkflowModel from response " + response));
+ } finally {
+ response.close();
+ }
+ });
}
public static CompletableFuture executeRequest(
@@ -61,15 +59,14 @@ public static CompletableFuture executeRequest(
WorkflowContext workflow,
TaskContext taskContext) {
return asWorkflowHtppResponse(requestInfo, app, workflow, taskContext)
- .thenApply(
- response -> {
- try {
- validateStatus(taskContext, requestInfo, response);
- return response.asByteArray();
- } finally {
- response.close();
- }
- });
+ .thenApply(response -> {
+ try {
+ validateStatus(taskContext, requestInfo, response);
+ return response.asByteArray();
+ } finally {
+ response.close();
+ }
+ });
}
public static CompletableFuture asWorkflowHtppResponse(
@@ -128,14 +125,13 @@ private static CompletableFuture> addAuthHeader(
TaskContext task) {
String scheme = auth.scheme();
return auth.content(workflow, task, info.uri(), info.method())
- .thenAccept(
- parameter -> {
- if (task != null) {
- task.authorization(scheme, parameter);
- }
- headerFiller.accept(
- AuthUtils.AUTH_HEADER_NAME, AuthUtils.authHeaderValue(scheme, parameter));
- });
+ .thenAccept(parameter -> {
+ if (task != null) {
+ task.authorization(scheme, parameter);
+ }
+ headerFiller.accept(
+ AuthUtils.AUTH_HEADER_NAME, AuthUtils.authHeaderValue(scheme, parameter));
+ });
}
private static boolean isSuccessful(int status) {
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/marshaller/AbstractOutputBuffer.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/marshaller/AbstractOutputBuffer.java
index 7b0063b93..39a8cf3ec 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/marshaller/AbstractOutputBuffer.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/marshaller/AbstractOutputBuffer.java
@@ -47,11 +47,10 @@ public > WorkflowOutputBuffer writeEnum(T value) {
@Override
public WorkflowOutputBuffer writeMap(Map map) {
writeInt(map.size());
- map.forEach(
- (k, v) -> {
- writeString(k);
- writeObject(v);
- });
+ map.forEach((k, v) -> {
+ writeString(k);
+ writeObject(v);
+ });
return this;
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/resources/DefaultResourceLoader.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/resources/DefaultResourceLoader.java
index c06d0f252..7d3a04dfa 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/resources/DefaultResourceLoader.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/resources/DefaultResourceLoader.java
@@ -86,11 +86,10 @@ protected CompletableFuture loadURI(
? reload(resourceHandler, function, workflowContext, taskContext)
: resourceHandler
.shouldReload(cached.lastReload(), workflowContext, taskContext)
- .thenCompose(
- changed ->
- changed
- ? reload(resourceHandler, function, workflowContext, taskContext)
- : CompletableFuture.completedFuture((T) cached.content()));
+ .thenCompose(changed ->
+ changed
+ ? reload(resourceHandler, function, workflowContext, taskContext)
+ : CompletableFuture.completedFuture((T) cached.content()));
}
private CompletableFuture reload(
@@ -101,16 +100,15 @@ private CompletableFuture reload(
Instant lastReload = Instant.now();
return resourceHandler
.load(workflowContext, taskContext)
- .thenApply(
- bytes -> {
- T content = function.apply(resourceHandler.name(), bytes);
- resourceCache.compute(
- resourceHandler,
- (k, v) ->
- v == null || v.lastReload().isBefore(lastReload)
- ? new CachedResource(lastReload, content)
- : v);
- return content;
- });
+ .thenApply(bytes -> {
+ T content = function.apply(resourceHandler.name(), bytes);
+ resourceCache.compute(
+ resourceHandler,
+ (k, v) ->
+ v == null || v.lastReload().isBefore(lastReload)
+ ? new CachedResource(lastReload, content)
+ : v);
+ return content;
+ });
}
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/resources/HttpResource.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/resources/HttpResource.java
index aa80229ab..d6e28edee 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/resources/HttpResource.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/resources/HttpResource.java
@@ -71,13 +71,12 @@ public CompletableFuture shouldReload(
application,
workflowContext,
taskContext)
- .thenApply(
- response -> {
- try (response) {
- return response.status() != HttpURLConnection.HTTP_NOT_MODIFIED
- && checkLastModified(response.lastModified(), millis);
- }
- });
+ .thenApply(response -> {
+ try (response) {
+ return response.status() != HttpURLConnection.HTTP_NOT_MODIFIED
+ && checkLastModified(response.lastModified(), millis);
+ }
+ });
}
private boolean checkLastModified(OptionalLong lastModified, long millis) {
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/DefaultWorkflowScheduler.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/DefaultWorkflowScheduler.java
index 791919323..8ce1859c3 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/DefaultWorkflowScheduler.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/DefaultWorkflowScheduler.java
@@ -54,13 +54,12 @@ public CronResolverCancellable(WorkflowDefinition definition, CronResolver cronR
private void scheduleNext() {
cronResolver
.nextExecution()
- .ifPresent(
- d ->
- nextCron.set(
- service.schedule(
- new CronResolverIntanceRunner(definition),
- d.toMillis(),
- TimeUnit.MILLISECONDS)));
+ .ifPresent(d ->
+ nextCron.set(
+ service.schedule(
+ new CronResolverIntanceRunner(definition),
+ d.toMillis(),
+ TimeUnit.MILLISECONDS)));
}
@Override
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/ScheduledEventConsumer.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/ScheduledEventConsumer.java
index c8d2775db..7f50f5145 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/ScheduledEventConsumer.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/ScheduledEventConsumer.java
@@ -59,11 +59,10 @@ public ScheduledEventConsumer(
Collection registrationBuilders =
builderInfo.registrations().registrations();
allStrategyCorrelationInfo.init(registrationBuilders, this::start);
- registrationBuilders.forEach(
- reg ->
- registrations.add(
- eventConsumer.register(
- reg, ce -> allStrategyCorrelationInfo.correlate(reg, (CloudEvent) ce))));
+ registrationBuilders.forEach(reg ->
+ registrations.add(
+ eventConsumer.register(
+ reg, ce -> allStrategyCorrelationInfo.correlate(reg, (CloudEvent) ce))));
} else {
builderInfo
.registrations()
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/ScheduledInstanceRunnable.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/ScheduledInstanceRunnable.java
index 1b3ca419f..ae0aed7f9 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/ScheduledInstanceRunnable.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/scheduler/ScheduledInstanceRunnable.java
@@ -52,19 +52,17 @@ private static void runScheduledInstance(
definition
.application()
.executorService()
- .execute(
- () ->
- instance
- .start()
- .whenComplete(
- (model, ex) -> {
- if (ex != null) {
- logger.error(
- "Scheduled workflow instance {} of definition {} has failed",
- instance.id(),
- definition.id(),
- ex);
- }
- }));
+ .execute(() ->
+ instance
+ .start()
+ .whenComplete((model, ex) -> {
+ if (ex != null) {
+ logger.error(
+ "Scheduled workflow instance {} of definition {} has failed",
+ instance.id(),
+ definition.id(),
+ ex);
+ }
+ }));
}
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/schema/AbstractSchemaValidator.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/schema/AbstractSchemaValidator.java
index 0b6f70c4a..e7f7b5509 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/schema/AbstractSchemaValidator.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/schema/AbstractSchemaValidator.java
@@ -33,16 +33,14 @@ public Optional validate(WorkflowModel model) {
return validate(
model
.as(validationClass)
- .orElseThrow(
- () ->
- new IllegalStateException(
- "Model cannot be converted to proper schema validation class "
- + validationClass)))
- .map(
- s ->
- WorkflowError.error(Errors.VALIDATION.toString(), Errors.VALIDATION.status())
- .title("Schema validation errors")
- .details(s));
+ .orElseThrow(() ->
+ new IllegalStateException(
+ "Model cannot be converted to proper schema validation class "
+ + validationClass)))
+ .map(s ->
+ WorkflowError.error(Errors.VALIDATION.toString(), Errors.VALIDATION.status())
+ .title("Schema validation errors")
+ .details(s));
}
protected abstract Optional validate(T object);
diff --git a/impl/http/src/main/java/org/openworkflow/sdk/impl/jakarta/http/JakartaRequestExecutor.java b/impl/http/src/main/java/org/openworkflow/sdk/impl/jakarta/http/JakartaRequestExecutor.java
index 7de745728..08ee26796 100644
--- a/impl/http/src/main/java/org/openworkflow/sdk/impl/jakarta/http/JakartaRequestExecutor.java
+++ b/impl/http/src/main/java/org/openworkflow/sdk/impl/jakarta/http/JakartaRequestExecutor.java
@@ -84,23 +84,21 @@ public CompletableFuture invoke(
}
return WorkflowHttpRequestHelper.processAuth(
requestInfo, request::header, workflowContext, taskContext)
- .thenCompose(
- __ ->
- doRequest(
- request,
- HttpConverterResolver.converter(application, workflowContext, taskContext),
- taskContext))
- .exceptionallyCompose(
- ex ->
- ex instanceof WebApplicationException webAppEx
- ? CompletableFuture.failedFuture(
- new WorkflowException(
- WorkflowError.communication(
- webAppEx.getResponse().getStatus(), taskContext, webAppEx)
- .build(),
- webAppEx))
- : CompletableFuture.failedFuture(
- WorkflowHttpRequestHelper.fromError(ex, taskContext)));
+ .thenCompose(__ ->
+ doRequest(
+ request,
+ HttpConverterResolver.converter(application, workflowContext, taskContext),
+ taskContext))
+ .exceptionallyCompose(ex ->
+ ex instanceof WebApplicationException webAppEx
+ ? CompletableFuture.failedFuture(
+ new WorkflowException(
+ WorkflowError.communication(
+ webAppEx.getResponse().getStatus(), taskContext, webAppEx)
+ .build(),
+ webAppEx))
+ : CompletableFuture.failedFuture(
+ WorkflowHttpRequestHelper.fromError(ex, taskContext)));
}
private Entity> buildBody(HttpModelConverter converter) {
@@ -115,10 +113,9 @@ private Entity