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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 73 additions & 58 deletions impl/test/pom.xml
Original file line number Diff line number Diff line change
@@ -1,60 +1,75 @@
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl</artifactId>
<version>8.0.0-SNAPSHOT</version>
</parent>
<artifactId>serverlessworkflow-impl-test</artifactId>
<name> Serverless Workflow :: Impl :: Test </name>
<dependencies>
<dependency>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-api</artifactId>
</dependency>
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl-http</artifactId>
</dependency>
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl-jackson-jwt</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
</dependency>
</dependencies>
<artifactId>serverlessworkflow-impl</artifactId>
<version>8.0.0-SNAPSHOT</version>
</parent>
<artifactId>serverlessworkflow-impl-test</artifactId>
<name>Serverless Workflow :: Impl :: Test</name>
<dependencies>
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-api</artifactId>
</dependency>
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl-http</artifactId>
</dependency>
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl-jackson-jwt</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ void testEventsListened(String listen, String emit1, String emit2, JsonNode expe
void testForEachInAnyIsExecutedAsEventArrive() throws IOException, InterruptedException {
WorkflowDefinition listenDefinition =
appl.workflowDefinition(
WorkflowReader.readWorkflowFromClasspath("listen-to-any-until.yaml"));
WorkflowReader.readWorkflowFromClasspath("workflows-samples/listen-to-any-until.yaml"));
WorkflowDefinition emitDoctorDefinition =
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("emit-doctor.yaml"));
appl.workflowDefinition(
WorkflowReader.readWorkflowFromClasspath("workflows-samples/emit-doctor.yaml"));
WorkflowInstance waitingInstance = listenDefinition.instance(Map.of());
CompletableFuture<WorkflowModel> future = waitingInstance.start();
assertThat(waitingInstance.status()).isEqualTo(WorkflowStatus.WAITING);
Expand All @@ -116,22 +117,29 @@ private static Instant getInstant(ArrayNode result, int index) {

private static Stream<Arguments> eventListenerParameters() {
return Stream.of(
Arguments.of("listen-to-any.yaml", "emit.yaml", array(cruellaDeVil()), Map.of()),
Arguments.of(
"listen-to-any-filter.yaml", "emit-doctor.yaml", doctor(), Map.of("temperature", 39)));
"workflows-samples/listen-to-any.yaml",
"workflows-samples/emit.yaml",
array(cruellaDeVil()),
Map.of()),
Arguments.of(
"workflows-samples/listen-to-any-filter.yaml",
"workflows-samples/emit-doctor.yaml",
doctor(),
Map.of("temperature", 39)));
}

private static Stream<Arguments> eventsListenerParameters() {
return Stream.of(
Arguments.of(
"listen-to-all.yaml",
"emit-doctor.yaml",
"emit.yaml",
"workflows-samples/listen-to-all.yaml",
"workflows-samples/emit-doctor.yaml",
"workflows-samples/emit.yaml",
array(temperature(), cruellaDeVil())),
Arguments.of(
"listen-to-any-until-consumed.yaml",
"emit-doctor.yaml",
"emit-out.yaml",
"workflows-samples/listen-to-any-until-consumed.yaml",
"workflows-samples/emit-doctor.yaml",
"workflows-samples/emit-out.yaml",
array(temperature())));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ void testWorkflowExecution(String fileName, Object input, Condition<Object> cond
@ParameterizedTest
@ValueSource(
strings = {
"call-http-query-parameters.yaml",
"call-http-query-parameters-external-schema.yaml"
"workflows-samples/call-http-query-parameters.yaml",
"workflows-samples/call-http-query-parameters-external-schema.yaml"
})
void testWrongSchema(String fileName) {
IllegalArgumentException exception =
Expand Down Expand Up @@ -86,18 +86,22 @@ private static Stream<Arguments> provideParameters() {
.equals("Star Trek"),
"StartTrek");
return Stream.of(
Arguments.of("callGetHttp.yaml", petInput, petCondition),
Arguments.of("workflows-samples/callGetHttp.yaml", petInput, petCondition),
Arguments.of(
"callGetHttp.yaml",
"workflows-samples/callGetHttp.yaml",
Map.of("petId", "-1"),
new Condition<WorkflowModel>(
o -> o.asMap().orElseThrow().containsKey("petId"), "notFoundCondition")),
Arguments.of("call-http-endpoint-interpolation.yaml", petInput, petCondition),
Arguments.of("call-http-query-parameters.yaml", starTrekInput, starTrekCondition),
Arguments.of(
"call-http-query-parameters-external-schema.yaml", starTrekInput, starTrekCondition),
"workflows-samples/call-http-endpoint-interpolation.yaml", petInput, petCondition),
Arguments.of(
"callPostHttp.yaml",
"workflows-samples/call-http-query-parameters.yaml", starTrekInput, starTrekCondition),
Arguments.of(
"workflows-samples/call-http-query-parameters-external-schema.yaml",
starTrekInput,
starTrekCondition),
Arguments.of(
"workflows-samples/callPostHttp.yaml",
Map.of("name", "Javierito", "surname", "Unknown"),
new Condition<WorkflowModel>(
o -> o.asText().orElseThrow().equals("Javierito"), "CallHttpPostCondition")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ void close() {
void simpleWorkflow() throws IOException {

WorkflowModel model =
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("simple-expression.yaml"))
appl.workflowDefinition(
WorkflowReader.readWorkflowFromClasspath(
"workflows-samples/simple-expression.yaml"))
.instance(Map.of())
.start()
.join();
Expand All @@ -109,7 +111,8 @@ void simpleWorkflow() throws IOException {
void testSuspendResumeNotWait()
throws IOException, ExecutionException, InterruptedException, TimeoutException {
WorkflowInstance instance =
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("wait-set.yaml"))
appl.workflowDefinition(
WorkflowReader.readWorkflowFromClasspath("workflows-samples/wait-set.yaml"))
.instance(Map.of());
CompletableFuture<WorkflowModel> future = instance.start();
instance.suspend();
Expand All @@ -131,7 +134,8 @@ void testSuspendResumeNotWait()
void testSuspendResumeWait()
throws IOException, ExecutionException, InterruptedException, TimeoutException {
WorkflowInstance instance =
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("wait-set.yaml"))
appl.workflowDefinition(
WorkflowReader.readWorkflowFromClasspath("workflows-samples/wait-set.yaml"))
.instance(Map.of());
CompletableFuture<WorkflowModel> future = instance.start();
assertThat(instance.status()).isEqualTo(WorkflowStatus.WAITING);
Expand All @@ -158,7 +162,8 @@ void testSuspendResumeWait()
@Test
void testCancel() throws IOException, InterruptedException {
WorkflowInstance instance =
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("wait-set.yaml"))
appl.workflowDefinition(
WorkflowReader.readWorkflowFromClasspath("workflows-samples/wait-set.yaml"))
.instance(Map.of());
CompletableFuture<WorkflowModel> future = instance.start();
instance.cancel();
Expand All @@ -178,7 +183,8 @@ void testCancel() throws IOException, InterruptedException {
void testSuspendResumeTimeout()
throws IOException, ExecutionException, InterruptedException, TimeoutException {
WorkflowInstance instance =
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("wait-set.yaml"))
appl.workflowDefinition(
WorkflowReader.readWorkflowFromClasspath("workflows-samples/wait-set.yaml"))
.instance(Map.of());
CompletableFuture<WorkflowModel> future = instance.start();
instance.suspend();
Expand All @@ -188,7 +194,8 @@ void testSuspendResumeTimeout()

@Test
void testError() throws IOException {
Workflow workflow = WorkflowReader.readWorkflowFromClasspath("raise-inline.yaml");
Workflow workflow =
WorkflowReader.readWorkflowFromClasspath("workflows-samples/raise-inline.yaml");
assertThat(
catchThrowableOfType(
CompletionException.class,
Expand Down
Loading