Skip to content

Commit 307fdd4

Browse files
committed
[Fix #1489] Alternative approach
Signed-off-by: fjtirado <ftirados@ibm.com>
1 parent ae0d727 commit 307fdd4

40 files changed

Lines changed: 667 additions & 575 deletions

File tree

api/src/main/java/io/serverlessworkflow/api/WorkflowWriter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.io.Writer;
2323
import java.nio.file.Files;
2424
import java.nio.file.Path;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
2527

2628
/**
2729
* Utility class for writing Serverless Workflow definitions to various outputs and formats.
@@ -32,6 +34,8 @@
3234
*/
3335
public class WorkflowWriter {
3436

37+
private static final Logger logger = LoggerFactory.getLogger(WorkflowWriter.class);
38+
3539
/**
3640
* Writes a {@link Workflow} to the given {@link OutputStream} in the specified format.
3741
*
@@ -95,7 +99,9 @@ public static void writeWorkflow(Path output, Workflow workflow, WorkflowFormat
9599
*/
96100
public static String workflowAsString(Workflow workflow, WorkflowFormat format)
97101
throws IOException {
98-
return format.mapper().writeValueAsString(workflow);
102+
String result = format.mapper().writeValueAsString(workflow);
103+
logger.trace("Workflow is {}", result);
104+
return result;
99105
}
100106

101107
/**

experimental/fluent/func/pom.xml

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,42 +33,17 @@
3333
<groupId>io.cloudevents</groupId>
3434
<artifactId>cloudevents-core</artifactId>
3535
</dependency>
36+
3637
<dependency>
3738
<groupId>org.junit.jupiter</groupId>
38-
<artifactId>junit-jupiter-engine</artifactId>
39-
<scope>test</scope>
40-
</dependency>
41-
<dependency>
42-
<groupId>org.junit.jupiter</groupId>
43-
<artifactId>junit-jupiter-params</artifactId>
44-
<scope>test</scope>
45-
</dependency>
46-
<dependency>
47-
<groupId>org.assertj</groupId>
48-
<artifactId>assertj-core</artifactId>
39+
<artifactId>junit-jupiter-api</artifactId>
4940
<scope>test</scope>
5041
</dependency>
5142
<dependency>
5243
<groupId>org.mockito</groupId>
5344
<artifactId>mockito-core</artifactId>
45+
<version>${version.org.mockito}</version>
5446
<scope>test</scope>
5547
</dependency>
56-
<dependency>
57-
<groupId>io.serverlessworkflow</groupId>
58-
<artifactId>serverlessworkflow-api</artifactId>
59-
<scope>test</scope>
60-
</dependency>
61-
<dependency>
62-
<groupId>ch.qos.logback</groupId>
63-
<artifactId>logback-classic</artifactId>
64-
<scope>test</scope>
65-
</dependency>
66-
67-
<dependency>
68-
<groupId>io.serverlessworkflow</groupId>
69-
<artifactId>serverlessworkflow-experimental-fluent-serialization-jackson</artifactId>
70-
<scope>test</scope>
71-
</dependency>
72-
7348
</dependencies>
7449
</project>

experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncCallTaskBuilder.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package io.serverlessworkflow.fluent.func;
1717

18+
import io.serverlessworkflow.api.types.CallTask;
1819
import io.serverlessworkflow.api.types.func.CallJava;
19-
import io.serverlessworkflow.api.types.func.CallTaskJava;
2020
import io.serverlessworkflow.api.types.func.ContextFunction;
2121
import io.serverlessworkflow.api.types.func.FilterFunction;
2222
import io.serverlessworkflow.fluent.func.spi.ConditionalTaskBuilder;
@@ -29,12 +29,9 @@ public class FuncCallTaskBuilder extends TaskBaseBuilder<FuncCallTaskBuilder>
2929
implements FuncTaskTransformations<FuncCallTaskBuilder>,
3030
ConditionalTaskBuilder<FuncCallTaskBuilder> {
3131

32-
private CallTaskJava callTaskJava;
32+
private CallTask callTaskJava;
3333

34-
FuncCallTaskBuilder() {
35-
callTaskJava = new CallTaskJava(new CallJava() {});
36-
super.setTask(callTaskJava.getCallJava());
37-
}
34+
FuncCallTaskBuilder() {}
3835

3936
@Override
4037
protected FuncCallTaskBuilder self() {
@@ -51,8 +48,9 @@ public <T, V> FuncCallTaskBuilder function(Function<T, V> function, Class<T> arg
5148

5249
public <T, V> FuncCallTaskBuilder function(
5350
Function<T, V> function, Class<T> argClass, Class<V> returnClass) {
54-
this.callTaskJava = new CallTaskJava(CallJava.function(function, argClass, returnClass));
55-
super.setTask(this.callTaskJava.getCallJava());
51+
this.callTaskJava =
52+
new CallTask().withCallFunction(CallJava.function(function, argClass, returnClass));
53+
super.setTask(this.callTaskJava.getCallFunction());
5654
return this;
5755
}
5856

@@ -66,8 +64,9 @@ public <T, V> FuncCallTaskBuilder function(ContextFunction<T, V> function, Class
6664

6765
public <T, V> FuncCallTaskBuilder function(
6866
ContextFunction<T, V> function, Class<T> argClass, Class<V> returnClass) {
69-
this.callTaskJava = new CallTaskJava(CallJava.function(function, argClass, returnClass));
70-
super.setTask(this.callTaskJava.getCallJava());
67+
this.callTaskJava =
68+
new CallTask().withCallFunction(CallJava.function(function, argClass, returnClass));
69+
super.setTask(this.callTaskJava.getCallFunction());
7170
return this;
7271
}
7372

@@ -81,26 +80,27 @@ public <T, V> FuncCallTaskBuilder function(FilterFunction<T, V> function, Class<
8180

8281
public <T, V> FuncCallTaskBuilder function(
8382
FilterFunction<T, V> function, Class<T> argClass, Class<V> outputClass) {
84-
this.callTaskJava = new CallTaskJava(CallJava.function(function, argClass, outputClass));
85-
super.setTask(this.callTaskJava.getCallJava());
83+
this.callTaskJava =
84+
new CallTask().withCallFunction(CallJava.function(function, argClass, outputClass));
85+
super.setTask(this.callTaskJava.getCallFunction());
8686
return this;
8787
}
8888

8989
/** Accept a side-effect Consumer; engine should pass input through unchanged. */
9090
public <T> FuncCallTaskBuilder consumer(Consumer<T> consumer) {
91-
this.callTaskJava = new CallTaskJava(CallJava.consumer(consumer));
92-
super.setTask(this.callTaskJava.getCallJava());
91+
this.callTaskJava = new CallTask().withCallFunction(CallJava.consumer(consumer));
92+
super.setTask(this.callTaskJava.getCallFunction());
9393
return this;
9494
}
9595

9696
/** Accept a Consumer with explicit input type hint. */
9797
public <T> FuncCallTaskBuilder consumer(Consumer<T> consumer, Class<T> argClass) {
98-
this.callTaskJava = new CallTaskJava(CallJava.consumer(consumer, argClass));
99-
super.setTask(this.callTaskJava.getCallJava());
98+
this.callTaskJava = new CallTask().withCallFunction(CallJava.consumer(consumer, argClass));
99+
super.setTask(this.callTaskJava.getCallFunction());
100100
return this;
101101
}
102102

103-
public CallTaskJava build() {
103+
public CallTask build() {
104104
return this.callTaskJava;
105105
}
106106
}

experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncForTaskBuilder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*/
1616
package io.serverlessworkflow.fluent.func;
1717

18+
import io.serverlessworkflow.api.types.CallTask;
1819
import io.serverlessworkflow.api.types.ForTaskConfiguration;
1920
import io.serverlessworkflow.api.types.Task;
2021
import io.serverlessworkflow.api.types.TaskItem;
2122
import io.serverlessworkflow.api.types.func.CallJava;
22-
import io.serverlessworkflow.api.types.func.CallTaskJava;
2323
import io.serverlessworkflow.api.types.func.ForTaskFunction;
2424
import io.serverlessworkflow.api.types.func.LoopFunction;
2525
import io.serverlessworkflow.api.types.func.LoopPredicate;
@@ -84,9 +84,10 @@ public <T, V, R> FuncForTaskBuilder tasks(String name, LoopFunction<T, V, R> fun
8484
name,
8585
new Task()
8686
.withCallTask(
87-
new CallTaskJava(
88-
CallJava.loopFunction(
89-
function, this.forTaskFunction.getFor().getEach())))));
87+
new CallTask()
88+
.withCallFunction(
89+
CallJava.loopFunction(
90+
function, this.forTaskFunction.getFor().getEach())))));
9091
return this;
9192
}
9293

experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncForkTaskBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*/
1616
package io.serverlessworkflow.fluent.func;
1717

18+
import io.serverlessworkflow.api.types.CallTask;
1819
import io.serverlessworkflow.api.types.Task;
1920
import io.serverlessworkflow.api.types.TaskItem;
2021
import io.serverlessworkflow.api.types.func.CallJava;
21-
import io.serverlessworkflow.api.types.func.CallTaskJava;
2222
import io.serverlessworkflow.fluent.func.spi.ConditionalTaskBuilder;
2323
import io.serverlessworkflow.fluent.func.spi.FuncTaskTransformations;
2424
import io.serverlessworkflow.fluent.spec.AbstractForkTaskBuilder;
@@ -61,7 +61,8 @@ public <T, V> FuncForkTaskBuilder branch(
6161
this.defaultBranchName(name, this.currentOffset()),
6262
new Task()
6363
.withCallTask(
64-
new CallTaskJava(CallJava.function(function, argParam, returnClass)))));
64+
new CallTask()
65+
.withCallFunction(CallJava.function(function, argParam, returnClass)))));
6566
return this;
6667
}
6768

experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/FuncDSL.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ public static <T, V> FuncTaskConfigurer forEach(
15991599
}
16001600

16011601
public static <T, V> FuncTaskConfigurer forEachItem(
1602-
SerializableFunction<T, Collection<V>> collection, Function<V, ?> function) {
1602+
SerializableFunction<T, Collection<V>> collection, SerializableFunction<V, ?> function) {
16031603
return forEachItem(null, collection, function);
16041604
}
16051605

experimental/fluent/func/src/test/java/io/serverlessworkflow/fluent/func/FuncDSLSerializationTest.java

Lines changed: 0 additions & 115 deletions
This file was deleted.

experimental/fluent/func/src/test/resources/logback_test.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

experimental/fluent/jackson/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88
<artifactId>serverlessworkflow-experimental-fluent-serialization-jackson</artifactId>
99
<name>Serverless Workflow :: Experimental :: Fluent :: Serialization:: Jackson</name>
1010
<dependencies>
11-
<dependency>
11+
<dependency>
1212
<groupId>com.fasterxml.jackson.dataformat</groupId>
1313
<artifactId>jackson-dataformat-yaml</artifactId>
1414
</dependency>
15+
<dependency>
16+
<groupId>com.fasterxml.jackson.datatype</groupId>
17+
<artifactId>jackson-datatype-jdk8</artifactId>
18+
</dependency>
1519
<dependency>
1620
<groupId>io.serverlessworkflow</groupId>
1721
<artifactId>serverlessworkflow-experimental-types</artifactId>

0 commit comments

Comments
 (0)