Skip to content

Commit 242d489

Browse files
committed
Add documentation, tests, wrap up nodes
Signed-off-by: Ricardo Zanini <[email protected]>
1 parent 4389734 commit 242d489

File tree

82 files changed

+1403
-635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1403
-635
lines changed

impl/test/pom.xml

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,75 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2-
<modelVersion>4.0.0</modelVersion>
3-
<parent>
4-
<groupId>io.serverlessworkflow</groupId>
5-
<artifactId>serverlessworkflow-impl</artifactId>
6-
<version>8.0.0-SNAPSHOT</version>
7-
</parent>
8-
<artifactId>serverlessworkflow-impl-test</artifactId>
9-
<name> Serverless Workflow :: Impl :: Test </name>
10-
<dependencies>
11-
<dependency>
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
125
<groupId>io.serverlessworkflow</groupId>
13-
<artifactId>serverlessworkflow-impl-jackson</artifactId>
14-
</dependency>
15-
<dependency>
16-
<groupId>io.serverlessworkflow</groupId>
17-
<artifactId>serverlessworkflow-api</artifactId>
18-
</dependency>
19-
<dependency>
20-
<groupId>io.serverlessworkflow</groupId>
21-
<artifactId>serverlessworkflow-impl-http</artifactId>
22-
</dependency>
23-
<dependency>
24-
<groupId>io.serverlessworkflow</groupId>
25-
<artifactId>serverlessworkflow-impl-jackson-jwt</artifactId>
26-
</dependency>
27-
<dependency>
28-
<groupId>org.glassfish.jersey.media</groupId>
29-
<artifactId>jersey-media-json-jackson</artifactId>
30-
</dependency>
31-
<dependency>
32-
<groupId>org.glassfish.jersey.core</groupId>
33-
<artifactId>jersey-client</artifactId>
34-
</dependency>
35-
<dependency>
36-
<groupId>org.junit.jupiter</groupId>
37-
<artifactId>junit-jupiter-engine</artifactId>
38-
</dependency>
39-
<dependency>
40-
<groupId>org.junit.jupiter</groupId>
41-
<artifactId>junit-jupiter-params</artifactId>
42-
</dependency>
43-
<dependency>
44-
<groupId>org.assertj</groupId>
45-
<artifactId>assertj-core</artifactId>
46-
</dependency>
47-
<dependency>
48-
<groupId>ch.qos.logback</groupId>
49-
<artifactId>logback-classic</artifactId>
50-
</dependency>
51-
<dependency>
52-
<groupId>org.mockito</groupId>
53-
<artifactId>mockito-core</artifactId>
54-
</dependency>
55-
<dependency>
56-
<groupId>com.squareup.okhttp3</groupId>
57-
<artifactId>mockwebserver</artifactId>
58-
</dependency>
59-
</dependencies>
6+
<artifactId>serverlessworkflow-impl</artifactId>
7+
<version>8.0.0-SNAPSHOT</version>
8+
</parent>
9+
<artifactId>serverlessworkflow-impl-test</artifactId>
10+
<name>Serverless Workflow :: Impl :: Test</name>
11+
<dependencies>
12+
<dependency>
13+
<groupId>io.serverlessworkflow</groupId>
14+
<artifactId>serverlessworkflow-impl-jackson</artifactId>
15+
</dependency>
16+
<dependency>
17+
<groupId>io.serverlessworkflow</groupId>
18+
<artifactId>serverlessworkflow-api</artifactId>
19+
</dependency>
20+
<dependency>
21+
<groupId>io.serverlessworkflow</groupId>
22+
<artifactId>serverlessworkflow-impl-http</artifactId>
23+
</dependency>
24+
<dependency>
25+
<groupId>io.serverlessworkflow</groupId>
26+
<artifactId>serverlessworkflow-impl-jackson-jwt</artifactId>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.glassfish.jersey.media</groupId>
30+
<artifactId>jersey-media-json-jackson</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.glassfish.jersey.core</groupId>
34+
<artifactId>jersey-client</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.junit.jupiter</groupId>
38+
<artifactId>junit-jupiter-engine</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.junit.jupiter</groupId>
42+
<artifactId>junit-jupiter-params</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.assertj</groupId>
46+
<artifactId>assertj-core</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>ch.qos.logback</groupId>
50+
<artifactId>logback-classic</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.mockito</groupId>
54+
<artifactId>mockito-core</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>com.squareup.okhttp3</groupId>
58+
<artifactId>mockwebserver</artifactId>
59+
</dependency>
60+
</dependencies>
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<artifactId>maven-jar-plugin</artifactId>
65+
<executions>
66+
<execution>
67+
<goals>
68+
<goal>test-jar</goal>
69+
</goals>
70+
</execution>
71+
</executions>
72+
</plugin>
73+
</plugins>
74+
</build>
6075
</project>

impl/test/src/test/java/io/serverlessworkflow/impl/test/EventDefinitionTest.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ void testEventsListened(String listen, String emit1, String emit2, JsonNode expe
9393
void testForEachInAnyIsExecutedAsEventArrive() throws IOException, InterruptedException {
9494
WorkflowDefinition listenDefinition =
9595
appl.workflowDefinition(
96-
WorkflowReader.readWorkflowFromClasspath("listen-to-any-until.yaml"));
96+
WorkflowReader.readWorkflowFromClasspath("workflows-samples/listen-to-any-until.yaml"));
9797
WorkflowDefinition emitDoctorDefinition =
98-
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("emit-doctor.yaml"));
98+
appl.workflowDefinition(
99+
WorkflowReader.readWorkflowFromClasspath("workflows-samples/emit-doctor.yaml"));
99100
WorkflowInstance waitingInstance = listenDefinition.instance(Map.of());
100101
CompletableFuture<WorkflowModel> future = waitingInstance.start();
101102
assertThat(waitingInstance.status()).isEqualTo(WorkflowStatus.WAITING);
@@ -116,22 +117,29 @@ private static Instant getInstant(ArrayNode result, int index) {
116117

117118
private static Stream<Arguments> eventListenerParameters() {
118119
return Stream.of(
119-
Arguments.of("listen-to-any.yaml", "emit.yaml", array(cruellaDeVil()), Map.of()),
120120
Arguments.of(
121-
"listen-to-any-filter.yaml", "emit-doctor.yaml", doctor(), Map.of("temperature", 39)));
121+
"workflows-samples/listen-to-any.yaml",
122+
"workflows-samples/emit.yaml",
123+
array(cruellaDeVil()),
124+
Map.of()),
125+
Arguments.of(
126+
"workflows-samples/listen-to-any-filter.yaml",
127+
"workflows-samples/emit-doctor.yaml",
128+
doctor(),
129+
Map.of("temperature", 39)));
122130
}
123131

124132
private static Stream<Arguments> eventsListenerParameters() {
125133
return Stream.of(
126134
Arguments.of(
127-
"listen-to-all.yaml",
128-
"emit-doctor.yaml",
129-
"emit.yaml",
135+
"workflows-samples/listen-to-all.yaml",
136+
"workflows-samples/emit-doctor.yaml",
137+
"workflows-samples/emit.yaml",
130138
array(temperature(), cruellaDeVil())),
131139
Arguments.of(
132-
"listen-to-any-until-consumed.yaml",
133-
"emit-doctor.yaml",
134-
"emit-out.yaml",
140+
"workflows-samples/listen-to-any-until-consumed.yaml",
141+
"workflows-samples/emit-doctor.yaml",
142+
"workflows-samples/emit-out.yaml",
135143
array(temperature())));
136144
}
137145

impl/test/src/test/java/io/serverlessworkflow/impl/test/HTTPWorkflowDefinitionTest.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ void testWorkflowExecution(String fileName, Object input, Condition<Object> cond
5555
@ParameterizedTest
5656
@ValueSource(
5757
strings = {
58-
"call-http-query-parameters.yaml",
59-
"call-http-query-parameters-external-schema.yaml"
58+
"workflows-samples/call-http-query-parameters.yaml",
59+
"workflows-samples/call-http-query-parameters-external-schema.yaml"
6060
})
6161
void testWrongSchema(String fileName) {
6262
IllegalArgumentException exception =
@@ -86,18 +86,22 @@ private static Stream<Arguments> provideParameters() {
8686
.equals("Star Trek"),
8787
"StartTrek");
8888
return Stream.of(
89-
Arguments.of("callGetHttp.yaml", petInput, petCondition),
89+
Arguments.of("workflows-samples/callGetHttp.yaml", petInput, petCondition),
9090
Arguments.of(
91-
"callGetHttp.yaml",
91+
"workflows-samples/callGetHttp.yaml",
9292
Map.of("petId", "-1"),
9393
new Condition<WorkflowModel>(
9494
o -> o.asMap().orElseThrow().containsKey("petId"), "notFoundCondition")),
95-
Arguments.of("call-http-endpoint-interpolation.yaml", petInput, petCondition),
96-
Arguments.of("call-http-query-parameters.yaml", starTrekInput, starTrekCondition),
9795
Arguments.of(
98-
"call-http-query-parameters-external-schema.yaml", starTrekInput, starTrekCondition),
96+
"workflows-samples/call-http-endpoint-interpolation.yaml", petInput, petCondition),
9997
Arguments.of(
100-
"callPostHttp.yaml",
98+
"workflows-samples/call-http-query-parameters.yaml", starTrekInput, starTrekCondition),
99+
Arguments.of(
100+
"workflows-samples/call-http-query-parameters-external-schema.yaml",
101+
starTrekInput,
102+
starTrekCondition),
103+
Arguments.of(
104+
"workflows-samples/callPostHttp.yaml",
101105
Map.of("name", "Javierito", "surname", "Unknown"),
102106
new Condition<WorkflowModel>(
103107
o -> o.asText().orElseThrow().equals("Javierito"), "CallHttpPostCondition")));

impl/test/src/test/java/io/serverlessworkflow/impl/test/LifeCycleEventsTest.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ void close() {
8282
void simpleWorkflow() throws IOException {
8383

8484
WorkflowModel model =
85-
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("simple-expression.yaml"))
85+
appl.workflowDefinition(
86+
WorkflowReader.readWorkflowFromClasspath(
87+
"workflows-samples/simple-expression.yaml"))
8688
.instance(Map.of())
8789
.start()
8890
.join();
@@ -109,7 +111,8 @@ void simpleWorkflow() throws IOException {
109111
void testSuspendResumeNotWait()
110112
throws IOException, ExecutionException, InterruptedException, TimeoutException {
111113
WorkflowInstance instance =
112-
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("wait-set.yaml"))
114+
appl.workflowDefinition(
115+
WorkflowReader.readWorkflowFromClasspath("workflows-samples/wait-set.yaml"))
113116
.instance(Map.of());
114117
CompletableFuture<WorkflowModel> future = instance.start();
115118
instance.suspend();
@@ -131,7 +134,8 @@ void testSuspendResumeNotWait()
131134
void testSuspendResumeWait()
132135
throws IOException, ExecutionException, InterruptedException, TimeoutException {
133136
WorkflowInstance instance =
134-
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("wait-set.yaml"))
137+
appl.workflowDefinition(
138+
WorkflowReader.readWorkflowFromClasspath("workflows-samples/wait-set.yaml"))
135139
.instance(Map.of());
136140
CompletableFuture<WorkflowModel> future = instance.start();
137141
assertThat(instance.status()).isEqualTo(WorkflowStatus.WAITING);
@@ -158,7 +162,8 @@ void testSuspendResumeWait()
158162
@Test
159163
void testCancel() throws IOException, InterruptedException {
160164
WorkflowInstance instance =
161-
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("wait-set.yaml"))
165+
appl.workflowDefinition(
166+
WorkflowReader.readWorkflowFromClasspath("workflows-samples/wait-set.yaml"))
162167
.instance(Map.of());
163168
CompletableFuture<WorkflowModel> future = instance.start();
164169
instance.cancel();
@@ -178,7 +183,8 @@ void testCancel() throws IOException, InterruptedException {
178183
void testSuspendResumeTimeout()
179184
throws IOException, ExecutionException, InterruptedException, TimeoutException {
180185
WorkflowInstance instance =
181-
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("wait-set.yaml"))
186+
appl.workflowDefinition(
187+
WorkflowReader.readWorkflowFromClasspath("workflows-samples/wait-set.yaml"))
182188
.instance(Map.of());
183189
CompletableFuture<WorkflowModel> future = instance.start();
184190
instance.suspend();
@@ -188,7 +194,8 @@ void testSuspendResumeTimeout()
188194

189195
@Test
190196
void testError() throws IOException {
191-
Workflow workflow = WorkflowReader.readWorkflowFromClasspath("raise-inline.yaml");
197+
Workflow workflow =
198+
WorkflowReader.readWorkflowFromClasspath("workflows-samples/raise-inline.yaml");
192199
assertThat(
193200
catchThrowableOfType(
194201
CompletionException.class,

0 commit comments

Comments
 (0)