diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/AbstractExecutorServiceHolder.java b/impl/core/src/main/java/io/serverlessworkflow/impl/AbstractExecutorServiceHolder.java index f32d8e94..9982c9f2 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/AbstractExecutorServiceHolder.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/AbstractExecutorServiceHolder.java @@ -16,15 +16,17 @@ package io.serverlessworkflow.impl; import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; public abstract class AbstractExecutorServiceHolder implements ExecutorServiceFactory { protected ExecutorService service; @Override - public void close() { + public void close() throws InterruptedException { if (service != null && !service.isShutdown()) { service.shutdown(); + service.awaitTermination(2, TimeUnit.SECONDS); } } } diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/ExecutorServiceFactory.java b/impl/core/src/main/java/io/serverlessworkflow/impl/ExecutorServiceFactory.java index 2b831037..3d35a2dd 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/ExecutorServiceFactory.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/ExecutorServiceFactory.java @@ -18,6 +18,4 @@ import java.util.concurrent.ExecutorService; import java.util.function.Supplier; -public interface ExecutorServiceFactory extends Supplier, AutoCloseable { - void close(); -} +public interface ExecutorServiceFactory extends Supplier, AutoCloseable {} diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowMutableInstance.java b/impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowMutableInstance.java index 796d2e68..c55d8088 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowMutableInstance.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowMutableInstance.java @@ -18,8 +18,6 @@ import static io.serverlessworkflow.impl.lifecycle.LifecycleEventsUtils.publishEvent; import io.serverlessworkflow.impl.executors.TaskExecutorHelper; -import io.serverlessworkflow.impl.lifecycle.TaskResumedEvent; -import io.serverlessworkflow.impl.lifecycle.TaskSuspendedEvent; import io.serverlessworkflow.impl.lifecycle.WorkflowCancelledEvent; import io.serverlessworkflow.impl.lifecycle.WorkflowCompletedEvent; import io.serverlessworkflow.impl.lifecycle.WorkflowFailedEvent; @@ -27,10 +25,12 @@ import io.serverlessworkflow.impl.lifecycle.WorkflowStartedEvent; import io.serverlessworkflow.impl.lifecycle.WorkflowSuspendedEvent; import java.time.Instant; +import java.util.Map; import java.util.Optional; import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -47,9 +47,7 @@ public class WorkflowMutableInstance implements WorkflowInstance { private volatile WorkflowModel output; private Lock statusLock = new ReentrantLock(); private CompletableFuture completableFuture; - private CompletableFuture suspended; - private TaskContext suspendedTask; - private CompletableFuture cancelled; + private Map, TaskContext> suspended; WorkflowMutableInstance(WorkflowDefinition definition, WorkflowModel input) { this.id = definition.application().idFactory().get(); @@ -88,11 +86,7 @@ private void whenFailed(WorkflowModel result, Throwable ex) { } private void handleException(Throwable ex) { - if (ex instanceof CancellationException) { - status.set(WorkflowStatus.CANCELLED); - publishEvent( - workflowContext, l -> l.onWorkflowCancelled(new WorkflowCancelledEvent(workflowContext))); - } else { + if (!(ex instanceof CancellationException)) { status.set(WorkflowStatus.FAULTED); publishEvent( workflowContext, l -> l.onWorkflowFailed(new WorkflowFailedEvent(workflowContext, ex))); @@ -107,7 +101,7 @@ private WorkflowModel whenSuccess(WorkflowModel node) { .map(f -> f.apply(workflowContext, null, node)) .orElse(node); workflowContext.definition().outputSchemaValidator().ifPresent(v -> v.validate(output)); - status.compareAndSet(WorkflowStatus.RUNNING, WorkflowStatus.COMPLETED); + status.set(WorkflowStatus.COMPLETED); publishEvent( workflowContext, l -> l.onWorkflowCompleted(new WorkflowCompletedEvent(workflowContext))); return output; @@ -174,9 +168,9 @@ public String toString() { public boolean suspend() { try { statusLock.lock(); - if (TaskExecutorHelper.isActive(status.get())) { - suspended = new CompletableFuture(); - workflowContext.instance().status(WorkflowStatus.SUSPENDED); + if (TaskExecutorHelper.isActive(status.get()) && suspended == null) { + suspended = new ConcurrentHashMap<>(); + status.set(WorkflowStatus.SUSPENDED); publishEvent( workflowContext, l -> l.onWorkflowSuspended(new WorkflowSuspendedEvent(workflowContext))); @@ -193,40 +187,27 @@ public boolean suspend() { public boolean resume() { try { statusLock.lock(); - if (suspended != null) { - if (suspendedTask != null) { - CompletableFuture toBeCompleted = suspended; - suspended = null; - toBeCompleted.complete(suspendedTask); - publishEvent( - workflowContext, - l -> l.onTaskResumed(new TaskResumedEvent(workflowContext, suspendedTask))); - } else { - suspended = null; - } + if (TaskExecutorHelper.isActive(status.get()) && suspended != null) { publishEvent( workflowContext, l -> l.onWorkflowResumed(new WorkflowResumedEvent(workflowContext))); + suspended.forEach( + (k, v) -> { + k.complete(v); + }); + suspended = null; return true; - } else { - return false; } } finally { statusLock.unlock(); } + return false; } - public CompletableFuture completedChecks(TaskContext t) { + public CompletableFuture cancelCheck(TaskContext t) { try { statusLock.lock(); - if (suspended != null) { - suspendedTask = t; - publishEvent( - workflowContext, l -> l.onTaskSuspended(new TaskSuspendedEvent(workflowContext, t))); - return suspended; - } - if (cancelled != null) { - cancelled = new CompletableFuture(); - workflowContext.instance().status(WorkflowStatus.CANCELLED); + if (status.get() == WorkflowStatus.CANCELLED) { + CompletableFuture cancelled = new CompletableFuture(); cancelled.completeExceptionally( new CancellationException("Task " + t.taskName() + " has been cancelled")); return cancelled; @@ -237,12 +218,31 @@ public CompletableFuture completedChecks(TaskContext t) { return CompletableFuture.completedFuture(t); } + public CompletableFuture suspendedCheck(TaskContext t) { + try { + statusLock.lock(); + if (suspended != null) { + CompletableFuture suspendedTask = new CompletableFuture(); + suspended.put(suspendedTask, t); + return suspendedTask; + } else if (TaskExecutorHelper.isActive(status.get())) { + status.set(WorkflowStatus.RUNNING); + } + } finally { + statusLock.unlock(); + } + return CompletableFuture.completedFuture(t); + } + @Override public boolean cancel() { try { statusLock.lock(); if (TaskExecutorHelper.isActive(status.get())) { - cancelled = new CompletableFuture(); + status.set(WorkflowStatus.CANCELLED); + publishEvent( + workflowContext, + l -> l.onWorkflowCancelled(new WorkflowCancelledEvent(workflowContext))); return true; } else { return false; diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/events/EventConsumer.java b/impl/core/src/main/java/io/serverlessworkflow/impl/events/EventConsumer.java index c08b3d2d..1c94ed49 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/events/EventConsumer.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/events/EventConsumer.java @@ -31,6 +31,4 @@ public interface EventConsumer consumer); void unregister(T register); - - void close(); } diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/events/EventPublisher.java b/impl/core/src/main/java/io/serverlessworkflow/impl/events/EventPublisher.java index 5ac724ce..632bbef8 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/events/EventPublisher.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/events/EventPublisher.java @@ -20,6 +20,4 @@ public interface EventPublisher extends AutoCloseable { CompletableFuture publish(CloudEvent event); - - void close(); } diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/events/InMemoryEvents.java b/impl/core/src/main/java/io/serverlessworkflow/impl/events/InMemoryEvents.java index f2d6cba3..05473090 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/events/InMemoryEvents.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/events/InMemoryEvents.java @@ -81,7 +81,7 @@ protected void unregisterFromAll() { } @Override - public void close() { + public void close() throws Exception { topicMap.clear(); serviceFactory.close(); } diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/executors/AbstractTaskExecutor.java b/impl/core/src/main/java/io/serverlessworkflow/impl/executors/AbstractTaskExecutor.java index 10b76308..f7f78bc5 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/executors/AbstractTaskExecutor.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/executors/AbstractTaskExecutor.java @@ -197,6 +197,7 @@ public CompletableFuture apply( if (ifFilter.map(f -> f.test(workflowContext, taskContext, input)).orElse(true)) { return executeNext( completable + .thenCompose(workflowContext.instance()::suspendedCheck) .thenApply( t -> { publishEvent( @@ -208,7 +209,7 @@ public CompletableFuture apply( return t; }) .thenCompose(t -> execute(workflowContext, t)) - .thenCompose(t -> workflowContext.instance().completedChecks(t)) + .thenCompose(workflowContext.instance()::cancelCheck) .whenComplete( (t, e) -> { if (e != null) { @@ -216,8 +217,6 @@ public CompletableFuture apply( workflowContext, taskContext, e instanceof CompletionException ? e.getCause() : e); - } else { - workflowContext.instance().status(WorkflowStatus.RUNNING); } }) .thenApply( diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/executors/TaskExecutorHelper.java b/impl/core/src/main/java/io/serverlessworkflow/impl/executors/TaskExecutorHelper.java index 0b66cf7d..32516e5b 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/executors/TaskExecutorHelper.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/executors/TaskExecutorHelper.java @@ -54,7 +54,9 @@ public static boolean isActive(WorkflowContext context) { } public static boolean isActive(WorkflowStatus status) { - return status == WorkflowStatus.RUNNING || status == WorkflowStatus.WAITING; + return status == WorkflowStatus.RUNNING + || status == WorkflowStatus.WAITING + || status == WorkflowStatus.SUSPENDED; } public static TaskExecutor createExecutorList( diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkWaitTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkWaitTest.java new file mode 100644 index 00000000..712bab31 --- /dev/null +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/ForkWaitTest.java @@ -0,0 +1,82 @@ +/* + * Copyright 2020-Present The Serverless Workflow Specification Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.serverlessworkflow.impl.test; + +import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath; +import static org.assertj.core.api.Assertions.assertThat; + +import io.serverlessworkflow.api.types.Workflow; +import io.serverlessworkflow.impl.WorkflowApplication; +import io.serverlessworkflow.impl.WorkflowInstance; +import io.serverlessworkflow.impl.WorkflowModel; +import io.serverlessworkflow.impl.WorkflowStatus; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +class ForkWaitTest { + + private static WorkflowApplication appl; + + @BeforeAll + static void init() throws IOException { + appl = WorkflowApplication.builder().build(); + } + + @AfterAll + static void tearDown() throws IOException { + appl.close(); + } + + @Test + void testForkWait() throws IOException, InterruptedException, ExecutionException { + assertModel( + appl.workflowDefinition(readWorkflowFromClasspath("workflows-samples/fork-wait.yaml")) + .instance(Map.of()) + .start() + .join()); + } + + @Test + void testForkWaitWithSuspend() throws IOException, InterruptedException { + Workflow workflow = readWorkflowFromClasspath("workflows-samples/fork-wait.yaml"); + WorkflowInstance instance = appl.workflowDefinition(workflow).instance(Map.of()); + CompletableFuture future = instance.start(); + Thread.sleep(50); + assertThat(instance.status()).isEqualTo(WorkflowStatus.WAITING); + instance.suspend(); + assertThat(instance.status()).isEqualTo(WorkflowStatus.SUSPENDED); + Thread.sleep(200); + instance.resume(); + WorkflowModel model = future.join(); + assertThat(instance.status()).isEqualTo(WorkflowStatus.COMPLETED); + assertModel(model); + } + + private void assertModel(WorkflowModel current) { + assertThat((Collection>) current.asJavaObject()) + .containsExactlyInAnyOrderElementsOf( + List.of( + Map.of("helloBranch", Map.of("value", 1)), + Map.of("byeBranch", Map.of("value", 2)))); + } +} diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/HTTPWorkflowDefinitionTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/HTTPWorkflowDefinitionTest.java index 35b1985f..08a8648a 100644 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/HTTPWorkflowDefinitionTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/HTTPWorkflowDefinitionTest.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.stream.Stream; import org.assertj.core.api.Condition; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -40,6 +41,11 @@ static void init() { appl = WorkflowApplication.builder().build(); } + @AfterAll + static void cleanup() { + appl.close(); + } + @ParameterizedTest @MethodSource("provideParameters") void testWorkflowExecution(String fileName, Object input, Condition condition) diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/LifeCycleEventsTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/LifeCycleEventsTest.java index 2029760f..3af374aa 100644 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/LifeCycleEventsTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/LifeCycleEventsTest.java @@ -31,9 +31,7 @@ import io.serverlessworkflow.impl.lifecycle.ce.AbstractLifeCyclePublisher; import io.serverlessworkflow.impl.lifecycle.ce.TaskCancelledCEData; import io.serverlessworkflow.impl.lifecycle.ce.TaskCompletedCEData; -import io.serverlessworkflow.impl.lifecycle.ce.TaskResumedCEData; import io.serverlessworkflow.impl.lifecycle.ce.TaskStartedCEData; -import io.serverlessworkflow.impl.lifecycle.ce.TaskSuspendedCEData; import io.serverlessworkflow.impl.lifecycle.ce.WorkflowCancelledCEData; import io.serverlessworkflow.impl.lifecycle.ce.WorkflowCompletedCEData; import io.serverlessworkflow.impl.lifecycle.ce.WorkflowErrorCEData; @@ -53,18 +51,18 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; class LifeCycleEventsTest { - private WorkflowApplication appl; - private Collection publishedEvents; + private static WorkflowApplication appl; + private static Collection publishedEvents; - @BeforeEach - void setup() { - publishedEvents = new CopyOnWriteArrayList<>(); + @BeforeAll + static void init() { InMemoryEvents eventBroker = new InMemoryEvents(); for (String type : AbstractLifeCyclePublisher.getLifeCycleTypes()) { eventBroker.register(type, ce -> publishedEvents.add(ce)); @@ -76,11 +74,16 @@ void setup() { .build(); } - @AfterEach - void close() { + @AfterAll + static void cleanup() { appl.close(); } + @BeforeEach + void setup() { + publishedEvents = new CopyOnWriteArrayList<>(); + } + @Test void simpleWorkflow() throws IOException { @@ -149,17 +152,12 @@ void testSuspendResumeWait() assertThat(future.get(1, TimeUnit.SECONDS).asMap().orElseThrow()) .isEqualTo(Map.of("name", "Javierito")); assertThat(instance.status()).isEqualTo(WorkflowStatus.COMPLETED); - TaskSuspendedCEData taskSuspendedEvent = - assertPojoInCE("io.serverlessworkflow.task.suspended.v1", TaskSuspendedCEData.class); WorkflowSuspendedCEData workflowSuspendedEvent = assertPojoInCE( "io.serverlessworkflow.workflow.suspended.v1", WorkflowSuspendedCEData.class); - TaskResumedCEData taskResumedEvent = - assertPojoInCE("io.serverlessworkflow.task.resumed.v1", TaskResumedCEData.class); WorkflowResumedCEData workflowResumedEvent = assertPojoInCE("io.serverlessworkflow.workflow.resumed.v1", WorkflowResumedCEData.class); assertThat(workflowSuspendedEvent.suspendedAt()).isBefore(workflowResumedEvent.resumedAt()); - assertThat(taskSuspendedEvent.suspendedAt()).isBefore(taskResumedEvent.resumedAt()); } @Test @@ -173,13 +171,8 @@ void testCancel() throws IOException, InterruptedException { assertThat(catchThrowableOfType(ExecutionException.class, () -> future.get().asMap())) .isNotNull(); assertThat(instance.status()).isEqualTo(WorkflowStatus.CANCELLED); - TaskCancelledCEData taskCancelledEvent = - assertPojoInCE("io.serverlessworkflow.task.cancelled.v1", TaskCancelledCEData.class); - WorkflowCancelledCEData workflowCancelledEvent = - assertPojoInCE( - "io.serverlessworkflow.workflow.cancelled.v1", WorkflowCancelledCEData.class); - assertThat(taskCancelledEvent.cancelledAt()) - .isBeforeOrEqualTo(workflowCancelledEvent.cancelledAt()); + assertPojoInCE("io.serverlessworkflow.task.cancelled.v1", TaskCancelledCEData.class); + assertPojoInCE("io.serverlessworkflow.workflow.cancelled.v1", WorkflowCancelledCEData.class); } @Test diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/OAuthHTTPWorkflowDefinitionTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/OAuthHTTPWorkflowDefinitionTest.java index 157b894e..aaa8b0ff 100644 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/OAuthHTTPWorkflowDefinitionTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/OAuthHTTPWorkflowDefinitionTest.java @@ -27,11 +27,12 @@ import java.time.Instant; import java.util.Base64; import java.util.Map; -import okhttp3.OkHttpClient; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -56,23 +57,27 @@ public class OAuthHTTPWorkflowDefinitionTest { } """; + private static WorkflowApplication app; private MockWebServer authServer; private MockWebServer apiServer; - private OkHttpClient httpClient; - private String authBaseUrl; - private String apiBaseUrl; + + @BeforeAll + static void init() { + app = WorkflowApplication.builder().build(); + } + + @AfterAll + static void cleanup() { + app.close(); + } @BeforeEach void setUp() throws IOException { authServer = new MockWebServer(); authServer.start(8888); - authBaseUrl = "http://localhost:8888"; apiServer = new MockWebServer(); apiServer.start(8081); - apiBaseUrl = "http://localhost:8081"; - - httpClient = new OkHttpClient(); } @AfterEach @@ -100,11 +105,8 @@ public void testOAuthClientSecretPostPasswordWorkflowExecution() throws Exceptio Workflow workflow = readWorkflowFromClasspath("workflows-samples/oAuthClientSecretPostPasswordHttpCall.yaml"); - Map result; - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -145,7 +147,7 @@ public void testOAuthClientSecretPostWithArgsWorkflowExecution() throws Exceptio Workflow workflow = readWorkflowFromClasspath( "workflows-samples/oAuthClientSecretPostPasswordAsArgHttpCall.yaml"); - Map result; + Map params = Map.of( "clientId", "serverless-workflow", @@ -153,10 +155,8 @@ public void testOAuthClientSecretPostWithArgsWorkflowExecution() throws Exceptio "username", "serverless-workflow-test", "password", "serverless-workflow-test"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -197,7 +197,7 @@ public void testOAuthClientSecretPostWithArgsNoEndPointWorkflowExecution() throw Workflow workflow = readWorkflowFromClasspath( "workflows-samples/oAuthClientSecretPostPasswordNoEndpointsHttpCall.yaml"); - Map result; + Map params = Map.of( "clientId", "serverless-workflow", @@ -205,10 +205,8 @@ public void testOAuthClientSecretPostWithArgsNoEndPointWorkflowExecution() throw "username", "serverless-workflow-test", "password", "serverless-workflow-test"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -249,7 +247,6 @@ public void testOAuthClientSecretPostWithArgsAllGrantsWorkflowExecution() throws Workflow workflow = readWorkflowFromClasspath( "workflows-samples/oAuthClientSecretPostPasswordAllGrantsHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", @@ -259,10 +256,8 @@ public void testOAuthClientSecretPostWithArgsAllGrantsWorkflowExecution() throws "openidScope", "openidScope", "audience", "account"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -309,11 +304,8 @@ public void testOAuthClientSecretPostClientCredentialsWorkflowExecution() throws Workflow workflow = readWorkflowFromClasspath( "workflows-samples/oAuthClientSecretPostClientCredentialsHttpCall.yaml"); - Map result; - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -355,16 +347,13 @@ public void testOAuthClientSecretPostClientCredentialsParamsWorkflowExecution() Workflow workflow = readWorkflowFromClasspath( "workflows-samples/oAuthClientSecretPostClientCredentialsParamsHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", "clientSecret", "D0ACXCUKOUrL5YL7j6RQWplMaSjPB8MT"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -407,16 +396,13 @@ public void testOAuthClientSecretPostClientCredentialsParamsNoEndpointWorkflowEx Workflow workflow = readWorkflowFromClasspath( "workflows-samples/oAuthClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", "clientSecret", "D0ACXCUKOUrL5YL7j6RQWplMaSjPB8MT"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -456,11 +442,8 @@ public void testOAuthJSONPasswordWorkflowExecution() throws Exception { Workflow workflow = readWorkflowFromClasspath("workflows-samples/oAuthJSONPasswordHttpCall.yaml"); - Map result; - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -514,7 +497,6 @@ public void testOAuthJSONWithArgsWorkflowExecution() throws Exception { Workflow workflow = readWorkflowFromClasspath("workflows-samples/oAuthJSONPasswordAsArgHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", @@ -522,10 +504,8 @@ public void testOAuthJSONWithArgsWorkflowExecution() throws Exception { "username", "serverless-workflow-test", "password", "serverless-workflow-test"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -576,7 +556,6 @@ public void testOAuthJSONWithArgsNoEndPointWorkflowExecution() throws Exception Workflow workflow = readWorkflowFromClasspath("workflows-samples/oAuthJSONPasswordNoEndpointsHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", @@ -584,10 +563,8 @@ public void testOAuthJSONWithArgsNoEndPointWorkflowExecution() throws Exception "username", "serverless-workflow-test", "password", "serverless-workflow-test"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -637,7 +614,6 @@ public void testOAuthJSONWithArgsAllGrantsWorkflowExecution() throws Exception { Workflow workflow = readWorkflowFromClasspath("workflows-samples/oAuthJSONPasswordAllGrantsHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", @@ -647,10 +623,8 @@ public void testOAuthJSONWithArgsAllGrantsWorkflowExecution() throws Exception { "openidScope", "openidScope", "audience", "account"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -712,11 +686,8 @@ public void testOAuthJSONClientCredentialsWorkflowExecution() throws Exception { Workflow workflow = readWorkflowFromClasspath("workflows-samples/oAuthJSONClientCredentialsHttpCall.yaml"); - Map result; - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -763,16 +734,13 @@ public void testOAuthJSONClientCredentialsParamsWorkflowExecution() throws Excep Workflow workflow = readWorkflowFromClasspath( "workflows-samples/oAuthJSONClientCredentialsParamsHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", "clientSecret", "D0ACXCUKOUrL5YL7j6RQWplMaSjPB8MT"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -819,16 +787,13 @@ public void testOAuthJSONClientCredentialsParamsNoEndpointWorkflowExecution() th Workflow workflow = readWorkflowFromClasspath( "workflows-samples/oAuthJSONClientCredentialsParamsNoEndPointHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", "clientSecret", "D0ACXCUKOUrL5YL7j6RQWplMaSjPB8MT"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/OpenIDCHTTPWorkflowDefinitionTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/OpenIDCHTTPWorkflowDefinitionTest.java index 7dbd2f5a..7cecf9e5 100644 --- a/impl/test/src/test/java/io/serverlessworkflow/impl/test/OpenIDCHTTPWorkflowDefinitionTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/OpenIDCHTTPWorkflowDefinitionTest.java @@ -25,11 +25,12 @@ import io.serverlessworkflow.impl.WorkflowApplication; import java.io.IOException; import java.util.Map; -import okhttp3.OkHttpClient; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -54,23 +55,27 @@ public class OpenIDCHTTPWorkflowDefinitionTest { } """; + private static WorkflowApplication app; private MockWebServer authServer; private MockWebServer apiServer; - private OkHttpClient httpClient; - private String authBaseUrl; - private String apiBaseUrl; + + @BeforeAll + static void init() { + app = WorkflowApplication.builder().build(); + } + + @AfterAll + static void cleanup() { + app.close(); + } @BeforeEach void setUp() throws IOException { authServer = new MockWebServer(); authServer.start(8888); - authBaseUrl = "http://localhost:8888"; apiServer = new MockWebServer(); apiServer.start(8881); - apiBaseUrl = "http://localhost:8881"; - - httpClient = new OkHttpClient(); } @AfterEach @@ -99,12 +104,8 @@ public void testOpenIDCClientSecretPostPasswordWorkflowExecution() throws Except Workflow workflow = readWorkflowFromClasspath("workflows-samples/openidcClientSecretPostPasswordHttpCall.yaml"); - Map result; - System.err.println("START"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -148,7 +149,6 @@ public void testOpenIDCClientSecretPostWithArgsWorkflowExecution() throws Except Workflow workflow = readWorkflowFromClasspath( "workflows-samples/openidcClientSecretPostPasswordAsArgHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", @@ -156,10 +156,8 @@ public void testOpenIDCClientSecretPostWithArgsWorkflowExecution() throws Except "username", "serverless-workflow-test", "password", "serverless-workflow-test"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -202,7 +200,6 @@ public void testOpenIDCClientSecretPostWithArgsAllGrantsWorkflowExecution() thro Workflow workflow = readWorkflowFromClasspath( "workflows-samples/openidcClientSecretPostPasswordAllGrantsHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", @@ -210,10 +207,8 @@ public void testOpenIDCClientSecretPostWithArgsAllGrantsWorkflowExecution() thro "username", "serverless-workflow-test", "password", "serverless-workflow-test"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -264,16 +259,13 @@ public void testOpenIDCClientSecretPostClientCredentialsParamsWorkflowExecution( Workflow workflow = readWorkflowFromClasspath( "workflows-samples/openidcClientSecretPostClientCredentialsParamsHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", "clientSecret", "D0ACXCUKOUrL5YL7j6RQWplMaSjPB8MT"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -316,16 +308,13 @@ public void testOpenIDCClientSecretPostClientCredentialsParamsNoEndpointWorkflow Workflow workflow = readWorkflowFromClasspath( "workflows-samples/openidcClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", "clientSecret", "D0ACXCUKOUrL5YL7j6RQWplMaSjPB8MT"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -364,11 +353,8 @@ public void testOpenIDCJSONPasswordWorkflowExecution() throws Exception { Workflow workflow = readWorkflowFromClasspath("workflows-samples/openidcJSONPasswordHttpCall.yaml"); - Map result; - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -422,7 +408,6 @@ public void testOpenIDCJSONWithArgsWorkflowExecution() throws Exception { Workflow workflow = readWorkflowFromClasspath("workflows-samples/openidcJSONPasswordAsArgHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", @@ -430,10 +415,8 @@ public void testOpenIDCJSONWithArgsWorkflowExecution() throws Exception { "username", "serverless-workflow-test", "password", "serverless-workflow-test"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -484,7 +467,6 @@ public void testOpenIDCJSONWithArgsNoEndPointWorkflowExecution() throws Exceptio Workflow workflow = readWorkflowFromClasspath("workflows-samples/openidcJSONPasswordNoEndpointsHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", @@ -492,10 +474,8 @@ public void testOpenIDCJSONWithArgsNoEndPointWorkflowExecution() throws Exceptio "username", "serverless-workflow-test", "password", "serverless-workflow-test"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -545,7 +525,6 @@ public void testOpenIDCJSONWithArgsAllGrantsWorkflowExecution() throws Exception Workflow workflow = readWorkflowFromClasspath("workflows-samples/openidcJSONPasswordAllGrantsHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", @@ -555,10 +534,8 @@ public void testOpenIDCJSONWithArgsAllGrantsWorkflowExecution() throws Exception "openidScope", "openidScope", "audience", "account"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -620,11 +597,8 @@ public void testOpenIDCJSONClientCredentialsWorkflowExecution() throws Exception Workflow workflow = readWorkflowFromClasspath("workflows-samples/openidcJSONClientCredentialsHttpCall.yaml"); - Map result; - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -671,16 +645,13 @@ public void testOpenIDCJSONClientCredentialsParamsWorkflowExecution() throws Exc Workflow workflow = readWorkflowFromClasspath( "workflows-samples/openidcJSONClientCredentialsParamsHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", "clientSecret", "D0ACXCUKOUrL5YL7j6RQWplMaSjPB8MT"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); @@ -727,16 +698,13 @@ public void testOpenIDCJSONClientCredentialsParamsNoEndpointWorkflowExecution() Workflow workflow = readWorkflowFromClasspath( "workflows-samples/openidcJSONClientCredentialsParamsNoEndPointHttpCall.yaml"); - Map result; Map params = Map.of( "clientId", "serverless-workflow", "clientSecret", "D0ACXCUKOUrL5YL7j6RQWplMaSjPB8MT"); - try (WorkflowApplication app = WorkflowApplication.builder().build()) { - result = - app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } + Map result = + app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); assertTrue(result.containsKey("message")); assertTrue(result.get("message").toString().contains("Hello World")); diff --git a/impl/test/src/test/java/io/serverlessworkflow/impl/test/TraceExecutionListener.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/TraceExecutionListener.java new file mode 100644 index 00000000..8a47c72c --- /dev/null +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/TraceExecutionListener.java @@ -0,0 +1,101 @@ +/* + * Copyright 2020-Present The Serverless Workflow Specification Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.serverlessworkflow.impl.test; + +import io.serverlessworkflow.impl.lifecycle.TaskCancelledEvent; +import io.serverlessworkflow.impl.lifecycle.TaskCompletedEvent; +import io.serverlessworkflow.impl.lifecycle.TaskFailedEvent; +import io.serverlessworkflow.impl.lifecycle.TaskResumedEvent; +import io.serverlessworkflow.impl.lifecycle.TaskRetriedEvent; +import io.serverlessworkflow.impl.lifecycle.TaskStartedEvent; +import io.serverlessworkflow.impl.lifecycle.TaskSuspendedEvent; +import io.serverlessworkflow.impl.lifecycle.WorkflowCancelledEvent; +import io.serverlessworkflow.impl.lifecycle.WorkflowCompletedEvent; +import io.serverlessworkflow.impl.lifecycle.WorkflowExecutionListener; +import io.serverlessworkflow.impl.lifecycle.WorkflowFailedEvent; +import io.serverlessworkflow.impl.lifecycle.WorkflowResumedEvent; +import io.serverlessworkflow.impl.lifecycle.WorkflowStartedEvent; +import io.serverlessworkflow.impl.lifecycle.WorkflowSuspendedEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TraceExecutionListener implements WorkflowExecutionListener { + + private static final Logger logger = LoggerFactory.getLogger(TraceExecutionListener.class); + + public void onWorkflowStarted(WorkflowStartedEvent ev) { + + logger.info( + "Workflow definition {} with id {} started at {}", + ev.workflowContext().definition().workflow().getDocument().getName(), + ev.workflowContext().instanceData().id(), + ev.eventDate()); + } + + public void onWorkflowResumed(WorkflowResumedEvent ev) { + logger.info( + "Workflow definition {} with id {} resumed at {}", + ev.workflowContext().definition().workflow().getDocument().getName(), + ev.workflowContext().instanceData().id(), + ev.eventDate()); + } + + public void onWorkflowSuspended(WorkflowSuspendedEvent ev) { + logger.info( + "Workflow definition {} with id {} suspended at {}", + ev.workflowContext().definition().workflow().getDocument().getName(), + ev.workflowContext().instanceData().id(), + ev.eventDate()); + } + + public void onWorkflowCompleted(WorkflowCompletedEvent ev) { + logger.info( + "Workflow definition {} with id {} completed at {}", + ev.workflowContext().definition().workflow().getDocument().getName(), + ev.workflowContext().instanceData().id(), + ev.eventDate()); + } + + public void onWorkflowFailed(WorkflowFailedEvent ev) {} + + public void onWorkflowCancelled(WorkflowCancelledEvent ev) {} + + public void onTaskStarted(TaskStartedEvent ev) { + logger.info( + "Task {} started at {}, position {}", + ev.taskContext().taskName(), + ev.eventDate(), + ev.taskContext().position()); + } + + public void onTaskCompleted(TaskCompletedEvent ev) { + logger.info( + "Task {} completed at {} with output {}", + ev.taskContext().taskName(), + ev.eventDate(), + ev.taskContext().output().asJavaObject()); + } + + public void onTaskFailed(TaskFailedEvent ev) {} + + public void onTaskCancelled(TaskCancelledEvent ev) {} + + public void onTaskSuspended(TaskSuspendedEvent ev) {} + + public void onTaskResumed(TaskResumedEvent ev) {} + + public void onTaskRetried(TaskRetriedEvent ev) {} +} diff --git a/impl/test/src/test/resources/workflows-samples/fork-wait.yaml b/impl/test/src/test/resources/workflows-samples/fork-wait.yaml new file mode 100644 index 00000000..8ec77c1e --- /dev/null +++ b/impl/test/src/test/resources/workflows-samples/fork-wait.yaml @@ -0,0 +1,26 @@ +document: + dsl: '1.0.0-alpha5' + namespace: test + name: fork-wait + version: '0.1.0' +do: + - incrParallel: + fork: + compete: false + branches: + - helloBranch: + do: + - waitABit: + wait: + milliseconds: 90 + - set: + set: + value: 1 + - byeBranch: + do: + - waitABit: + wait: + milliseconds: 90 + - set: + set: + value: 2 \ No newline at end of file diff --git a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsHttpCall.yaml index 6ba976c8..e763bd75 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.1' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsParamsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsParamsHttpCall.yaml index 9a441fcc..a15e27df 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsParamsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsParamsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.2' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml index 5e616d34..22dfa9c0 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.3' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordAllGrantsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordAllGrantsHttpCall.yaml index ff350683..0c7e6183 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordAllGrantsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordAllGrantsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.4' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordAsArgHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordAsArgHttpCall.yaml index 817844a3..09ee1dfe 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordAsArgHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordAsArgHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.5' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordHttpCall.yaml index 891ce62f..ec4210e3 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.6' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordNoEndpointsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordNoEndpointsHttpCall.yaml index 3a0fc402..6a3f8f56 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordNoEndpointsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthClientSecretPostPasswordNoEndpointsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.7' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsHttpCall.yaml index 5c50cfd9..1dbf9d85 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.8' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsParamsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsParamsHttpCall.yaml index d6480d03..e4e4f283 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsParamsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsParamsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.9' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsParamsNoEndPointHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsParamsNoEndPointHttpCall.yaml index 8c442372..a441130a 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsParamsNoEndPointHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthJSONClientCredentialsParamsNoEndPointHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.10' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordAllGrantsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordAllGrantsHttpCall.yaml index b5546842..2c2e510c 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordAllGrantsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordAllGrantsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.11' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordAsArgHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordAsArgHttpCall.yaml index c9864aa9..f87a3e20 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordAsArgHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordAsArgHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.12' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordHttpCall.yaml index fa5d3edc..ebff190a 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.13' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordNoEndpointsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordNoEndpointsHttpCall.yaml index 91da2890..aa427ec5 100644 --- a/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordNoEndpointsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/oAuthJSONPasswordNoEndpointsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.14' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostClientCredentialsParamsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostClientCredentialsParamsHttpCall.yaml index 536f3331..34c2b25f 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostClientCredentialsParamsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostClientCredentialsParamsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.1' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml index c4e068bb..cac89ace 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.2' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordAllGrantsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordAllGrantsHttpCall.yaml index 468a0d3d..8e0e5f87 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordAllGrantsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordAllGrantsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.3' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordAsArgHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordAsArgHttpCall.yaml index 26d035f0..b5c8b9d6 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordAsArgHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordAsArgHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.4' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordHttpCall.yaml index be49e5aa..323cfe28 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcClientSecretPostPasswordHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples + namespace: test name: oauth2-authentication - version: '0.1.0' + version: '0.0.12' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsHttpCall.yaml index c36c53b8..6ce4868a 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.5' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsParamsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsParamsHttpCall.yaml index cbcba38d..a47a8fd1 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsParamsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsParamsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.6' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsParamsNoEndPointHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsParamsNoEndPointHttpCall.yaml index cbcba38d..8cbcf10c 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsParamsNoEndPointHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcJSONClientCredentialsParamsNoEndPointHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.7' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordAllGrantsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordAllGrantsHttpCall.yaml index ae36c8fc..6e3c3b8a 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordAllGrantsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordAllGrantsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.8' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordAsArgHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordAsArgHttpCall.yaml index 477e232e..9c48d176 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordAsArgHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordAsArgHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.9' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordHttpCall.yaml index e78e8b85..b34b4309 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.10' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordNoEndpointsHttpCall.yaml b/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordNoEndpointsHttpCall.yaml index 1dd1ed87..d100e284 100644 --- a/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordNoEndpointsHttpCall.yaml +++ b/impl/test/src/test/resources/workflows-samples/openidcJSONPasswordNoEndpointsHttpCall.yaml @@ -1,8 +1,8 @@ document: dsl: '1.0.0-alpha5' - namespace: examples - name: oauth2-authentication - version: '0.1.0' + namespace: test + name: openid-authentication + version: '0.0.11' do: - getPet: call: http diff --git a/impl/test/src/test/resources/workflows-samples/wait-set.yaml b/impl/test/src/test/resources/workflows-samples/wait-set.yaml index 74da694c..0fe9c4fa 100644 --- a/impl/test/src/test/resources/workflows-samples/wait-set.yaml +++ b/impl/test/src/test/resources/workflows-samples/wait-set.yaml @@ -1,7 +1,7 @@ document: dsl: '1.0.0-alpha5' namespace: test - name: simple-expression + name: wait-set version: '0.1.0' do: - waitABit: