From bd43f98f6224b2c2e09865ef66181539b780597d Mon Sep 17 00:00:00 2001 From: fjtirado Date: Tue, 26 Aug 2025 10:41:47 +0200 Subject: [PATCH] [Fix #737] Adding test module Signed-off-by: fjtirado --- .../impl/WorkflowApplication.java | 16 ++--- .../impl/events/InMemoryEvents.java | 11 +--- impl/http/pom.xml | 53 ---------------- .../executors/http/OAuth2AuthProvider.java | 8 +-- .../http/oauth/AccessTokenProvider.java | 2 - .../impl/executors/http/oauth}/JWT.java | 2 +- .../executors/http/oauth}/JWTConverter.java | 2 +- impl/jackson/pom.xml | 29 --------- .../expressions/jq/JacksonModelFactory.java | 2 +- .../events}/JacksonCloudEventUtils.java | 2 +- .../events}/JacksonLifeCyclePublisher.java | 2 +- .../schema}/JsonSchemaValidator.java | 2 +- .../schema}/JsonSchemaValidatorFactory.java | 2 +- ...w.impl.lifecycle.WorkflowExecutionListener | 2 +- ...orkflow.impl.schema.SchemaValidatorFactory | 2 +- impl/jwt-impl/pom.xml | 20 ++---- .../oauth/jackson}/JacksonJWTConverter.java | 37 +++++------ .../http/oauth/jackson}/JacksonJWTImpl.java | 22 +++---- ...o.serverlessworkflow.http.jwt.JWTConverter | 1 - ...low.impl.executors.http.oauth.JWTConverter | 1 + .../impl/http/jwt/JacksonJWTImplTest.java | 3 +- impl/jwt/pom.xml | 15 ----- impl/pom.xml | 2 +- impl/test/pom.xml | 62 +++++++++++++++++++ .../impl/test}/DateTimeDescriptorTest.java | 2 +- .../impl/test}/EventDefinitionTest.java | 7 ++- .../test}/HTTPWorkflowDefinitionTest.java | 4 +- .../impl/test}/LifeCycleEventsTest.java | 7 ++- .../OAuthHTTPWorkflowDefinitionTest.java | 34 +--------- .../impl/test}/WorkflowDefinitionTest.java | 6 +- .../call-http-endpoint-interpolation.yaml | 0 ...http-query-parameters-external-schema.yaml | 0 .../resources/call-http-query-parameters.yaml | 0 .../src/test/resources/callGetHttp.yaml | 0 .../src/test/resources/callPostHttp.yaml | 0 .../src/test/resources/conditional-set.yaml | 0 .../src/test/resources/emit-doctor.yaml | 0 .../src/test/resources/emit-out.yaml | 0 .../src/test/resources/emit.yaml | 0 .../src/test/resources/for-collect.yaml | 0 .../src/test/resources/for-sum.yaml | 0 .../src/test/resources/fork-no-compete.yaml | 0 .../src/test/resources/fork.yaml | 0 .../src/test/resources/listen-to-all.yaml | 0 .../test/resources/listen-to-any-filter.yaml | 0 .../listen-to-any-until-consumed.yaml | 0 .../test/resources/listen-to-any-until.yaml | 0 .../src/test/resources/listen-to-any.yaml | 0 ...ntSecretPostClientCredentialsHttpCall.yaml | 0 ...etPostClientCredentialsParamsHttpCall.yaml | 0 ...ntCredentialsParamsNoEndPointHttpCall.yaml | 0 ...ntSecretPostPasswordAllGrantsHttpCall.yaml | 0 ...ClientSecretPostPasswordAsArgHttpCall.yaml | 0 ...oAuthClientSecretPostPasswordHttpCall.yaml | 0 ...SecretPostPasswordNoEndpointsHttpCall.yaml | 0 .../oAuthJSONClientCredentialsHttpCall.yaml | 0 ...thJSONClientCredentialsParamsHttpCall.yaml | 0 ...ntCredentialsParamsNoEndPointHttpCall.yaml | 0 .../oAuthJSONPasswordAllGrantsHttpCall.yaml | 0 .../oAuthJSONPasswordAsArgHttpCall.yaml | 0 .../resources/oAuthJSONPasswordHttpCall.yaml | 0 .../oAuthJSONPasswordNoEndpointsHttpCall.yaml | 0 .../src/test/resources/raise-inline.yaml | 0 .../src/test/resources/raise-reusable.yaml | 0 .../test/resources/schema/searchquery.yaml | 0 .../src/test/resources/simple-expression.yaml | 0 .../src/test/resources/switch-then-loop.yaml | 0 .../test/resources/switch-then-string.yaml | 0 .../src/test/resources/wait-set.yaml | 0 69 files changed, 143 insertions(+), 217 deletions(-) rename impl/{jwt/src/main/java/io/serverlessworkflow/http/jwt => http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth}/JWT.java (94%) rename impl/{jwt/src/main/java/io/serverlessworkflow/http/jwt => http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth}/JWTConverter.java (94%) rename impl/jackson/src/main/java/io/serverlessworkflow/impl/{events/json => jackson/events}/JacksonCloudEventUtils.java (98%) rename impl/jackson/src/main/java/io/serverlessworkflow/impl/{events/json => jackson/events}/JacksonLifeCyclePublisher.java (97%) rename impl/jackson/src/main/java/io/serverlessworkflow/impl/{schema/json => jackson/schema}/JsonSchemaValidator.java (97%) rename impl/jackson/src/main/java/io/serverlessworkflow/impl/{schema/json => jackson/schema}/JsonSchemaValidatorFactory.java (97%) rename impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/{http/jwt => executors/http/oauth/jackson}/JacksonJWTConverter.java (53%) rename impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/{http/jwt => executors/http/oauth/jackson}/JacksonJWTImpl.java (85%) delete mode 100644 impl/jwt-impl/src/main/resources/META-INF/services/io.serverlessworkflow.http.jwt.JWTConverter create mode 100644 impl/jwt-impl/src/main/resources/META-INF/services/io.serverlessworkflow.impl.executors.http.oauth.JWTConverter delete mode 100644 impl/jwt/pom.xml create mode 100644 impl/test/pom.xml rename impl/{jackson/src/test/java/io/serverlessworkflow/impl => test/src/test/java/io/serverlessworkflow/impl/test}/DateTimeDescriptorTest.java (96%) rename impl/{jackson/src/test/java/io/serverlessworkflow/impl => test/src/test/java/io/serverlessworkflow/impl/test}/EventDefinitionTest.java (95%) rename impl/{http/src/test/java/io/serverlessworkflow/impl => test/src/test/java/io/serverlessworkflow/impl/test}/HTTPWorkflowDefinitionTest.java (96%) rename impl/{jackson/src/test/java/io/serverlessworkflow/impl => test/src/test/java/io/serverlessworkflow/impl/test}/LifeCycleEventsTest.java (96%) rename impl/{http/src/test/java/io/serverlessworkflow/impl => test/src/test/java/io/serverlessworkflow/impl/test}/OAuthHTTPWorkflowDefinitionTest.java (96%) rename impl/{jackson/src/test/java/io/serverlessworkflow/impl => test/src/test/java/io/serverlessworkflow/impl/test}/WorkflowDefinitionTest.java (96%) rename impl/{http => test}/src/test/resources/call-http-endpoint-interpolation.yaml (100%) rename impl/{http => test}/src/test/resources/call-http-query-parameters-external-schema.yaml (100%) rename impl/{http => test}/src/test/resources/call-http-query-parameters.yaml (100%) rename impl/{http => test}/src/test/resources/callGetHttp.yaml (100%) rename impl/{http => test}/src/test/resources/callPostHttp.yaml (100%) rename impl/{jackson => test}/src/test/resources/conditional-set.yaml (100%) rename impl/{jackson => test}/src/test/resources/emit-doctor.yaml (100%) rename impl/{jackson => test}/src/test/resources/emit-out.yaml (100%) rename impl/{jackson => test}/src/test/resources/emit.yaml (100%) rename impl/{jackson => test}/src/test/resources/for-collect.yaml (100%) rename impl/{jackson => test}/src/test/resources/for-sum.yaml (100%) rename impl/{jackson => test}/src/test/resources/fork-no-compete.yaml (100%) rename impl/{jackson => test}/src/test/resources/fork.yaml (100%) rename impl/{jackson => test}/src/test/resources/listen-to-all.yaml (100%) rename impl/{jackson => test}/src/test/resources/listen-to-any-filter.yaml (100%) rename impl/{jackson => test}/src/test/resources/listen-to-any-until-consumed.yaml (100%) rename impl/{jackson => test}/src/test/resources/listen-to-any-until.yaml (100%) rename impl/{jackson => test}/src/test/resources/listen-to-any.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthClientSecretPostClientCredentialsHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthClientSecretPostClientCredentialsParamsHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthClientSecretPostPasswordAllGrantsHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthClientSecretPostPasswordAsArgHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthClientSecretPostPasswordHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthClientSecretPostPasswordNoEndpointsHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthJSONClientCredentialsHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthJSONClientCredentialsParamsHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthJSONClientCredentialsParamsNoEndPointHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthJSONPasswordAllGrantsHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthJSONPasswordAsArgHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthJSONPasswordHttpCall.yaml (100%) rename impl/{http => test}/src/test/resources/oAuthJSONPasswordNoEndpointsHttpCall.yaml (100%) rename impl/{jackson => test}/src/test/resources/raise-inline.yaml (100%) rename impl/{jackson => test}/src/test/resources/raise-reusable.yaml (100%) rename impl/{http => test}/src/test/resources/schema/searchquery.yaml (100%) rename impl/{jackson => test}/src/test/resources/simple-expression.yaml (100%) rename impl/{jackson => test}/src/test/resources/switch-then-loop.yaml (100%) rename impl/{jackson => test}/src/test/resources/switch-then-string.yaml (100%) rename impl/{jackson => test}/src/test/resources/wait-set.yaml (100%) diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java b/impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java index a89c798e..e1cb5838 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java @@ -141,8 +141,8 @@ public SchemaValidator getValidator(SchemaInline inline) { private WorkflowPositionFactory positionFactory = () -> new QueueWorkflowPosition(); private WorkflowIdFactory idFactory = () -> UlidCreator.getMonotonicUlid().toString(); private ExecutorServiceFactory executorFactory = new DefaultExecutorServiceFactory(); - private EventConsumer eventConsumer = InMemoryEvents.get(); - private EventPublisher eventPublisher = InMemoryEvents.get(); + private EventConsumer eventConsumer; + private EventPublisher eventPublisher; private RuntimeDescriptorFactory descriptorFactory = () -> new RuntimeDescriptor("reference impl", "1.0.0_alpha", Collections.emptyMap()); @@ -193,12 +193,9 @@ public Builder withDescriptorFactory(RuntimeDescriptorFactory factory) { return this; } - public Builder withEventConsumer(EventConsumer eventConsumer) { + public Builder withEventHandler( + EventPublisher eventPublisher, EventConsumer eventConsumer) { this.eventConsumer = eventConsumer; - return this; - } - - public Builder withEventPublisher(EventPublisher eventPublisher) { this.eventPublisher = eventPublisher; return this; } @@ -222,6 +219,11 @@ public WorkflowApplication build() { .findFirst() .orElseGet(() -> DefaultTaskExecutorFactory.get()); } + if (eventConsumer == null && eventPublisher == null) { + InMemoryEvents inMemory = new InMemoryEvents(executorFactory); + eventPublisher = inMemory; + eventConsumer = inMemory; + } return new WorkflowApplication(this); } } 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 02f1b9cf..2bcf96ef 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 @@ -16,7 +16,6 @@ package io.serverlessworkflow.impl.events; import io.cloudevents.CloudEvent; -import io.serverlessworkflow.impl.DefaultExecutorServiceFactory; import io.serverlessworkflow.impl.ExecutorServiceFactory; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -30,15 +29,11 @@ */ public class InMemoryEvents extends AbstractTypeConsumer implements EventPublisher { - private static InMemoryEvents instance = new InMemoryEvents(); - - private InMemoryEvents() {} - - public static InMemoryEvents get() { - return instance; + public InMemoryEvents(ExecutorServiceFactory serviceFactory) { + this.serviceFactory = serviceFactory; } - private ExecutorServiceFactory serviceFactory = new DefaultExecutorServiceFactory(); + private ExecutorServiceFactory serviceFactory; private Map> topicMap = new ConcurrentHashMap<>(); diff --git a/impl/http/pom.xml b/impl/http/pom.xml index 4b128a45..ee63b7f0 100644 --- a/impl/http/pom.xml +++ b/impl/http/pom.xml @@ -16,58 +16,5 @@ io.serverlessworkflow serverlessworkflow-impl-core - - io.serverlessworkflow - serverlessworkflow-jwt - - - org.glassfish.jersey.media - jersey-media-json-jackson - - - org.glassfish.jersey.core - jersey-client - - - io.serverlessworkflow - serverlessworkflow-api - test - - - io.serverlessworkflow - serverlessworkflow-impl-jackson - test - - - io.serverlessworkflow - serverlessworkflow-impl-jackson-jwt - test - - - org.junit.jupiter - junit-jupiter-api - - - org.junit.jupiter - junit-jupiter-engine - - - org.junit.jupiter - junit-jupiter-params - - - org.assertj - assertj-core - - - ch.qos.logback - logback-classic - test - - - com.squareup.okhttp3 - mockwebserver - test - \ No newline at end of file diff --git a/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/OAuth2AuthProvider.java b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/OAuth2AuthProvider.java index d508507f..058454dc 100644 --- a/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/OAuth2AuthProvider.java +++ b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/OAuth2AuthProvider.java @@ -18,11 +18,11 @@ import io.serverlessworkflow.api.types.OAuth2AuthenticationPolicy; import io.serverlessworkflow.api.types.Oauth2; import io.serverlessworkflow.api.types.Workflow; -import io.serverlessworkflow.http.jwt.JWT; import io.serverlessworkflow.impl.TaskContext; import io.serverlessworkflow.impl.WorkflowApplication; import io.serverlessworkflow.impl.WorkflowContext; import io.serverlessworkflow.impl.WorkflowModel; +import io.serverlessworkflow.impl.executors.http.oauth.JWT; import io.serverlessworkflow.impl.executors.http.oauth.OAuthRequestBuilder; import jakarta.ws.rs.client.Invocation; import jakarta.ws.rs.client.Invocation.Builder; @@ -54,11 +54,7 @@ public void preRequest( Invocation.Builder builder, WorkflowContext workflow, TaskContext task, WorkflowModel model) { JWT jwt = requestBuilder.build(workflow, task, model).validateAndGet(); String type = - jwt.claim("typ", String.class) - .map(String::trim) - .filter(t -> !t.isEmpty()) - .orElseThrow(() -> new IllegalStateException("Token type is not present")); - + jwt.type().orElseThrow(() -> new IllegalStateException("Token type is not present")); builder.header( AuthProviderFactory.AUTH_HEADER_NAME, String.format(BEARER_TOKEN, type, jwt.token())); } diff --git a/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/AccessTokenProvider.java b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/AccessTokenProvider.java index e46c83d9..03df2400 100644 --- a/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/AccessTokenProvider.java +++ b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/AccessTokenProvider.java @@ -15,8 +15,6 @@ */ package io.serverlessworkflow.impl.executors.http.oauth; -import io.serverlessworkflow.http.jwt.JWT; -import io.serverlessworkflow.http.jwt.JWTConverter; import io.serverlessworkflow.impl.TaskContext; import java.util.List; import java.util.Map; diff --git a/impl/jwt/src/main/java/io/serverlessworkflow/http/jwt/JWT.java b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/JWT.java similarity index 94% rename from impl/jwt/src/main/java/io/serverlessworkflow/http/jwt/JWT.java rename to impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/JWT.java index e3e36502..91da6737 100644 --- a/impl/jwt/src/main/java/io/serverlessworkflow/http/jwt/JWT.java +++ b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/JWT.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.http.jwt; +package io.serverlessworkflow.impl.executors.http.oauth; import java.time.Instant; import java.util.List; diff --git a/impl/jwt/src/main/java/io/serverlessworkflow/http/jwt/JWTConverter.java b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/JWTConverter.java similarity index 94% rename from impl/jwt/src/main/java/io/serverlessworkflow/http/jwt/JWTConverter.java rename to impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/JWTConverter.java index fd3d759e..269436fb 100644 --- a/impl/jwt/src/main/java/io/serverlessworkflow/http/jwt/JWTConverter.java +++ b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/JWTConverter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.http.jwt; +package io.serverlessworkflow.impl.executors.http.oauth; public interface JWTConverter { diff --git a/impl/jackson/pom.xml b/impl/jackson/pom.xml index 8079cbab..0ed7816f 100644 --- a/impl/jackson/pom.xml +++ b/impl/jackson/pom.xml @@ -28,34 +28,5 @@ net.thisptr jackson-jq - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.junit.jupiter - junit-jupiter-params - test - - - org.assertj - assertj-core - test - - - ch.qos.logback - logback-classic - test - - - org.mockito - mockito-core - \ No newline at end of file diff --git a/impl/jackson/src/main/java/io/serverlessworkflow/impl/expressions/jq/JacksonModelFactory.java b/impl/jackson/src/main/java/io/serverlessworkflow/impl/expressions/jq/JacksonModelFactory.java index f025fc83..8f894fdb 100644 --- a/impl/jackson/src/main/java/io/serverlessworkflow/impl/expressions/jq/JacksonModelFactory.java +++ b/impl/jackson/src/main/java/io/serverlessworkflow/impl/expressions/jq/JacksonModelFactory.java @@ -27,8 +27,8 @@ import io.serverlessworkflow.impl.WorkflowModel; import io.serverlessworkflow.impl.WorkflowModelCollection; import io.serverlessworkflow.impl.WorkflowModelFactory; -import io.serverlessworkflow.impl.events.json.JacksonCloudEventUtils; import io.serverlessworkflow.impl.jackson.JsonUtils; +import io.serverlessworkflow.impl.jackson.events.JacksonCloudEventUtils; import java.math.BigDecimal; import java.time.OffsetDateTime; import java.util.Map; diff --git a/impl/jackson/src/main/java/io/serverlessworkflow/impl/events/json/JacksonCloudEventUtils.java b/impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/events/JacksonCloudEventUtils.java similarity index 98% rename from impl/jackson/src/main/java/io/serverlessworkflow/impl/events/json/JacksonCloudEventUtils.java rename to impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/events/JacksonCloudEventUtils.java index 10ea02be..61df6502 100644 --- a/impl/jackson/src/main/java/io/serverlessworkflow/impl/events/json/JacksonCloudEventUtils.java +++ b/impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/events/JacksonCloudEventUtils.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl.events.json; +package io.serverlessworkflow.impl.jackson.events; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.NullNode; diff --git a/impl/jackson/src/main/java/io/serverlessworkflow/impl/events/json/JacksonLifeCyclePublisher.java b/impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/events/JacksonLifeCyclePublisher.java similarity index 97% rename from impl/jackson/src/main/java/io/serverlessworkflow/impl/events/json/JacksonLifeCyclePublisher.java rename to impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/events/JacksonLifeCyclePublisher.java index c785a273..be209869 100644 --- a/impl/jackson/src/main/java/io/serverlessworkflow/impl/events/json/JacksonLifeCyclePublisher.java +++ b/impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/events/JacksonLifeCyclePublisher.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl.events.json; +package io.serverlessworkflow.impl.jackson.events; import com.fasterxml.jackson.core.JsonProcessingException; import io.serverlessworkflow.impl.jackson.JsonUtils; diff --git a/impl/jackson/src/main/java/io/serverlessworkflow/impl/schema/json/JsonSchemaValidator.java b/impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/schema/JsonSchemaValidator.java similarity index 97% rename from impl/jackson/src/main/java/io/serverlessworkflow/impl/schema/json/JsonSchemaValidator.java rename to impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/schema/JsonSchemaValidator.java index c4859ba9..99cea32b 100644 --- a/impl/jackson/src/main/java/io/serverlessworkflow/impl/schema/json/JsonSchemaValidator.java +++ b/impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/schema/JsonSchemaValidator.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl.schema.json; +package io.serverlessworkflow.impl.jackson.schema; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.JsonSchema; diff --git a/impl/jackson/src/main/java/io/serverlessworkflow/impl/schema/json/JsonSchemaValidatorFactory.java b/impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/schema/JsonSchemaValidatorFactory.java similarity index 97% rename from impl/jackson/src/main/java/io/serverlessworkflow/impl/schema/json/JsonSchemaValidatorFactory.java rename to impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/schema/JsonSchemaValidatorFactory.java index 9b89e46c..78e7324d 100644 --- a/impl/jackson/src/main/java/io/serverlessworkflow/impl/schema/json/JsonSchemaValidatorFactory.java +++ b/impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/schema/JsonSchemaValidatorFactory.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl.schema.json; +package io.serverlessworkflow.impl.jackson.schema; import com.fasterxml.jackson.databind.ObjectMapper; import io.serverlessworkflow.api.WorkflowFormat; diff --git a/impl/jackson/src/main/resources/META-INF/services/io.serverlessworkflow.impl.lifecycle.WorkflowExecutionListener b/impl/jackson/src/main/resources/META-INF/services/io.serverlessworkflow.impl.lifecycle.WorkflowExecutionListener index 7324bcc0..511575b5 100644 --- a/impl/jackson/src/main/resources/META-INF/services/io.serverlessworkflow.impl.lifecycle.WorkflowExecutionListener +++ b/impl/jackson/src/main/resources/META-INF/services/io.serverlessworkflow.impl.lifecycle.WorkflowExecutionListener @@ -1 +1 @@ -io.serverlessworkflow.impl.events.json.JacksonLifeCyclePublisher \ No newline at end of file +io.serverlessworkflow.impl.jackson.events.JacksonLifeCyclePublisher \ No newline at end of file diff --git a/impl/jackson/src/main/resources/META-INF/services/io.serverlessworkflow.impl.schema.SchemaValidatorFactory b/impl/jackson/src/main/resources/META-INF/services/io.serverlessworkflow.impl.schema.SchemaValidatorFactory index 3100f8fa..9480ce16 100644 --- a/impl/jackson/src/main/resources/META-INF/services/io.serverlessworkflow.impl.schema.SchemaValidatorFactory +++ b/impl/jackson/src/main/resources/META-INF/services/io.serverlessworkflow.impl.schema.SchemaValidatorFactory @@ -1 +1 @@ -io.serverlessworkflow.impl.schema.json.JsonSchemaValidatorFactory \ No newline at end of file +io.serverlessworkflow.impl.jackson.schema.JsonSchemaValidatorFactory \ No newline at end of file diff --git a/impl/jwt-impl/pom.xml b/impl/jwt-impl/pom.xml index f15d854a..a597e09c 100644 --- a/impl/jwt-impl/pom.xml +++ b/impl/jwt-impl/pom.xml @@ -10,36 +10,24 @@ serverlessworkflow-impl-jackson-jwt - Serverless Workflow :: Impl :: JWT + Serverless Workflow :: Impl :: JWT :: Jackson io.serverlessworkflow - serverlessworkflow-jwt + serverlessworkflow-impl-http - com.fasterxml.jackson.core - jackson-databind + io.serverlessworkflow + serverlessworkflow-impl-jackson org.junit.jupiter junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.junit.jupiter - junit-jupiter-params - test org.assertj assertj-core - test diff --git a/impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/http/jwt/JacksonJWTConverter.java b/impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/jackson/JacksonJWTConverter.java similarity index 53% rename from impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/http/jwt/JacksonJWTConverter.java rename to impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/jackson/JacksonJWTConverter.java index 15df48fa..04babf62 100644 --- a/impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/http/jwt/JacksonJWTConverter.java +++ b/impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/jackson/JacksonJWTConverter.java @@ -13,42 +13,39 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl.http.jwt; +package io.serverlessworkflow.impl.executors.http.oauth.jackson; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.serverlessworkflow.http.jwt.JWT; -import io.serverlessworkflow.http.jwt.JWTConverter; +import com.fasterxml.jackson.core.type.TypeReference; +import io.serverlessworkflow.impl.executors.http.oauth.JWT; +import io.serverlessworkflow.impl.executors.http.oauth.JWTConverter; +import io.serverlessworkflow.impl.jackson.JsonUtils; +import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Map; public class JacksonJWTConverter implements JWTConverter { - private static final ObjectMapper MAPPER = new ObjectMapper(); - @Override public JWT fromToken(String token) throws IllegalArgumentException { if (token == null || token.isBlank()) { throw new IllegalArgumentException("JWT token must not be null or blank"); } - String[] parts = token.split("\\."); if (parts.length < 2) { - throw new IllegalArgumentException("Invalid JWT token format"); + throw new IllegalArgumentException( + "Invalid JWT token format. There should at least two parts separated by :"); } - try { - String headerJson = - new String(Base64.getUrlDecoder().decode(parts[0]), StandardCharsets.UTF_8); - String payloadJson = - new String(Base64.getUrlDecoder().decode(parts[1]), StandardCharsets.UTF_8); - - Map header = MAPPER.readValue(headerJson, Map.class); - Map claims = MAPPER.readValue(payloadJson, Map.class); + return new JacksonJWTImpl(token, fromPart2Map(parts[0]), fromPart2Map(parts[1])); + } - return new JacksonJWTImpl(token, header, claims); - } catch (JsonProcessingException e) { - throw new IllegalArgumentException("Failed to parse JWT token payload: " + e.getMessage(), e); + private static final Map fromPart2Map(String part) { + String decoded = new String(Base64.getUrlDecoder().decode(part), StandardCharsets.UTF_8); + try { + return JsonUtils.mapper().readValue(decoded, new TypeReference>() {}); + } catch (IOException e) { + throw new IllegalArgumentException( + "Invalid JTW token format. " + decoded + " is not a valid json", e); } } } diff --git a/impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/http/jwt/JacksonJWTImpl.java b/impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/jackson/JacksonJWTImpl.java similarity index 85% rename from impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/http/jwt/JacksonJWTImpl.java rename to impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/jackson/JacksonJWTImpl.java index 591810df..5d0c6486 100644 --- a/impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/http/jwt/JacksonJWTImpl.java +++ b/impl/jwt-impl/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/jackson/JacksonJWTImpl.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl.http.jwt; +package io.serverlessworkflow.impl.executors.http.oauth.jackson; -import io.serverlessworkflow.http.jwt.JWT; +import io.serverlessworkflow.impl.executors.http.oauth.JWT; import java.time.Instant; import java.util.Arrays; import java.util.Collection; @@ -33,12 +33,9 @@ public class JacksonJWTImpl implements JWT { private final String token; JacksonJWTImpl(String token, Map header, Map claims) { - Objects.requireNonNull(token, "token"); - Objects.requireNonNull(header, "header"); - Objects.requireNonNull(claims, "claims"); - this.token = token; - this.header = Collections.unmodifiableMap(header); - this.claims = Collections.unmodifiableMap(claims); + this.token = Objects.requireNonNull(token, "token"); + this.header = Collections.unmodifiableMap(Objects.requireNonNull(header, "header")); + this.claims = Collections.unmodifiableMap(Objects.requireNonNull(claims, "claims")); } @Override @@ -98,10 +95,9 @@ public Optional expiresAt() { @Override public Optional type() { - if (header.containsKey("typ")) { - return Optional.of(asString(header.get("typ"))); - } - return Optional.ofNullable(asString(claims.get("typ"))); + return header.containsKey("typ") + ? Optional.of(asString(header.get("typ"))) + : Optional.ofNullable(asString(claims.get("typ"))); } private static Instant toInstant(Object v) { @@ -130,7 +126,7 @@ private static Instant toInstant(Object v) { } private static String asString(Object v) { - return (v == null) ? null : String.valueOf(v).trim(); + return v == null ? null : String.valueOf(v).trim(); } @Override diff --git a/impl/jwt-impl/src/main/resources/META-INF/services/io.serverlessworkflow.http.jwt.JWTConverter b/impl/jwt-impl/src/main/resources/META-INF/services/io.serverlessworkflow.http.jwt.JWTConverter deleted file mode 100644 index 1c898a8b..00000000 --- a/impl/jwt-impl/src/main/resources/META-INF/services/io.serverlessworkflow.http.jwt.JWTConverter +++ /dev/null @@ -1 +0,0 @@ -io.serverlessworkflow.impl.http.jwt.JacksonJWTConverter \ No newline at end of file diff --git a/impl/jwt-impl/src/main/resources/META-INF/services/io.serverlessworkflow.impl.executors.http.oauth.JWTConverter b/impl/jwt-impl/src/main/resources/META-INF/services/io.serverlessworkflow.impl.executors.http.oauth.JWTConverter new file mode 100644 index 00000000..9d4bcb2b --- /dev/null +++ b/impl/jwt-impl/src/main/resources/META-INF/services/io.serverlessworkflow.impl.executors.http.oauth.JWTConverter @@ -0,0 +1 @@ +io.serverlessworkflow.impl.executors.http.oauth.jackson.JacksonJWTConverter \ No newline at end of file diff --git a/impl/jwt-impl/src/test/java/io/serverlessworkflow/impl/http/jwt/JacksonJWTImplTest.java b/impl/jwt-impl/src/test/java/io/serverlessworkflow/impl/http/jwt/JacksonJWTImplTest.java index 3a992f47..103f48fd 100644 --- a/impl/jwt-impl/src/test/java/io/serverlessworkflow/impl/http/jwt/JacksonJWTImplTest.java +++ b/impl/jwt-impl/src/test/java/io/serverlessworkflow/impl/http/jwt/JacksonJWTImplTest.java @@ -17,7 +17,8 @@ import static org.junit.jupiter.api.Assertions.*; -import io.serverlessworkflow.http.jwt.JWT; +import io.serverlessworkflow.impl.executors.http.oauth.JWT; +import io.serverlessworkflow.impl.executors.http.oauth.jackson.JacksonJWTConverter; import java.time.Instant; import java.util.List; import java.util.Map; diff --git a/impl/jwt/pom.xml b/impl/jwt/pom.xml deleted file mode 100644 index 6a274a36..00000000 --- a/impl/jwt/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 4.0.0 - - io.serverlessworkflow - serverlessworkflow-impl - 8.0.0-SNAPSHOT - - - serverlessworkflow-jwt - Serverless Workflow :: JWT - jar - \ No newline at end of file diff --git a/impl/pom.xml b/impl/pom.xml index 47fd9b22..fbed0558 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -75,7 +75,7 @@ http core jackson - jwt jwt-impl + test \ No newline at end of file diff --git a/impl/test/pom.xml b/impl/test/pom.xml new file mode 100644 index 00000000..b4009c55 --- /dev/null +++ b/impl/test/pom.xml @@ -0,0 +1,62 @@ + + 4.0.0 + + io.serverlessworkflow + serverlessworkflow-impl + 8.0.0-SNAPSHOT + + serverlessworkflow-impl-test + Serverless Workflow :: Impl :: Test + + + io.serverlessworkflow + serverlessworkflow-impl-jackson + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.junit.jupiter + junit-jupiter-params + + + org.assertj + assertj-core + + + ch.qos.logback + logback-classic + + + org.mockito + mockito-core + + + com.squareup.okhttp3 + mockwebserver + + + io.serverlessworkflow + serverlessworkflow-impl-http + + + io.serverlessworkflow + serverlessworkflow-impl-jackson-jwt + + + org.glassfish.jersey.media + jersey-media-json-jackson + + + org.glassfish.jersey.core + jersey-client + + + \ No newline at end of file diff --git a/impl/jackson/src/test/java/io/serverlessworkflow/impl/DateTimeDescriptorTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/DateTimeDescriptorTest.java similarity index 96% rename from impl/jackson/src/test/java/io/serverlessworkflow/impl/DateTimeDescriptorTest.java rename to impl/test/src/test/java/io/serverlessworkflow/impl/test/DateTimeDescriptorTest.java index add57b92..09e4af56 100644 --- a/impl/jackson/src/test/java/io/serverlessworkflow/impl/DateTimeDescriptorTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/DateTimeDescriptorTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl; +package io.serverlessworkflow.impl.test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/impl/jackson/src/test/java/io/serverlessworkflow/impl/EventDefinitionTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/EventDefinitionTest.java similarity index 95% rename from impl/jackson/src/test/java/io/serverlessworkflow/impl/EventDefinitionTest.java rename to impl/test/src/test/java/io/serverlessworkflow/impl/test/EventDefinitionTest.java index b7483943..548ba61c 100644 --- a/impl/jackson/src/test/java/io/serverlessworkflow/impl/EventDefinitionTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/EventDefinitionTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl; +package io.serverlessworkflow.impl.test; import static org.assertj.core.api.Assertions.assertThat; @@ -22,6 +22,11 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import io.serverlessworkflow.api.WorkflowReader; +import io.serverlessworkflow.impl.WorkflowApplication; +import io.serverlessworkflow.impl.WorkflowDefinition; +import io.serverlessworkflow.impl.WorkflowInstance; +import io.serverlessworkflow.impl.WorkflowModel; +import io.serverlessworkflow.impl.WorkflowStatus; import io.serverlessworkflow.impl.jackson.JsonUtils; import java.io.IOException; import java.time.Instant; diff --git a/impl/http/src/test/java/io/serverlessworkflow/impl/HTTPWorkflowDefinitionTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/HTTPWorkflowDefinitionTest.java similarity index 96% rename from impl/http/src/test/java/io/serverlessworkflow/impl/HTTPWorkflowDefinitionTest.java rename to impl/test/src/test/java/io/serverlessworkflow/impl/test/HTTPWorkflowDefinitionTest.java index fd1c575b..84e95e1e 100644 --- a/impl/http/src/test/java/io/serverlessworkflow/impl/HTTPWorkflowDefinitionTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/HTTPWorkflowDefinitionTest.java @@ -13,12 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl; +package io.serverlessworkflow.impl.test; import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowableOfType; +import io.serverlessworkflow.impl.WorkflowApplication; +import io.serverlessworkflow.impl.WorkflowModel; import java.io.IOException; import java.util.Map; import java.util.stream.Stream; diff --git a/impl/jackson/src/test/java/io/serverlessworkflow/impl/LifeCycleEventsTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/LifeCycleEventsTest.java similarity index 96% rename from impl/jackson/src/test/java/io/serverlessworkflow/impl/LifeCycleEventsTest.java rename to impl/test/src/test/java/io/serverlessworkflow/impl/test/LifeCycleEventsTest.java index 47b02e74..a9d3502c 100644 --- a/impl/jackson/src/test/java/io/serverlessworkflow/impl/LifeCycleEventsTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/LifeCycleEventsTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl; +package io.serverlessworkflow.impl.test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowableOfType; @@ -22,6 +22,10 @@ import io.cloudevents.core.data.PojoCloudEventData; import io.serverlessworkflow.api.WorkflowReader; 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 io.serverlessworkflow.impl.events.EventRegistration; import io.serverlessworkflow.impl.events.EventRegistrationBuilder; import io.serverlessworkflow.impl.lifecycle.ce.TaskCompletedCEData; @@ -67,6 +71,7 @@ void setup() { @AfterEach void close() { registrations.forEach(r -> appl.eventConsumer().unregister(r)); + appl.close(); } @Test diff --git a/impl/http/src/test/java/io/serverlessworkflow/impl/OAuthHTTPWorkflowDefinitionTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/OAuthHTTPWorkflowDefinitionTest.java similarity index 96% rename from impl/http/src/test/java/io/serverlessworkflow/impl/OAuthHTTPWorkflowDefinitionTest.java rename to impl/test/src/test/java/io/serverlessworkflow/impl/test/OAuthHTTPWorkflowDefinitionTest.java index aa9d5859..b218fb25 100644 --- a/impl/http/src/test/java/io/serverlessworkflow/impl/OAuthHTTPWorkflowDefinitionTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/OAuthHTTPWorkflowDefinitionTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl; +package io.serverlessworkflow.impl.test; import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.serverlessworkflow.api.types.Workflow; +import io.serverlessworkflow.impl.WorkflowApplication; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.Instant; @@ -102,8 +103,6 @@ public void testOAuthClientSecretPostPasswordWorkflowExecution() throws Exceptio try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -155,8 +154,6 @@ public void testOAuthClientSecretPostWithArgsWorkflowExecution() throws Exceptio try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -208,8 +205,6 @@ public void testOAuthClientSecretPostWithArgsNoEndPointWorkflowExecution() throw try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -263,8 +258,6 @@ public void testOAuthClientSecretPostWithArgsAllGrantsWorkflowExecution() throws try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -315,8 +308,6 @@ public void testOAuthClientSecretPostClientCredentialsWorkflowExecution() throws try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -367,8 +358,6 @@ public void testOAuthClientSecretPostClientCredentialsParamsWorkflowExecution() try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -421,8 +410,6 @@ public void testOAuthClientSecretPostClientCredentialsParamsNoEndpointWorkflowEx try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -466,8 +453,6 @@ public void testOAuthJSONPasswordWorkflowExecution() throws Exception { try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -532,8 +517,6 @@ public void testOAuthJSONWithArgsWorkflowExecution() throws Exception { try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -595,8 +578,6 @@ public void testOAuthJSONWithArgsNoEndPointWorkflowExecution() throws Exception try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -659,8 +640,6 @@ public void testOAuthJSONWithArgsAllGrantsWorkflowExecution() throws Exception { try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -726,8 +705,6 @@ public void testOAuthJSONClientCredentialsWorkflowExecution() throws Exception { try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(Map.of()).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -782,8 +759,6 @@ public void testOAuthJSONClientCredentialsParamsWorkflowExecution() throws Excep try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -839,8 +814,6 @@ public void testOAuthJSONClientCredentialsParamsNoEndpointWorkflowExecution() th try (WorkflowApplication app = WorkflowApplication.builder().build()) { result = app.workflowDefinition(workflow).instance(params).start().get().asMap().orElseThrow(); - } catch (Exception e) { - throw new RuntimeException("Workflow execution failed", e); } assertTrue(result.containsKey("message")); @@ -872,7 +845,7 @@ public static String fakeJwt(Map payload) throws Exception { MAPPER.writeValueAsString( Map.of( "alg", "RS256", - "typ", "JWT", + "typ", "Bearer", "kid", "test")); String payloadJson = MAPPER.writeValueAsString(payload); return b64Url(headerJson) + "." + b64Url(payloadJson) + ".sig"; @@ -892,7 +865,6 @@ public static String fakeAccessToken() throws Exception { "aud", "account", "sub", "test-subject", "azp", "serverless-workflow", - "typ", "Bearer", "scope", "profile email", "exp", now + 3600, "iat", now)); diff --git a/impl/jackson/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java b/impl/test/src/test/java/io/serverlessworkflow/impl/test/WorkflowDefinitionTest.java similarity index 96% rename from impl/jackson/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java rename to impl/test/src/test/java/io/serverlessworkflow/impl/test/WorkflowDefinitionTest.java index 92091f16..0ee27c58 100644 --- a/impl/jackson/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java +++ b/impl/test/src/test/java/io/serverlessworkflow/impl/test/WorkflowDefinitionTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.serverlessworkflow.impl; +package io.serverlessworkflow.impl.test; import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath; import static io.serverlessworkflow.api.WorkflowReader.validation; @@ -22,6 +22,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; +import io.serverlessworkflow.impl.WorkflowApplication; +import io.serverlessworkflow.impl.WorkflowDefinition; +import io.serverlessworkflow.impl.WorkflowException; +import io.serverlessworkflow.impl.WorkflowModel; import io.serverlessworkflow.impl.jackson.JsonUtils; import java.io.IOException; import java.time.Instant; diff --git a/impl/http/src/test/resources/call-http-endpoint-interpolation.yaml b/impl/test/src/test/resources/call-http-endpoint-interpolation.yaml similarity index 100% rename from impl/http/src/test/resources/call-http-endpoint-interpolation.yaml rename to impl/test/src/test/resources/call-http-endpoint-interpolation.yaml diff --git a/impl/http/src/test/resources/call-http-query-parameters-external-schema.yaml b/impl/test/src/test/resources/call-http-query-parameters-external-schema.yaml similarity index 100% rename from impl/http/src/test/resources/call-http-query-parameters-external-schema.yaml rename to impl/test/src/test/resources/call-http-query-parameters-external-schema.yaml diff --git a/impl/http/src/test/resources/call-http-query-parameters.yaml b/impl/test/src/test/resources/call-http-query-parameters.yaml similarity index 100% rename from impl/http/src/test/resources/call-http-query-parameters.yaml rename to impl/test/src/test/resources/call-http-query-parameters.yaml diff --git a/impl/http/src/test/resources/callGetHttp.yaml b/impl/test/src/test/resources/callGetHttp.yaml similarity index 100% rename from impl/http/src/test/resources/callGetHttp.yaml rename to impl/test/src/test/resources/callGetHttp.yaml diff --git a/impl/http/src/test/resources/callPostHttp.yaml b/impl/test/src/test/resources/callPostHttp.yaml similarity index 100% rename from impl/http/src/test/resources/callPostHttp.yaml rename to impl/test/src/test/resources/callPostHttp.yaml diff --git a/impl/jackson/src/test/resources/conditional-set.yaml b/impl/test/src/test/resources/conditional-set.yaml similarity index 100% rename from impl/jackson/src/test/resources/conditional-set.yaml rename to impl/test/src/test/resources/conditional-set.yaml diff --git a/impl/jackson/src/test/resources/emit-doctor.yaml b/impl/test/src/test/resources/emit-doctor.yaml similarity index 100% rename from impl/jackson/src/test/resources/emit-doctor.yaml rename to impl/test/src/test/resources/emit-doctor.yaml diff --git a/impl/jackson/src/test/resources/emit-out.yaml b/impl/test/src/test/resources/emit-out.yaml similarity index 100% rename from impl/jackson/src/test/resources/emit-out.yaml rename to impl/test/src/test/resources/emit-out.yaml diff --git a/impl/jackson/src/test/resources/emit.yaml b/impl/test/src/test/resources/emit.yaml similarity index 100% rename from impl/jackson/src/test/resources/emit.yaml rename to impl/test/src/test/resources/emit.yaml diff --git a/impl/jackson/src/test/resources/for-collect.yaml b/impl/test/src/test/resources/for-collect.yaml similarity index 100% rename from impl/jackson/src/test/resources/for-collect.yaml rename to impl/test/src/test/resources/for-collect.yaml diff --git a/impl/jackson/src/test/resources/for-sum.yaml b/impl/test/src/test/resources/for-sum.yaml similarity index 100% rename from impl/jackson/src/test/resources/for-sum.yaml rename to impl/test/src/test/resources/for-sum.yaml diff --git a/impl/jackson/src/test/resources/fork-no-compete.yaml b/impl/test/src/test/resources/fork-no-compete.yaml similarity index 100% rename from impl/jackson/src/test/resources/fork-no-compete.yaml rename to impl/test/src/test/resources/fork-no-compete.yaml diff --git a/impl/jackson/src/test/resources/fork.yaml b/impl/test/src/test/resources/fork.yaml similarity index 100% rename from impl/jackson/src/test/resources/fork.yaml rename to impl/test/src/test/resources/fork.yaml diff --git a/impl/jackson/src/test/resources/listen-to-all.yaml b/impl/test/src/test/resources/listen-to-all.yaml similarity index 100% rename from impl/jackson/src/test/resources/listen-to-all.yaml rename to impl/test/src/test/resources/listen-to-all.yaml diff --git a/impl/jackson/src/test/resources/listen-to-any-filter.yaml b/impl/test/src/test/resources/listen-to-any-filter.yaml similarity index 100% rename from impl/jackson/src/test/resources/listen-to-any-filter.yaml rename to impl/test/src/test/resources/listen-to-any-filter.yaml diff --git a/impl/jackson/src/test/resources/listen-to-any-until-consumed.yaml b/impl/test/src/test/resources/listen-to-any-until-consumed.yaml similarity index 100% rename from impl/jackson/src/test/resources/listen-to-any-until-consumed.yaml rename to impl/test/src/test/resources/listen-to-any-until-consumed.yaml diff --git a/impl/jackson/src/test/resources/listen-to-any-until.yaml b/impl/test/src/test/resources/listen-to-any-until.yaml similarity index 100% rename from impl/jackson/src/test/resources/listen-to-any-until.yaml rename to impl/test/src/test/resources/listen-to-any-until.yaml diff --git a/impl/jackson/src/test/resources/listen-to-any.yaml b/impl/test/src/test/resources/listen-to-any.yaml similarity index 100% rename from impl/jackson/src/test/resources/listen-to-any.yaml rename to impl/test/src/test/resources/listen-to-any.yaml diff --git a/impl/http/src/test/resources/oAuthClientSecretPostClientCredentialsHttpCall.yaml b/impl/test/src/test/resources/oAuthClientSecretPostClientCredentialsHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthClientSecretPostClientCredentialsHttpCall.yaml rename to impl/test/src/test/resources/oAuthClientSecretPostClientCredentialsHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthClientSecretPostClientCredentialsParamsHttpCall.yaml b/impl/test/src/test/resources/oAuthClientSecretPostClientCredentialsParamsHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthClientSecretPostClientCredentialsParamsHttpCall.yaml rename to impl/test/src/test/resources/oAuthClientSecretPostClientCredentialsParamsHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml b/impl/test/src/test/resources/oAuthClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml rename to impl/test/src/test/resources/oAuthClientSecretPostClientCredentialsParamsNoEndPointHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthClientSecretPostPasswordAllGrantsHttpCall.yaml b/impl/test/src/test/resources/oAuthClientSecretPostPasswordAllGrantsHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthClientSecretPostPasswordAllGrantsHttpCall.yaml rename to impl/test/src/test/resources/oAuthClientSecretPostPasswordAllGrantsHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthClientSecretPostPasswordAsArgHttpCall.yaml b/impl/test/src/test/resources/oAuthClientSecretPostPasswordAsArgHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthClientSecretPostPasswordAsArgHttpCall.yaml rename to impl/test/src/test/resources/oAuthClientSecretPostPasswordAsArgHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthClientSecretPostPasswordHttpCall.yaml b/impl/test/src/test/resources/oAuthClientSecretPostPasswordHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthClientSecretPostPasswordHttpCall.yaml rename to impl/test/src/test/resources/oAuthClientSecretPostPasswordHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthClientSecretPostPasswordNoEndpointsHttpCall.yaml b/impl/test/src/test/resources/oAuthClientSecretPostPasswordNoEndpointsHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthClientSecretPostPasswordNoEndpointsHttpCall.yaml rename to impl/test/src/test/resources/oAuthClientSecretPostPasswordNoEndpointsHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthJSONClientCredentialsHttpCall.yaml b/impl/test/src/test/resources/oAuthJSONClientCredentialsHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthJSONClientCredentialsHttpCall.yaml rename to impl/test/src/test/resources/oAuthJSONClientCredentialsHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthJSONClientCredentialsParamsHttpCall.yaml b/impl/test/src/test/resources/oAuthJSONClientCredentialsParamsHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthJSONClientCredentialsParamsHttpCall.yaml rename to impl/test/src/test/resources/oAuthJSONClientCredentialsParamsHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthJSONClientCredentialsParamsNoEndPointHttpCall.yaml b/impl/test/src/test/resources/oAuthJSONClientCredentialsParamsNoEndPointHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthJSONClientCredentialsParamsNoEndPointHttpCall.yaml rename to impl/test/src/test/resources/oAuthJSONClientCredentialsParamsNoEndPointHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthJSONPasswordAllGrantsHttpCall.yaml b/impl/test/src/test/resources/oAuthJSONPasswordAllGrantsHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthJSONPasswordAllGrantsHttpCall.yaml rename to impl/test/src/test/resources/oAuthJSONPasswordAllGrantsHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthJSONPasswordAsArgHttpCall.yaml b/impl/test/src/test/resources/oAuthJSONPasswordAsArgHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthJSONPasswordAsArgHttpCall.yaml rename to impl/test/src/test/resources/oAuthJSONPasswordAsArgHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthJSONPasswordHttpCall.yaml b/impl/test/src/test/resources/oAuthJSONPasswordHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthJSONPasswordHttpCall.yaml rename to impl/test/src/test/resources/oAuthJSONPasswordHttpCall.yaml diff --git a/impl/http/src/test/resources/oAuthJSONPasswordNoEndpointsHttpCall.yaml b/impl/test/src/test/resources/oAuthJSONPasswordNoEndpointsHttpCall.yaml similarity index 100% rename from impl/http/src/test/resources/oAuthJSONPasswordNoEndpointsHttpCall.yaml rename to impl/test/src/test/resources/oAuthJSONPasswordNoEndpointsHttpCall.yaml diff --git a/impl/jackson/src/test/resources/raise-inline.yaml b/impl/test/src/test/resources/raise-inline.yaml similarity index 100% rename from impl/jackson/src/test/resources/raise-inline.yaml rename to impl/test/src/test/resources/raise-inline.yaml diff --git a/impl/jackson/src/test/resources/raise-reusable.yaml b/impl/test/src/test/resources/raise-reusable.yaml similarity index 100% rename from impl/jackson/src/test/resources/raise-reusable.yaml rename to impl/test/src/test/resources/raise-reusable.yaml diff --git a/impl/http/src/test/resources/schema/searchquery.yaml b/impl/test/src/test/resources/schema/searchquery.yaml similarity index 100% rename from impl/http/src/test/resources/schema/searchquery.yaml rename to impl/test/src/test/resources/schema/searchquery.yaml diff --git a/impl/jackson/src/test/resources/simple-expression.yaml b/impl/test/src/test/resources/simple-expression.yaml similarity index 100% rename from impl/jackson/src/test/resources/simple-expression.yaml rename to impl/test/src/test/resources/simple-expression.yaml diff --git a/impl/jackson/src/test/resources/switch-then-loop.yaml b/impl/test/src/test/resources/switch-then-loop.yaml similarity index 100% rename from impl/jackson/src/test/resources/switch-then-loop.yaml rename to impl/test/src/test/resources/switch-then-loop.yaml diff --git a/impl/jackson/src/test/resources/switch-then-string.yaml b/impl/test/src/test/resources/switch-then-string.yaml similarity index 100% rename from impl/jackson/src/test/resources/switch-then-string.yaml rename to impl/test/src/test/resources/switch-then-string.yaml diff --git a/impl/jackson/src/test/resources/wait-set.yaml b/impl/test/src/test/resources/wait-set.yaml similarity index 100% rename from impl/jackson/src/test/resources/wait-set.yaml rename to impl/test/src/test/resources/wait-set.yaml