diff --git a/README.md b/README.md
index 5ac8f45f..c0b4df70 100644
--- a/README.md
+++ b/README.md
@@ -3,29 +3,28 @@
# Serverless Workflow Specification - Java SDK
-Provides the Java API/SPI and Model Validation for the [Serverless Workflow Specification](https://github.com/serverlessworkflow/specification)
+Provides the Java API for the [Serverless Workflow Specification](https://github.com/serverlessworkflow/specification)
With the SDK you can:
-* Parse workflow JSON and YAML definitions
-* Programmatically build workflow definitions
-* Validate workflow definitions (both schema and workflow integrity validation)
-* Generate workflow diagram (SVG)
-* Set of utilities to help runtimes interpret the Serverless Workflow object model
+* Read workflow JSON and YAML definitions
+* Write workflow in JSON and YAML format.
-Serverless Workflow Java SDK is **not** a workflow runtime implementation but can be used by Java runtime implementations
-to parse and validate workflow definitions as well as generate the workflow diagram (SVG).
+Serverless Workflow Java SDK is **not** a workflow runtime implementation but can be used by Java runtime implementations to parse workflow definitions.
### Status
| Latest Releases | Conformance to spec version |
| :---: | :---: |
+| [7.0.0.Final](https://github.com/serverlessworkflow/sdk-java/releases/tag/7.0.0.Final) | [v1.0.0](https://github.com/serverlessworkflow/specification/tree/1.0.x) |
| [5.0.0.Final](https://github.com/serverlessworkflow/sdk-java/releases/tag/5.0.0.Final) | [v0.8](https://github.com/serverlessworkflow/specification/tree/0.8.x) |
| [4.0.5.Final](https://github.com/serverlessworkflow/sdk-java/releases/tag/4.0.5.Final) | [v0.8](https://github.com/serverlessworkflow/specification/tree/0.8.x) |
| [3.0.0.Final](https://github.com/serverlessworkflow/sdk-java/releases/tag/3.0.0.Final) | [v0.7](https://github.com/serverlessworkflow/specification/tree/0.7.x) |
| [2.0.0.Final](https://github.com/serverlessworkflow/sdk-java/releases/tag/2.0.0.Final) | [v0.6](https://github.com/serverlessworkflow/specification/tree/0.6.x) |
| [1.0.3.Final](https://github.com/serverlessworkflow/sdk-java/releases/tag/1.0.3.Final) | [v0.5](https://github.com/serverlessworkflow/specification/tree/0.5.x) |
+Note that 6.0.0.Final, which will be the one for specification version 0.9, is skipped intentionally in case someone want to work on it.
+
### JDK Version
| SDK Version | JDK Version |
@@ -35,10 +34,6 @@ to parse and validate workflow definitions as well as generate the workflow diag
### Getting Started
-#### Using the latest release
-
-See instructions how to define dependencies for the latest SDK release
-for both Maven and Gradle [here](https://github.com/serverlessworkflow/sdk-java/blob/4.0.x/README.md).
#### Building SNAPSHOT locally
@@ -54,71 +49,22 @@ Your changes should be automatically formatted during the build.
#### Maven projects:
-a) Add the following repository to your pom.xml `repositories` section:
-
-```xml
-
- oss.sonatype.org-snapshot
- http://oss.sonatype.org/content/repositories/snapshots
-
- false
-
-
- true
-
-
-```
-
-b) Add the following dependencies to your pom.xml `dependencies` section:
+Add the following dependencies to your pom.xml `dependencies` section:
```xml
io.serverlessworkflow
serverlessworkflow-api
- 5.0.0-SNAPSHOT
-
-
-
- io.serverlessworkflow
- serverlessworkflow-spi
- 5.0.0-SNAPSHOT
-
-
-
- io.serverlessworkflow
- serverlessworkflow-validation
- 5.0.0-SNAPSHOT
-
-
-
- io.serverlessworkflow
- serverlessworkflow-diagram
- 5.0.0-SNAPSHOT
-
-
-
- io.serverlessworkflow
- serverlessworkflow-util
- 5.0.0-SNAPSHOT
+ 7.0.0-SNAPSHOT
```
#### Gradle projects:
-a) Add the following repositories to your build.gradle `repositories` section:
-
-```text
-maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
-```
-
-b) Add the following dependencies to your build.gradle `dependencies` section:
+ Add the following dependencies to your build.gradle `dependencies` section:
```text
-implementation("io.serverlessworkflow:serverlessworkflow-api:5.0.0-SNAPSHOT")
-implementation("io.serverlessworkflow:serverlessworkflow-spi:5.0.0-SNAPSHOT")
-implementation("io.serverlessworkflow:serverlessworkflow-validation:5.0.0-SNAPSHOT")
-implementation("io.serverlessworkflow:serverlessworkflow-diagram:5.0.0-SNAPSHOT")
-implementation("io.serverlessworkflow:serverlessworkflow-util:5.0.0-SNAPSHOT")
+implementation("io.serverlessworkflow:serverlessworkflow-api:7.0.0-SNAPSHOT")
```
### How to Use
@@ -127,256 +73,44 @@ implementation("io.serverlessworkflow:serverlessworkflow-util:5.0.0-SNAPSHOT")
You can create a Workflow instance from JSON/YAML source:
-Let's say you have a simple YAML based workflow definition:
+Let's say you have a simple YAML based workflow definition in a file name `simple.yaml` located in your working dir:
```yaml
-id: greeting
-version: '1.0'
-name: Greeting Workflow
-start: Greet
-description: Greet Someone
-functions:
- - name: greetingFunction
- operation: file://myapis/greetingapis.json#greeting
-states:
-- name: Greet
- type: operation
- actions:
- - functionRef:
- refName: greetingFunction
- arguments:
- name: "${ .greet.name }"
- actionDataFilter:
- results: "${ .payload.greeting }"
- stateDataFilter:
- output: "${ .greeting }"
- end: true
-```
-
-To parse it and create a Workflow instance you can do:
-
-``` java
-Workflow workflow = Workflow.fromSource(source);
-```
-
-where 'source' is the above mentioned YAML definition.
-
-The fromSource static method can take in definitions in both JSON and YAML formats.
-
-Once you have the Workflow instance you can use its API to inspect it, for example:
-
-``` java
-assertNotNull(workflow);
-assertEquals("greeting", workflow.getId());
-assertEquals("Greeting Workflow", workflow.getName());
-
-assertNotNull(workflow.getFunctions());
-assertEquals(1, workflow.getFunctions().size());
-assertEquals("greetingFunction", workflow.getFunctions().get(0).getName());
-
-assertNotNull(workflow.getStates());
-assertEquals(1, workflow.getStates().size());
-assertTrue(workflow.getStates().get(0) instanceof OperationState);
-
-OperationState operationState = (OperationState) workflow.getStates().get(0);
-assertEquals("Greet", operationState.getName());
-assertEquals(DefaultState.Type.OPERATION, operationState.getType());
-...
-```
-
-#### Using builder API
-
-You can also programmatically create Workflow instances, for example:
-
-``` java
-Workflow workflow = new Workflow()
- .withId("test-workflow")
- .withName("test-workflow-name")
- .withVersion("1.0")
- .withStart(new Start().withStateName("MyDelayState"))
- .withFunctions(new Functions(Arrays.asList(
- new FunctionDefinition().withName("testFunction")
- .withOperation("testSwaggerDef#testOperationId")))
- )
- .withStates(Arrays.asList(
- new DelayState().withName("MyDelayState").withType(DELAY)
- .withTimeDelay("PT1M")
- .withEnd(
- new End().withTerminate(true)
- )
- )
- );
-```
-
-This will create a test workflow that defines an event, a function and a single Delay State.
-
-You can use the workflow instance to get its JSON/YAML definition as well:
-
-``` java
-assertNotNull(Workflow.toJson(testWorkflow));
-assertNotNull(Workflow.toYaml(testWorkflow));
-```
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: implicit-sequence
+do:
+ setRed:
+ set:
+ colors: '${ .colors + [ "red" ] }'
+ setGreen:
+ set:
+ colors: '${ .colors + [ "green" ] }'
+ setBlue:
+ set:
+ colors: '${ .colors + [ "blue" ] }'
-#### Using Workflow Validation
-
-Validation allows you to perform Json Schema validation against the JSON/YAML workflow definitions.
-Once you have a `Workflow` instance, you can also run integrity checks.
-
-You can validate a Workflow JSON/YAML definition to get validation errors:
-
-``` java
-WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
-List validationErrors = workflowValidator.setSource("WORKFLOW_MODEL_JSON/YAML").validate();
-```
-
-Where `WORKFLOW_MODEL_JSON/YAML` is the actual workflow model JSON or YAML definition.
-
-Or you can just check if it is valid (without getting specific errors):
-
-``` java
-WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
-boolean isValidWorkflow = workflowValidator.setSource("WORKFLOW_MODEL_JSON/YAML").isValid();
-```
-
-If you build your Workflow programmatically, you can validate it as well:
-
-``` java
-Workflow workflow = new Workflow()
- .withId("test-workflow")
- .withVersion("1.0")
- .withStart(new Start().withStateName("MyDelayState"))
- .withStates(Arrays.asList(
- new DelayState().withName("MyDelayState").withType(DefaultState.Type.DELAY)
- .withTimeDelay("PT1M")
- .withEnd(
- new End().withTerminate(true)
- )
- ));
-);
-
-WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
-List validationErrors = workflowValidator.setWorkflow(workflow).validate();
```
-#### Building Workflow Diagram
-
-Given a valid workflow definition (JSON/YAML) or a Workflow object you can build the workflow diagram SVG.
-The generated diagram SVG uses [PlantUML](https://plantuml.com/) state diagram visualization and can be embedded inside your
-tooling or web pages, or any SVG viewer.
-
-You can build the workflow diagram SVG with the following code:
+To parse it and create a Workflow instance you can do:
``` java
-Workflow workflow = Workflow.fromSource(source);
-
-WorkflowDiagram workflowDiagram = new WorkflowDiagramImpl();
-workflowDiagram.setWorkflow(workflow);
-String diagramSVG = workflowDiagram.getSvgDiagram();
+try (InputStream in = new FileInputStream("simple.yaml")) {
+ Workflow workflow = WorkflowReader.readWorkflow (in, WorkflowFormat.YAML);
+ // Once you have the Workflow instance you can use its API to inspect it
+}
```
-`diagramSVG` includes the diagram SVG source which you can then decide to save to a file,
-print, or process further.
-
-In case default visualization of the workflow is not sufficient you can provide custom workflow template to be
-used while generating the SVG file. Easiest is to start off from the default template and customize it to your needs.
-
-Custom template must be on the classpath in `templates/plantuml` directory and must use `.txt` extension. Next
-template is set on `WorkflowDiagram` instance as shown below.
-
-``` java
-Workflow workflow = Workflow.fromSource(source);
-
-WorkflowDiagram workflowDiagram = new WorkflowDiagramImpl();
-workflowDiagram.setWorkflow(workflow);
-workflowDiagram.setTemplate("custom-template");
-
-String diagramSVG = workflowDiagram.getSvgDiagram();
-```
+#### Writing a workflow
-By default the diagram legend is now shown. If you want to enable it you can do:
+Given a workflow definition, you can store it using JSON or YAML format.
+For example, to store a workflow using json format in a file called `simple.json`, you write
``` java
-Workflow workflow = Workflow.fromSource(source);
-
-WorkflowDiagram workflowDiagram = new WorkflowDiagramImpl();
-workflowDiagram.setWorkflow(workflow)
- .showLegend(true);
-
-String diagramSVG = workflowDiagram.getSvgDiagram();
-```
-
-Here are some generated diagrams from the specification examples (with legend enabled):
-
-1. [Job Monitoring Example](https://github.com/serverlessworkflow/specification/blob/master/examples/examples.md#Monitor-Job-Example)
-
-
-
-
-
-2. [Send CloudEvent on Workflow completion Example](https://github.com/serverlessworkflow/specification/blob/master/examples/examples.md#send-cloudevent-on-workfow-completion-example)
-
-
-
-
-#### Using Workflow Utils
-Workflow utils provide a number of useful methods for extracting information from workflow definitions.
-Once you have a `Workflow` instance, you can use it
-##### Get Starting State
-```Java
-State startingState = WorkflowUtils.getStartingState(workflow);
-```
-##### Get States by State Type
-```Java
- List states = WorkflowUtils.getStates(workflow, DefaultState.Type.EVENT);
-```
-##### Get Consumed-Events, Produced-Events and their count
-```Java
- List consumedEvents = WorkflowUtils.getWorkflowConsumedEvents(workflow);
- int consumedEventsCount = WorkflowUtils.getWorkflowConsumedEventsCount(workflow);
-
- List producedEvents = WorkflowUtils.getWorkflowProducedEvents(workflow);
- int producedEventsCount = WorkflowUtils.getWorkflowProducedEventsCount(workflow);
- ```
-##### Get Defined Consumed-Events, Defined Produced-Events and their count
-```Java
- List consumedEvents = WorkflowUtils.getWorkflowConsumedEventsCount(workflow);
- int consumedEventsCount = WorkflowUtils.getWorkflowConsumedEventsCount(workflow);
-
- List producedEvents = WorkflowUtils.getWorkflowProducedEvents(workflow);
- int producedEventsCount = WorkflowUtils.getWorkflowProducedEventsCount(workflow);
- ```
-##### Get Function definitions which is used by an action
-```Java
-FunctionDefinition finalizeApplicationFunctionDefinition =
- WorkflowUtils.getFunctionDefinitionsForAction(workflow, "finalizeApplicationAction");
-```
-##### Get Actions which uses a Function definition
-```Java
- List actionsForFunctionDefinition =
- WorkflowUtils.getActionsForFunctionDefinition(workflow, functionRefName);
-```
-
-#### Extra
-
-SDK includes extra functionalities which are not part of core modules but
-are very useful and can be used as addons to the core:
-
-##### Diagram REST
-This is a Spring Boot app which builds a rest api for diagram generation.
-It was contributed by our community member David Marques.
-
-To start using it:
-
-```
-cd diagram-rest
-mvn clean install spring-boot:run
-```
-
-Then you can get the diagram SVG for a workflow definition for example:
-
-```
-curl -X POST localhost:8090/diagram -d '{"id":"booklending","name":"Book Lending Workflow","version":"1.0","specVersion":"0.8","start":"Book Lending Request","states":[{"name":"Book Lending Request","type":"event","onEvents":[{"eventRefs":["Book Lending Request Event"]}],"transition":"Get Book Status"},{"name":"Get Book Status","type":"operation","actions":[{"functionRef":{"refName":"Get status for book","arguments":{"bookid":"${ .book.id }"}}}],"transition":"Book Status Decision"},{"name":"Book Status Decision","type":"switch","dataConditions":[{"name":"Book is on loan","condition":"${ .book.status == \"onloan\" }","transition":"Report Status To Lender"},{"name":"Check is available","condition":"${ .book.status == \"available\" }","transition":"Check Out Book"}]},{"name":"Report Status To Lender","type":"operation","actions":[{"functionRef":{"refName":"Send status to lender","arguments":{"bookid":"${ .book.id }","message":"Book ${ .book.title } is already on loan"}}}],"transition":"Wait for Lender response"},{"name":"Wait for Lender response","type":"switch","eventConditions":[{"name":"Hold Book","eventRef":"Hold Book Event","transition":"Request Hold"},{"name":"Decline Book Hold","eventRef":"Decline Hold Event","transition":"Cancel Request"}]},{"name":"Request Hold","type":"operation","actions":[{"functionRef":{"refName":"Request hold for lender","arguments":{"bookid":"${ .book.id }","lender":"${ .lender }"}}}],"transition":"Wait two weeks"},{"name":"Wait two weeks","type":"sleep","duration":"P2W","transition":"Get Book Status"},{"name":"Check Out Book","type":"operation","actions":[{"functionRef":{"refName":"Check out book with id","arguments":{"bookid":"${ .book.id }"}}},{"functionRef":{"refName":"Notify Lender for checkout","arguments":{"bookid":"${ .book.id }","lender":"${ .lender }"}}}],"end":true}],"functions":[],"events":[]}'
-```
-
+try (OutputStream out = new FileOutputStream("simple.json")) {
+ WorkflowWriter.writeWorkflow(out, workflow, WorkflowFormat.JSON);
+}
+```
\ No newline at end of file
diff --git a/api/.gitignore b/api/.gitignore
index d4dfde66..c7d1122c 100644
--- a/api/.gitignore
+++ b/api/.gitignore
@@ -28,4 +28,5 @@ target/
build/
### VS Code ###
-.vscode/
\ No newline at end of file
+.vscode/
+/.checkstyle
diff --git a/api/pom.xml b/api/pom.xml
index 9511a191..37524b37 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -17,10 +17,6 @@
org.slf4j
slf4j-api
-
- org.slf4j
- jcl-over-slf4j
-
com.fasterxml.jackson.core
jackson-core
@@ -37,6 +33,7 @@
jakarta.validation
jakarta.validation-api
+
org.junit.jupiter
@@ -53,6 +50,11 @@
junit-jupiter-params
test
+
+ org.assertj
+ assertj-core
+ test
+
org.mockito
mockito-core
@@ -77,22 +79,36 @@
org.jsonschema2pojo
jsonschema2pojo-maven-plugin
- ${basedir}/src/main/resources/schema
+ ${basedir}/src/main/resources/schema
+
+
+ yamlschema
io.serverlessworkflow.api.types
${project.build.directory}/generated-sources/src/main/java
true
true
- false
- false
+ true
+ true
false
false
true
true
+ true
true
${java.version}
true
true
+ io.serverlessworkflow.generator.UnreferencedFactory
+
+
+ io.serverlessworkflow
+ custom-generator
+ ${project.version}
+
+
diff --git a/api/src/main/java/io/serverlessworkflow/api/CallTaskDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/CallTaskDeserializer.java
new file mode 100644
index 00000000..fcfec397
--- /dev/null
+++ b/api/src/main/java/io/serverlessworkflow/api/CallTaskDeserializer.java
@@ -0,0 +1,38 @@
+/*
+ * 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.api;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import io.serverlessworkflow.api.types.CallAsyncAPI;
+import io.serverlessworkflow.api.types.CallGRPC;
+import io.serverlessworkflow.api.types.CallHTTP;
+import io.serverlessworkflow.api.types.CallOpenAPI;
+import io.serverlessworkflow.api.types.CallTask;
+import java.io.IOException;
+import java.util.List;
+
+class CallTaskDeserializer extends JsonDeserializer {
+
+ @Override
+ public CallTask deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
+ return DeserializeHelper.deserialize(
+ p,
+ CallTask.class,
+ List.of(CallHTTP.class, CallAsyncAPI.class, CallOpenAPI.class, CallGRPC.class));
+ }
+}
diff --git a/api/src/main/java/io/serverlessworkflow/api/mapper/JsonObjectMapper.java b/api/src/main/java/io/serverlessworkflow/api/CallTaskSerializer.java
similarity index 55%
rename from api/src/main/java/io/serverlessworkflow/api/mapper/JsonObjectMapper.java
rename to api/src/main/java/io/serverlessworkflow/api/CallTaskSerializer.java
index 2480beb0..18abac33 100644
--- a/api/src/main/java/io/serverlessworkflow/api/mapper/JsonObjectMapper.java
+++ b/api/src/main/java/io/serverlessworkflow/api/CallTaskSerializer.java
@@ -13,17 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.serverlessworkflow.api.mapper;
+package io.serverlessworkflow.api;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import io.serverlessworkflow.api.types.CallTask;
+import java.io.IOException;
-public class JsonObjectMapper extends BaseObjectMapper {
-
- public JsonObjectMapper() {
- this(null);
- }
-
- public JsonObjectMapper(WorkflowPropertySource context) {
- super(null, context);
+class CallTaskSerializer extends JsonSerializer {
+ @Override
+ public void serialize(CallTask value, JsonGenerator gen, SerializerProvider serializers)
+ throws IOException {
+ SerializeHelper.serialize(gen, value);
}
}
diff --git a/api/src/main/java/io/serverlessworkflow/api/DeserializeHelper.java b/api/src/main/java/io/serverlessworkflow/api/DeserializeHelper.java
new file mode 100644
index 00000000..ba35b90d
--- /dev/null
+++ b/api/src/main/java/io/serverlessworkflow/api/DeserializeHelper.java
@@ -0,0 +1,41 @@
+/*
+ * 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.api;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.TreeNode;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import java.io.IOException;
+import java.util.Collection;
+
+public class DeserializeHelper {
+
+ public static T deserialize(
+ JsonParser p, Class targetClass, Collection> unionTypes) throws IOException {
+ TreeNode node = p.readValueAsTree();
+ JsonProcessingException ex = new JsonMappingException("Problem deserializing " + targetClass);
+ for (Class> unionType : unionTypes) {
+ try {
+ Object object = p.getCodec().treeToValue(node, unionType);
+ return targetClass.getConstructor(unionType).newInstance(object);
+ } catch (IOException | ReflectiveOperationException io) {
+ ex.addSuppressed(io);
+ }
+ }
+ throw ex;
+ }
+}
diff --git a/api/src/main/java/io/serverlessworkflow/api/ObjectMapperFactory.java b/api/src/main/java/io/serverlessworkflow/api/ObjectMapperFactory.java
new file mode 100644
index 00000000..d3a9645c
--- /dev/null
+++ b/api/src/main/java/io/serverlessworkflow/api/ObjectMapperFactory.java
@@ -0,0 +1,55 @@
+/*
+ * 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.api;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
+import io.serverlessworkflow.api.types.CallTask;
+import io.serverlessworkflow.api.types.Task;
+
+class ObjectMapperFactory {
+
+ private static final ObjectMapper jsonMapper = configure(new ObjectMapper());
+
+ private static final ObjectMapper yamlMapper =
+ configure(new ObjectMapper(new YAMLFactory().enable(Feature.MINIMIZE_QUOTES)));
+
+ public static final ObjectMapper jsonMapper() {
+ return jsonMapper;
+ }
+
+ public static final ObjectMapper yamlMapper() {
+ return yamlMapper;
+ }
+
+ private static ObjectMapper configure(ObjectMapper mapper) {
+ SimpleModule simpleModule = new SimpleModule();
+ simpleModule.addDeserializer(Task.class, new TaskDeserializer());
+ simpleModule.addSerializer(Task.class, new TaskSerializer());
+ simpleModule.addDeserializer(CallTask.class, new CallTaskDeserializer());
+ simpleModule.addSerializer(CallTask.class, new CallTaskSerializer());
+ return mapper
+ .configure(SerializationFeature.INDENT_OUTPUT, true)
+ .configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false)
+ .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
+ .registerModule(simpleModule);
+ }
+
+ private ObjectMapperFactory() {}
+}
diff --git a/api/src/main/java/io/serverlessworkflow/api/SerializeHelper.java b/api/src/main/java/io/serverlessworkflow/api/SerializeHelper.java
new file mode 100644
index 00000000..e08de159
--- /dev/null
+++ b/api/src/main/java/io/serverlessworkflow/api/SerializeHelper.java
@@ -0,0 +1,36 @@
+/*
+ * 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.api;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+public class SerializeHelper {
+ public static void serialize(JsonGenerator jgen, Object item) throws IOException {
+ try {
+ for (Method m : item.getClass().getDeclaredMethods()) {
+ Object value = m.invoke(item);
+ if (value != null) {
+ jgen.writeObject(value);
+ break;
+ }
+ }
+ } catch (ReflectiveOperationException ex) {
+ throw new IOException(ex);
+ }
+ }
+}
diff --git a/api/src/main/java/io/serverlessworkflow/api/TaskDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/TaskDeserializer.java
new file mode 100644
index 00000000..d81091ca
--- /dev/null
+++ b/api/src/main/java/io/serverlessworkflow/api/TaskDeserializer.java
@@ -0,0 +1,58 @@
+/*
+ * 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.api;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import io.serverlessworkflow.api.types.CallTask;
+import io.serverlessworkflow.api.types.DoTask;
+import io.serverlessworkflow.api.types.EmitTask;
+import io.serverlessworkflow.api.types.ForTask;
+import io.serverlessworkflow.api.types.ForkTask;
+import io.serverlessworkflow.api.types.ListenTask;
+import io.serverlessworkflow.api.types.RaiseTask;
+import io.serverlessworkflow.api.types.RunTask;
+import io.serverlessworkflow.api.types.SetTask;
+import io.serverlessworkflow.api.types.SwitchTask;
+import io.serverlessworkflow.api.types.Task;
+import io.serverlessworkflow.api.types.TryTask;
+import io.serverlessworkflow.api.types.WaitTask;
+import java.io.IOException;
+import java.util.List;
+
+class TaskDeserializer extends JsonDeserializer {
+
+ @Override
+ public Task deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
+ return DeserializeHelper.deserialize(
+ p,
+ Task.class,
+ List.of(
+ CallTask.class,
+ DoTask.class,
+ SwitchTask.class,
+ TryTask.class,
+ RaiseTask.class,
+ EmitTask.class,
+ ForkTask.class,
+ ForTask.class,
+ ListenTask.class,
+ SetTask.class,
+ RunTask.class,
+ WaitTask.class));
+ }
+}
diff --git a/api/src/main/java/io/serverlessworkflow/api/mapper/JsonObjectMapperFactory.java b/api/src/main/java/io/serverlessworkflow/api/TaskSerializer.java
similarity index 56%
rename from api/src/main/java/io/serverlessworkflow/api/mapper/JsonObjectMapperFactory.java
rename to api/src/main/java/io/serverlessworkflow/api/TaskSerializer.java
index eb34b0eb..3900f16e 100644
--- a/api/src/main/java/io/serverlessworkflow/api/mapper/JsonObjectMapperFactory.java
+++ b/api/src/main/java/io/serverlessworkflow/api/TaskSerializer.java
@@ -13,15 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.serverlessworkflow.api.mapper;
+package io.serverlessworkflow.api;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import io.serverlessworkflow.api.types.Task;
+import java.io.IOException;
-public class JsonObjectMapperFactory {
+class TaskSerializer extends JsonSerializer {
- private static final ObjectMapper instance = new JsonObjectMapper();
-
- public static final ObjectMapper mapper() {
- return instance;
+ @Override
+ public void serialize(Task value, JsonGenerator gen, SerializerProvider serializers)
+ throws IOException {
+ SerializeHelper.serialize(gen, value);
}
}
diff --git a/api/src/main/java/io/serverlessworkflow/api/mapper/YamlObjectMapperFactory.java b/api/src/main/java/io/serverlessworkflow/api/WorkflowFormat.java
similarity index 54%
rename from api/src/main/java/io/serverlessworkflow/api/mapper/YamlObjectMapperFactory.java
rename to api/src/main/java/io/serverlessworkflow/api/WorkflowFormat.java
index 04371db4..d0cdfd95 100644
--- a/api/src/main/java/io/serverlessworkflow/api/mapper/YamlObjectMapperFactory.java
+++ b/api/src/main/java/io/serverlessworkflow/api/WorkflowFormat.java
@@ -13,15 +13,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.serverlessworkflow.api.mapper;
+package io.serverlessworkflow.api;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.nio.file.Path;
-public class YamlObjectMapperFactory {
+public enum WorkflowFormat {
+ JSON(ObjectMapperFactory.jsonMapper()),
+ YAML(ObjectMapperFactory.yamlMapper());
- private static final ObjectMapper instance = new YamlObjectMapper();
+ private final ObjectMapper mapper;
- public static final ObjectMapper mapper() {
- return instance;
+ public static WorkflowFormat fromPath(Path path) {
+ return fromFileName(path.getFileName().toString());
+ }
+
+ public static WorkflowFormat fromFileName(String fileName) {
+ return fileName.endsWith(".json") ? JSON : YAML;
+ }
+
+ private WorkflowFormat(ObjectMapper mapper) {
+ this.mapper = mapper;
+ }
+
+ public ObjectMapper mapper() {
+ return mapper;
}
}
diff --git a/api/src/main/java/io/serverlessworkflow/api/WorkflowReader.java b/api/src/main/java/io/serverlessworkflow/api/WorkflowReader.java
new file mode 100644
index 00000000..01c6c8b0
--- /dev/null
+++ b/api/src/main/java/io/serverlessworkflow/api/WorkflowReader.java
@@ -0,0 +1,58 @@
+/*
+ * 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.api;
+
+import io.serverlessworkflow.api.types.Workflow;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class WorkflowReader {
+
+ public static Workflow readWorkflow(InputStream input, WorkflowFormat format) throws IOException {
+ return format.mapper().readValue(input, Workflow.class);
+ }
+
+ public static Workflow readWorkflow(Reader input, WorkflowFormat format) throws IOException {
+ return format.mapper().readValue(input, Workflow.class);
+ }
+
+ public static Workflow readWorkflow(Path path, WorkflowFormat format) throws IOException {
+ return format.mapper().readValue(Files.readAllBytes(path), Workflow.class);
+ }
+
+ public static Workflow readWorkflowFromClasspath(String classpath) throws IOException {
+ return readWorkflowFromClasspath(
+ classpath,
+ Thread.currentThread().getContextClassLoader(),
+ WorkflowFormat.fromFileName(classpath));
+ }
+
+ public static Workflow readWorkflowFromClasspath(
+ String classpath, ClassLoader cl, WorkflowFormat format) throws IOException {
+ try (InputStream in = cl.getResourceAsStream(classpath)) {
+ if (in == null) {
+ throw new FileNotFoundException(classpath);
+ }
+ return readWorkflow(in, format);
+ }
+ }
+
+ private WorkflowReader() {}
+}
diff --git a/api/src/main/java/io/serverlessworkflow/api/WorkflowWriter.java b/api/src/main/java/io/serverlessworkflow/api/WorkflowWriter.java
new file mode 100644
index 00000000..f98e6402
--- /dev/null
+++ b/api/src/main/java/io/serverlessworkflow/api/WorkflowWriter.java
@@ -0,0 +1,49 @@
+/*
+ * 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.api;
+
+import io.serverlessworkflow.api.types.Workflow;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class WorkflowWriter {
+
+ public static void writeWorkflow(OutputStream output, Workflow workflow, WorkflowFormat format)
+ throws IOException {
+ format.mapper().writeValue(output, workflow);
+ }
+
+ public static void writeWorkflow(Writer output, Workflow workflow, WorkflowFormat format)
+ throws IOException {
+ format.mapper().writeValue(output, workflow);
+ }
+
+ public static void writeWorkflow(Path output, Workflow workflow) throws IOException {
+ writeWorkflow(output, workflow, WorkflowFormat.fromPath(output));
+ }
+
+ public static void writeWorkflow(Path output, Workflow workflow, WorkflowFormat format)
+ throws IOException {
+ try (OutputStream out = Files.newOutputStream(output)) {
+ writeWorkflow(out, workflow, format);
+ }
+ }
+
+ private WorkflowWriter() {}
+}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/AuthDefinitionDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/AuthDefinitionDeserializer.java
deleted file mode 100644
index 01ec3f6e..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/AuthDefinitionDeserializer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.auth.AuthDefinition;
-import io.serverlessworkflow.api.auth.BasicAuthDefinition;
-import io.serverlessworkflow.api.auth.BearerAuthDefinition;
-import io.serverlessworkflow.api.auth.OauthDefinition;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.io.IOException;
-
-public class AuthDefinitionDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public AuthDefinitionDeserializer() {
- this(AuthDefinition.class);
- }
-
- public AuthDefinitionDeserializer(Class> vc) {
- super(vc);
- }
-
- public AuthDefinitionDeserializer(WorkflowPropertySource context) {
- this(AuthDefinition.class);
- this.context = context;
- }
-
- @Override
- public AuthDefinition deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- AuthDefinition authDefinition = new AuthDefinition();
-
- if (node.get("name") != null) {
- authDefinition.setName(node.get("name").asText());
- }
-
- if (node.get("scheme") != null) {
- authDefinition.setScheme(AuthDefinition.Scheme.fromValue(node.get("scheme").asText()));
- }
-
- if (node.get("properties") != null) {
- JsonNode propsNode = node.get("properties");
-
- if (propsNode.get("grantType") != null) {
- authDefinition.setOauth(mapper.treeToValue(propsNode, OauthDefinition.class));
- } else if (propsNode.get("token") != null) {
- authDefinition.setBearerauth(mapper.treeToValue(propsNode, BearerAuthDefinition.class));
- } else {
- authDefinition.setBasicauth(mapper.treeToValue(propsNode, BasicAuthDefinition.class));
- }
- }
-
- return authDefinition;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/AuthDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/AuthDeserializer.java
deleted file mode 100644
index aa078cb4..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/AuthDeserializer.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.auth.AuthDefinition;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.utils.Utils;
-import io.serverlessworkflow.api.workflow.Auth;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AuthDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 520L;
- private static Logger logger = LoggerFactory.getLogger(AuthDeserializer.class);
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public AuthDeserializer() {
- this(Auth.class);
- }
-
- public AuthDeserializer(Class> vc) {
- super(vc);
- }
-
- public AuthDeserializer(WorkflowPropertySource context) {
- this(Auth.class);
- this.context = context;
- }
-
- @Override
- public Auth deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- Auth auth = new Auth();
- List authDefinitions = new ArrayList<>();
-
- if (node.isArray()) {
- for (final JsonNode nodeEle : node) {
- authDefinitions.add(mapper.treeToValue(nodeEle, AuthDefinition.class));
- }
- } else {
- String authFileDef = node.asText();
- String authFileSrc = Utils.getResourceFileAsString(authFileDef);
- if (authFileSrc != null && authFileSrc.trim().length() > 0) {
- JsonNode authRefNode = Utils.getNode(authFileSrc);
- JsonNode refAuth = authRefNode.get("auth");
- if (refAuth != null) {
- for (final JsonNode nodeEle : refAuth) {
- authDefinitions.add(mapper.treeToValue(nodeEle, AuthDefinition.class));
- }
- } else {
- logger.error("Unable to find auth definitions in reference file: {}", authFileSrc);
- }
-
- } else {
- logger.error("Unable to load auth defs reference file: {}", authFileSrc);
- }
- }
- auth.setAuthDefs(authDefinitions);
- return auth;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/ConstantsDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/ConstantsDeserializer.java
deleted file mode 100644
index 1d95216f..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/ConstantsDeserializer.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.utils.Utils;
-import io.serverlessworkflow.api.workflow.Constants;
-import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ConstantsDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(ConstantsDeserializer.class);
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public ConstantsDeserializer() {
- this(Constants.class);
- }
-
- public ConstantsDeserializer(Class> vc) {
- super(vc);
- }
-
- public ConstantsDeserializer(WorkflowPropertySource context) {
- this(Constants.class);
- this.context = context;
- }
-
- @Override
- public Constants deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- JsonNode node = jp.getCodec().readTree(jp);
-
- Constants constants = new Constants();
- JsonNode constantsDefinition = null;
-
- if (node.isObject()) {
- constantsDefinition = node;
- } else {
- String constantsFileDef = node.asText();
- constants.setRefValue(constantsFileDef);
- String constantsFileSrc = Utils.getResourceFileAsString(constantsFileDef);
- if (constantsFileSrc != null && constantsFileSrc.trim().length() > 0) {
- JsonNode constantsRefNode = Utils.getNode(constantsFileSrc);
- JsonNode refConstants = constantsRefNode.get("constants");
- if (refConstants != null) {
- constantsDefinition = refConstants;
- } else {
- logger.error(
- "Unable to find constants definitions in reference file: {}", constantsFileSrc);
- }
-
- } else {
- logger.error("Unable to load constants defs reference file: {}", constantsFileSrc);
- }
- }
- constants.setConstantsDef(constantsDefinition);
- return constants;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/ContinueAsDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/ContinueAsDeserializer.java
deleted file mode 100644
index accb1bd3..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/ContinueAsDeserializer.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.end.ContinueAs;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.timeouts.WorkflowExecTimeout;
-import java.io.IOException;
-
-public class ContinueAsDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public ContinueAsDeserializer() {
- this(ContinueAs.class);
- }
-
- public ContinueAsDeserializer(Class> vc) {
- super(vc);
- }
-
- public ContinueAsDeserializer(WorkflowPropertySource context) {
- this(ContinueAs.class);
- this.context = context;
- }
-
- @Override
- public ContinueAs deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- ContinueAs continueAs = new ContinueAs();
-
- if (!node.isObject()) {
- continueAs.setWorkflowId(node.asText());
- continueAs.setVersion(null);
- continueAs.setData(null);
- continueAs.setWorkflowExecTimeout(null);
- return continueAs;
- } else {
- if (node.get("workflowId") != null) {
- continueAs.setWorkflowId(node.get("workflowId").asText());
- }
-
- if (node.get("version") != null) {
- continueAs.setVersion(node.get("version").asText());
- }
-
- if (node.get("data") != null) {
- continueAs.setData(node.get("data").asText());
- }
-
- if (node.get("workflowExecTimeout") != null) {
- continueAs.setWorkflowExecTimeout(
- mapper.treeToValue(node.get("workflowExecTimeout"), WorkflowExecTimeout.class));
- }
-
- return continueAs;
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/CronDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/CronDeserializer.java
deleted file mode 100644
index 94aa2598..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/CronDeserializer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.cron.Cron;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.io.IOException;
-
-public class CronDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public CronDeserializer() {
- this(Cron.class);
- }
-
- public CronDeserializer(Class> vc) {
- super(vc);
- }
-
- public CronDeserializer(WorkflowPropertySource context) {
- this(Cron.class);
- this.context = context;
- }
-
- @Override
- public Cron deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- JsonNode node = jp.getCodec().readTree(jp);
-
- Cron cron = new Cron();
-
- if (!node.isObject()) {
- cron.setExpression(node.asText());
- return cron;
- } else {
- if (node.get("expression") != null) {
- cron.setExpression(node.get("expression").asText());
- }
-
- if (node.get("validUntil") != null) {
- cron.setValidUntil(node.get("validUntil").asText());
- }
-
- return cron;
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/DataInputSchemaDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/DataInputSchemaDeserializer.java
deleted file mode 100644
index ad711b98..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/DataInputSchemaDeserializer.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.workflow.DataInputSchema;
-import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DataInputSchemaDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(DataInputSchemaDeserializer.class);
-
- public DataInputSchemaDeserializer() {
- this(DataInputSchema.class);
- }
-
- public DataInputSchemaDeserializer(Class> vc) {
- super(vc);
- }
-
- public DataInputSchemaDeserializer(WorkflowPropertySource context) {
- this(DataInputSchema.class);
- }
-
- @Override
- public DataInputSchema deserialize(JsonParser jp, DeserializationContext ctxt)
- throws IOException {
-
- JsonNode node = jp.getCodec().readTree(jp);
-
- DataInputSchema dataInputSchema = new DataInputSchema();
- JsonNode schemaDefinition = null;
-
- if (node.isObject() && node.get("schema").isObject() && !node.get("schema").isEmpty()) {
- schemaDefinition = node.get("schema");
- dataInputSchema.setFailOnValidationErrors(node.get("failOnValidationErrors").asBoolean());
- dataInputSchema.setSchemaDef(schemaDefinition);
- } else {
- String schemaFileDef = node.isObject() ? node.get("schema").asText() : node.asText();
- dataInputSchema.setFailOnValidationErrors(true);
- dataInputSchema.setRefValue(schemaFileDef);
- }
- return dataInputSchema;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/DefaultStateTypeDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/DefaultStateTypeDeserializer.java
deleted file mode 100644
index c38a4b47..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/DefaultStateTypeDeserializer.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.states.DefaultState;
-import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DefaultStateTypeDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(DefaultStateTypeDeserializer.class);
-
- private WorkflowPropertySource context;
-
- public DefaultStateTypeDeserializer() {
- this(DefaultState.Type.class);
- }
-
- public DefaultStateTypeDeserializer(WorkflowPropertySource context) {
- this(DefaultState.Type.class);
- this.context = context;
- }
-
- public DefaultStateTypeDeserializer(Class> vc) {
- super(vc);
- }
-
- @Override
- public DefaultState.Type deserialize(JsonParser jp, DeserializationContext ctxt)
- throws IOException {
-
- String value = jp.getText();
-
- if (context != null) {
- try {
- String result = context.getPropertySource().getProperty(value);
-
- if (result != null) {
- return DefaultState.Type.fromValue(result);
- } else {
- return DefaultState.Type.fromValue(jp.getText());
- }
- } catch (Exception e) {
- logger.info("Exception trying to evaluate property: {}", e.getMessage());
- return DefaultState.Type.fromValue(jp.getText());
- }
- } else {
- return DefaultState.Type.fromValue(jp.getText());
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/EndDefinitionDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/EndDefinitionDeserializer.java
deleted file mode 100644
index 3a66816b..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/EndDefinitionDeserializer.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.end.ContinueAs;
-import io.serverlessworkflow.api.end.End;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.produce.ProduceEvent;
-import io.serverlessworkflow.api.start.Start;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class EndDefinitionDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public EndDefinitionDeserializer() {
- this(End.class);
- }
-
- public EndDefinitionDeserializer(Class> vc) {
- super(vc);
- }
-
- public EndDefinitionDeserializer(WorkflowPropertySource context) {
- this(Start.class);
- this.context = context;
- }
-
- @Override
- public End deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- End end = new End();
-
- if (node.isBoolean()) {
- end.setProduceEvents(null);
- end.setCompensate(false);
- end.setTerminate(false);
- end.setContinueAs(null);
- return node.asBoolean() ? end : null;
- } else {
- if (node.get("produceEvents") != null) {
- List produceEvents = new ArrayList<>();
- for (final JsonNode nodeEle : node.get("produceEvents")) {
- produceEvents.add(mapper.treeToValue(nodeEle, ProduceEvent.class));
- }
- end.setProduceEvents(produceEvents);
- }
-
- if (node.get("terminate") != null) {
- end.setTerminate(node.get("terminate").asBoolean());
- } else {
- end.setTerminate(false);
- }
-
- if (node.get("compensate") != null) {
- end.setCompensate(node.get("compensate").asBoolean());
- } else {
- end.setCompensate(false);
- }
-
- if (node.get("continueAs") != null) {
- end.setContinueAs(mapper.treeToValue(node.get("continueAs"), ContinueAs.class));
- }
-
- return end;
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/ErrorsDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/ErrorsDeserializer.java
deleted file mode 100644
index 6fe366ea..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/ErrorsDeserializer.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.error.ErrorDefinition;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.utils.Utils;
-import io.serverlessworkflow.api.workflow.Errors;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ErrorsDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(ErrorsDeserializer.class);
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public ErrorsDeserializer() {
- this(Errors.class);
- }
-
- public ErrorsDeserializer(Class> vc) {
- super(vc);
- }
-
- public ErrorsDeserializer(WorkflowPropertySource context) {
- this(Errors.class);
- this.context = context;
- }
-
- @Override
- public Errors deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- Errors errors = new Errors();
- List errorDefinitions = new ArrayList<>();
-
- if (node.isArray()) {
- for (final JsonNode nodeEle : node) {
- errorDefinitions.add(mapper.treeToValue(nodeEle, ErrorDefinition.class));
- }
- } else {
- String errorsFileDef = node.asText();
- String errorsFileSrc = Utils.getResourceFileAsString(errorsFileDef);
- if (errorsFileSrc != null && errorsFileSrc.trim().length() > 0) {
- JsonNode errorsRefNode = Utils.getNode(errorsFileSrc);
- JsonNode refErrors = errorsRefNode.get("errors");
- if (refErrors != null) {
- for (final JsonNode nodeEle : refErrors) {
- errorDefinitions.add(mapper.treeToValue(nodeEle, ErrorDefinition.class));
- }
- } else {
- logger.error("Unable to find error definitions in reference file: {}", errorsFileSrc);
- }
-
- } else {
- logger.error("Unable to load errors defs reference file: {}", errorsFileSrc);
- }
- }
- errors.setErrorDefs(errorDefinitions);
- return errors;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/EventDefinitionKindDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/EventDefinitionKindDeserializer.java
deleted file mode 100644
index b9ee25b3..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/EventDefinitionKindDeserializer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EventDefinitionKindDeserializer extends StdDeserializer {
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(EventDefinitionKindDeserializer.class);
-
- private WorkflowPropertySource context;
-
- public EventDefinitionKindDeserializer() {
- this(EventDefinition.Kind.class);
- }
-
- public EventDefinitionKindDeserializer(WorkflowPropertySource context) {
- this(EventDefinition.Kind.class);
- this.context = context;
- }
-
- public EventDefinitionKindDeserializer(Class> vc) {
- super(vc);
- }
-
- @Override
- public EventDefinition.Kind deserialize(JsonParser jp, DeserializationContext ctxt)
- throws IOException {
-
- String value = jp.getText();
- if (context != null) {
- try {
- String result = context.getPropertySource().getProperty(value);
-
- if (result != null) {
- return EventDefinition.Kind.fromValue(result);
- } else {
- return EventDefinition.Kind.fromValue(jp.getText());
- }
- } catch (Exception e) {
- logger.info("Exception trying to evaluate property: {}", e.getMessage());
- return EventDefinition.Kind.fromValue(jp.getText());
- }
- } else {
- return EventDefinition.Kind.fromValue(jp.getText());
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/EventsDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/EventsDeserializer.java
deleted file mode 100644
index a02fdf4b..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/EventsDeserializer.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.utils.Utils;
-import io.serverlessworkflow.api.workflow.Events;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EventsDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(EventsDeserializer.class);
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public EventsDeserializer() {
- this(Events.class);
- }
-
- public EventsDeserializer(Class> vc) {
- super(vc);
- }
-
- public EventsDeserializer(WorkflowPropertySource context) {
- this(Events.class);
- this.context = context;
- }
-
- @Override
- public Events deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- Events events = new Events();
- List eventDefs = new ArrayList<>();
-
- if (node.isArray()) {
- for (final JsonNode nodeEle : node) {
- eventDefs.add(mapper.treeToValue(nodeEle, EventDefinition.class));
- }
- } else {
- String eventsFileDef = node.asText();
- String eventsFileSrc = Utils.getResourceFileAsString(eventsFileDef);
- if (eventsFileSrc != null && eventsFileSrc.trim().length() > 0) {
- // if its a yaml def convert to json first
- JsonNode eventsRefNode = Utils.getNode(eventsFileSrc);
- JsonNode refEvents = eventsRefNode.get("events");
- if (refEvents != null) {
- for (final JsonNode nodeEle : refEvents) {
- eventDefs.add(mapper.treeToValue(nodeEle, EventDefinition.class));
- }
- } else {
- logger.error("Unable to find event definitions in reference file: {}", eventsFileSrc);
- }
-
- } else {
- logger.error("Unable to load event defs reference file: {}", eventsFileSrc);
- }
- }
- events.setEventDefs(eventDefs);
- return events;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/ExtensionDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/ExtensionDeserializer.java
deleted file mode 100644
index c5c6be21..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/ExtensionDeserializer.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.Extension;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ExtensionDeserializer extends StdDeserializer {
-
- private WorkflowPropertySource context;
- private Map> extensionsMap = new HashMap<>();
- private static Logger logger = LoggerFactory.getLogger(ExtensionDeserializer.class);
-
- public ExtensionDeserializer() {
- this(Extension.class);
- }
-
- public ExtensionDeserializer(Class> vc) {
- super(vc);
- }
-
- public ExtensionDeserializer(WorkflowPropertySource context) {
- this(Extension.class);
- this.context = context;
- }
-
- public void addExtension(String extensionId, Class extends Extension> extensionClass) {
- this.extensionsMap.put(extensionId, extensionClass);
- }
-
- @Override
- public Extension deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- String extensionId = node.get("extensionId").asText();
-
- if (context != null) {
- try {
- String result = context.getPropertySource().getProperty(extensionId);
-
- if (result != null) {
- extensionId = result;
- }
- } catch (Exception e) {
- logger.info("Exception trying to evaluate property: {}", e.getMessage());
- }
- }
-
- // based on the name return the specific extension impl
- if (extensionsMap != null && extensionsMap.containsKey(extensionId)) {
- return mapper.treeToValue(node, extensionsMap.get(extensionId));
- } else {
- throw new IllegalArgumentException("Extension handler not registered for: " + extensionId);
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/FunctionDefinitionTypeDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/FunctionDefinitionTypeDeserializer.java
deleted file mode 100644
index e8cd54a3..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/FunctionDefinitionTypeDeserializer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FunctionDefinitionTypeDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(FunctionDefinitionTypeDeserializer.class);
-
- private WorkflowPropertySource context;
-
- public FunctionDefinitionTypeDeserializer() {
- this(FunctionDefinition.Type.class);
- }
-
- public FunctionDefinitionTypeDeserializer(WorkflowPropertySource context) {
- this(FunctionDefinition.Type.class);
- this.context = context;
- }
-
- public FunctionDefinitionTypeDeserializer(Class> vc) {
- super(vc);
- }
-
- @Override
- public FunctionDefinition.Type deserialize(JsonParser jp, DeserializationContext ctxt)
- throws IOException {
-
- String value = jp.getText();
- if (context != null) {
- try {
- String result = context.getPropertySource().getProperty(value);
-
- if (result != null) {
- return FunctionDefinition.Type.fromValue(result);
- } else {
- return FunctionDefinition.Type.fromValue(jp.getText());
- }
- } catch (Exception e) {
- logger.info("Exception trying to evaluate property: {}", e.getMessage());
- return FunctionDefinition.Type.fromValue(jp.getText());
- }
- } else {
- return FunctionDefinition.Type.fromValue(jp.getText());
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/FunctionRefDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/FunctionRefDeserializer.java
deleted file mode 100644
index 8204b7bc..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/FunctionRefDeserializer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.functions.FunctionRef;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.io.IOException;
-
-public class FunctionRefDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public FunctionRefDeserializer() {
- this(FunctionRef.class);
- }
-
- public FunctionRefDeserializer(Class> vc) {
- super(vc);
- }
-
- public FunctionRefDeserializer(WorkflowPropertySource context) {
- this(FunctionRef.class);
- this.context = context;
- }
-
- @Override
- public FunctionRef deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- FunctionRef functionRef = new FunctionRef();
-
- if (!node.isObject()) {
- functionRef.setRefName(node.asText());
- functionRef.setArguments(null);
- functionRef.setInvoke(FunctionRef.Invoke.SYNC);
- return functionRef;
- } else {
- if (node.get("arguments") != null) {
- functionRef.setArguments(mapper.treeToValue(node.get("arguments"), JsonNode.class));
- }
-
- if (node.get("refName") != null) {
- functionRef.setRefName(node.get("refName").asText());
- }
-
- if (node.get("selectionSet") != null) {
- functionRef.setSelectionSet(node.get("selectionSet").asText());
- }
-
- if (node.get("invoke") != null) {
- functionRef.setInvoke(FunctionRef.Invoke.fromValue(node.get("invoke").asText()));
- }
-
- return functionRef;
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/FunctionsDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/FunctionsDeserializer.java
deleted file mode 100644
index b706b2d3..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/FunctionsDeserializer.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.utils.Utils;
-import io.serverlessworkflow.api.workflow.Functions;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FunctionsDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(FunctionsDeserializer.class);
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public FunctionsDeserializer() {
- this(Functions.class);
- }
-
- public FunctionsDeserializer(Class> vc) {
- super(vc);
- }
-
- public FunctionsDeserializer(WorkflowPropertySource context) {
- this(Functions.class);
- this.context = context;
- }
-
- @Override
- public Functions deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- Functions functions = new Functions();
- List functionDefs = new ArrayList<>();
- if (node.isArray()) {
- for (final JsonNode nodeEle : node) {
- functionDefs.add(mapper.treeToValue(nodeEle, FunctionDefinition.class));
- }
- } else {
- String functionsFileDef = node.asText();
- String functionsFileSrc = Utils.getResourceFileAsString(functionsFileDef);
- JsonNode functionsRefNode;
- if (functionsFileSrc != null && functionsFileSrc.trim().length() > 0) {
- // if its a yaml def convert to json first
- functionsRefNode = Utils.getNode(functionsFileSrc);
- JsonNode refFunctions = functionsRefNode.get("functions");
- if (refFunctions != null) {
- for (final JsonNode nodeEle : refFunctions) {
- functionDefs.add(mapper.treeToValue(nodeEle, FunctionDefinition.class));
- }
- } else {
- logger.error(
- "Unable to find function definitions in reference file: {}", functionsFileSrc);
- }
-
- } else {
- logger.error("Unable to load function defs reference file: {}", functionsFileSrc);
- }
- }
- functions.setFunctionDefs(functionDefs);
- return functions;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/OnEventsActionModeDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/OnEventsActionModeDeserializer.java
deleted file mode 100644
index f98b8a23..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/OnEventsActionModeDeserializer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.events.OnEvents;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class OnEventsActionModeDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(OnEventsActionModeDeserializer.class);
-
- private WorkflowPropertySource context;
-
- public OnEventsActionModeDeserializer() {
- this(OnEvents.ActionMode.class);
- }
-
- public OnEventsActionModeDeserializer(WorkflowPropertySource context) {
- this(OnEvents.ActionMode.class);
- this.context = context;
- }
-
- public OnEventsActionModeDeserializer(Class> vc) {
- super(vc);
- }
-
- @Override
- public OnEvents.ActionMode deserialize(JsonParser jp, DeserializationContext ctxt)
- throws IOException {
-
- String value = jp.getText();
- if (context != null) {
- try {
- String result = context.getPropertySource().getProperty(value);
-
- if (result != null) {
- return OnEvents.ActionMode.fromValue(result);
- } else {
- return OnEvents.ActionMode.fromValue(jp.getText());
- }
- } catch (Exception e) {
- logger.info("Exception trying to evaluate property: {}", e.getMessage());
- return OnEvents.ActionMode.fromValue(jp.getText());
- }
- } else {
- return OnEvents.ActionMode.fromValue(jp.getText());
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/OperationStateActionModeDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/OperationStateActionModeDeserializer.java
deleted file mode 100644
index ffad4ea0..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/OperationStateActionModeDeserializer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.states.OperationState;
-import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class OperationStateActionModeDeserializer
- extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger =
- LoggerFactory.getLogger(OperationStateActionModeDeserializer.class);
-
- private WorkflowPropertySource context;
-
- public OperationStateActionModeDeserializer() {
- this(OperationState.ActionMode.class);
- }
-
- public OperationStateActionModeDeserializer(WorkflowPropertySource context) {
- this(OperationState.ActionMode.class);
- this.context = context;
- }
-
- public OperationStateActionModeDeserializer(Class> vc) {
- super(vc);
- }
-
- @Override
- public OperationState.ActionMode deserialize(JsonParser jp, DeserializationContext ctxt)
- throws IOException {
-
- String value = jp.getText();
- if (context != null) {
- try {
- String result = context.getPropertySource().getProperty(value);
-
- if (result != null) {
- return OperationState.ActionMode.fromValue(result);
- } else {
- return OperationState.ActionMode.fromValue(jp.getText());
- }
- } catch (Exception e) {
- logger.info("Exception trying to evaluate property: {}", e.getMessage());
- return OperationState.ActionMode.fromValue(jp.getText());
- }
- } else {
- return OperationState.ActionMode.fromValue(jp.getText());
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/ParallelStateCompletionTypeDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/ParallelStateCompletionTypeDeserializer.java
deleted file mode 100644
index 281fd486..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/ParallelStateCompletionTypeDeserializer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.states.ParallelState;
-import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ParallelStateCompletionTypeDeserializer
- extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger =
- LoggerFactory.getLogger(ParallelStateCompletionTypeDeserializer.class);
-
- private WorkflowPropertySource context;
-
- public ParallelStateCompletionTypeDeserializer() {
- this(ParallelState.CompletionType.class);
- }
-
- public ParallelStateCompletionTypeDeserializer(WorkflowPropertySource context) {
- this(ParallelState.CompletionType.class);
- this.context = context;
- }
-
- public ParallelStateCompletionTypeDeserializer(Class> vc) {
- super(vc);
- }
-
- @Override
- public ParallelState.CompletionType deserialize(JsonParser jp, DeserializationContext ctxt)
- throws IOException {
-
- String value = jp.getText();
- if (context != null) {
- try {
- String result = context.getPropertySource().getProperty(value);
-
- if (result != null) {
- return ParallelState.CompletionType.fromValue(result);
- } else {
- return ParallelState.CompletionType.fromValue(jp.getText());
- }
- } catch (Exception e) {
- logger.info("Exception trying to evaluate property: {}", e.getMessage());
- return ParallelState.CompletionType.fromValue(jp.getText());
- }
- } else {
- return ParallelState.CompletionType.fromValue(jp.getText());
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/RetriesDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/RetriesDeserializer.java
deleted file mode 100644
index 9eb47b5f..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/RetriesDeserializer.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.retry.RetryDefinition;
-import io.serverlessworkflow.api.utils.Utils;
-import io.serverlessworkflow.api.workflow.Retries;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RetriesDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(RetriesDeserializer.class);
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public RetriesDeserializer() {
- this(Retries.class);
- }
-
- public RetriesDeserializer(Class> vc) {
- super(vc);
- }
-
- public RetriesDeserializer(WorkflowPropertySource context) {
- this(Retries.class);
- this.context = context;
- }
-
- @Override
- public Retries deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- Retries retries = new Retries();
- List retryDefinitions = new ArrayList<>();
-
- if (node.isArray()) {
- for (final JsonNode nodeEle : node) {
- retryDefinitions.add(mapper.treeToValue(nodeEle, RetryDefinition.class));
- }
- } else {
- String retriesFileDef = node.asText();
- String retriesFileSrc = Utils.getResourceFileAsString(retriesFileDef);
- if (retriesFileSrc != null && retriesFileSrc.trim().length() > 0) {
- JsonNode retriesRefNode = Utils.getNode(retriesFileSrc);
- JsonNode refRetries = retriesRefNode.get("retries");
- if (refRetries != null) {
- for (final JsonNode nodeEle : refRetries) {
- retryDefinitions.add(mapper.treeToValue(nodeEle, RetryDefinition.class));
- }
- } else {
- logger.error("Unable to find retries definitions in reference file: {}", retriesFileSrc);
- }
-
- } else {
- logger.error("Unable to load retries defs reference file: {}", retriesFileSrc);
- }
- }
- retries.setRetryDefs(retryDefinitions);
- return retries;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/ScheduleDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/ScheduleDeserializer.java
deleted file mode 100644
index b6bc5359..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/ScheduleDeserializer.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.cron.Cron;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.schedule.Schedule;
-import java.io.IOException;
-
-public class ScheduleDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public ScheduleDeserializer() {
- this(Schedule.class);
- }
-
- public ScheduleDeserializer(Class> vc) {
- super(vc);
- }
-
- public ScheduleDeserializer(WorkflowPropertySource context) {
- this(Schedule.class);
- this.context = context;
- }
-
- @Override
- public Schedule deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- Schedule schedule = new Schedule();
-
- if (!node.isObject()) {
- schedule.setInterval(node.asText());
- return schedule;
- } else {
- if (node.get("interval") != null) {
- schedule.setInterval(node.get("interval").asText());
- }
-
- if (node.get("cron") != null) {
- schedule.setCron(mapper.treeToValue(node.get("cron"), Cron.class));
- }
-
- if (node.get("timezone") != null) {
- schedule.setTimezone(node.get("timezone").asText());
- }
-
- return schedule;
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/SecretsDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/SecretsDeserializer.java
deleted file mode 100644
index 60cc2a82..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/SecretsDeserializer.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.utils.Utils;
-import io.serverlessworkflow.api.workflow.Secrets;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SecretsDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(SecretsDeserializer.class);
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public SecretsDeserializer() {
- this(Secrets.class);
- }
-
- public SecretsDeserializer(Class> vc) {
- super(vc);
- }
-
- public SecretsDeserializer(WorkflowPropertySource context) {
- this(Secrets.class);
- this.context = context;
- }
-
- @Override
- public Secrets deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
- JsonNode node = jp.getCodec().readTree(jp);
-
- Secrets secrets = new Secrets();
- List secretsDefinitions = new ArrayList<>();
-
- if (node.isArray()) {
- for (final JsonNode nodeEle : node) {
- secretsDefinitions.add(nodeEle.asText());
- }
- } else {
- String secretsFileDef = node.asText();
- String secretsFileSrc = Utils.getResourceFileAsString(secretsFileDef);
- if (secretsFileSrc != null && secretsFileSrc.trim().length() > 0) {
- // if its a yaml def convert to json first
- JsonNode secretsRefNode = Utils.getNode(secretsFileSrc);
- JsonNode refSecrets = secretsRefNode.get("secrets");
- if (refSecrets != null) {
- for (final JsonNode nodeEle : refSecrets) {
- secretsDefinitions.add(nodeEle.asText());
- }
- } else {
- logger.error("Unable to find secrets definitions in reference file: {}", secretsFileSrc);
- }
-
- } else {
- logger.error("Unable to load secrets defs reference file: {}", secretsFileSrc);
- }
- }
- secrets.setSecretDefs(secretsDefinitions);
- return secrets;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/StartDefinitionDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/StartDefinitionDeserializer.java
deleted file mode 100644
index e709a079..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/StartDefinitionDeserializer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.schedule.Schedule;
-import io.serverlessworkflow.api.start.Start;
-import java.io.IOException;
-
-public class StartDefinitionDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public StartDefinitionDeserializer() {
- this(Start.class);
- }
-
- public StartDefinitionDeserializer(Class> vc) {
- super(vc);
- }
-
- public StartDefinitionDeserializer(WorkflowPropertySource context) {
- this(Start.class);
- this.context = context;
- }
-
- @Override
- public Start deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- Start start = new Start();
-
- if (!node.isObject()) {
- start.setStateName(node.asText());
- start.setSchedule(null);
- return start;
- } else {
- if (node.get("stateName") != null) {
- start.setStateName(node.get("stateName").asText());
- }
-
- if (node.get("schedule") != null) {
- start.setSchedule(mapper.treeToValue(node.get("schedule"), Schedule.class));
- }
-
- return start;
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/StateDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/StateDeserializer.java
deleted file mode 100644
index 25672c76..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/StateDeserializer.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.states.*;
-import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class StateDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(StateDeserializer.class);
-
- private WorkflowPropertySource context;
-
- public StateDeserializer() {
- this(State.class);
- }
-
- public StateDeserializer(Class> vc) {
- super(vc);
- }
-
- public StateDeserializer(WorkflowPropertySource context) {
- this(State.class);
- this.context = context;
- }
-
- @Override
- public State deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
- String typeValue = node.get("type").asText();
-
- if (context != null) {
- try {
- String result = context.getPropertySource().getProperty(typeValue);
-
- if (result != null) {
- typeValue = result;
- }
- } catch (Exception e) {
- logger.info("Exception trying to evaluate property: {}", e.getMessage());
- }
- }
-
- // based on statetype return the specific state impl
- DefaultState.Type type = DefaultState.Type.fromValue(typeValue);
- switch (type) {
- case EVENT:
- return mapper.treeToValue(node, EventState.class);
- case OPERATION:
- return mapper.treeToValue(node, OperationState.class);
- case SWITCH:
- return mapper.treeToValue(node, SwitchState.class);
- case SLEEP:
- return mapper.treeToValue(node, SleepState.class);
- case PARALLEL:
- return mapper.treeToValue(node, ParallelState.class);
-
- case INJECT:
- return mapper.treeToValue(node, InjectState.class);
-
- case FOREACH:
- return mapper.treeToValue(node, ForEachState.class);
-
- case CALLBACK:
- return mapper.treeToValue(node, CallbackState.class);
- default:
- return mapper.treeToValue(node, DefaultState.class);
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/StateExecTimeoutDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/StateExecTimeoutDeserializer.java
deleted file mode 100644
index 18a73550..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/StateExecTimeoutDeserializer.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.timeouts.StateExecTimeout;
-import java.io.IOException;
-
-public class StateExecTimeoutDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public StateExecTimeoutDeserializer() {
- this(StateExecTimeout.class);
- }
-
- public StateExecTimeoutDeserializer(Class> vc) {
- super(vc);
- }
-
- public StateExecTimeoutDeserializer(WorkflowPropertySource context) {
- this(StateExecTimeout.class);
- this.context = context;
- }
-
- @Override
- public StateExecTimeout deserialize(JsonParser jp, DeserializationContext ctxt)
- throws IOException {
-
- JsonNode node = jp.getCodec().readTree(jp);
-
- StateExecTimeout stateExecTimeout = new StateExecTimeout();
-
- if (!node.isObject()) {
- stateExecTimeout.setTotal(node.asText());
- stateExecTimeout.setSingle(null);
- return stateExecTimeout;
- } else {
- if (node.get("single") != null) {
- stateExecTimeout.setSingle(node.get("single").asText());
- }
-
- if (node.get("total") != null) {
- stateExecTimeout.setTotal(node.get("total").asText());
- }
-
- return stateExecTimeout;
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/StringValueDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/StringValueDeserializer.java
deleted file mode 100644
index 7704cdf2..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/StringValueDeserializer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class StringValueDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
- private static Logger logger = LoggerFactory.getLogger(StringValueDeserializer.class);
-
- private WorkflowPropertySource context;
-
- public StringValueDeserializer() {
- this(String.class);
- }
-
- public StringValueDeserializer(WorkflowPropertySource context) {
- this(String.class);
- this.context = context;
- }
-
- public StringValueDeserializer(Class> vc) {
- super(vc);
- }
-
- @Override
- public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- String value = jp.getText();
- if (context != null) {
- try {
- String result = context.getPropertySource().getProperty(value);
-
- if (result != null) {
- return result;
- } else {
- return jp.getText();
- }
- } catch (Exception e) {
- logger.info("Exception trying to evaluate property: {}", e.getMessage());
- return jp.getText();
- }
- } else {
- return jp.getText();
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/SubFlowRefDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/SubFlowRefDeserializer.java
deleted file mode 100644
index 53e45969..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/SubFlowRefDeserializer.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.functions.SubFlowRef;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.io.IOException;
-
-public class SubFlowRefDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public SubFlowRefDeserializer() {
- this(SubFlowRef.class);
- }
-
- public SubFlowRefDeserializer(Class> vc) {
- super(vc);
- }
-
- public SubFlowRefDeserializer(WorkflowPropertySource context) {
- this(SubFlowRef.class);
- this.context = context;
- }
-
- @Override
- public SubFlowRef deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- JsonNode node = jp.getCodec().readTree(jp);
-
- SubFlowRef subflowRef = new SubFlowRef();
-
- if (!node.isObject()) {
- subflowRef.setWorkflowId(node.asText());
- return subflowRef;
- } else {
- if (node.get("workflowId") != null) {
- subflowRef.setWorkflowId(node.get("workflowId").asText());
- }
-
- if (node.get("version") != null) {
- subflowRef.setVersion(node.get("version").asText());
- }
-
- if (node.get("onParentComplete") != null) {
- subflowRef.setOnParentComplete(
- SubFlowRef.OnParentComplete.fromValue(node.get("onParentComplete").asText()));
- }
-
- if (node.get("invoke") != null) {
- subflowRef.setInvoke(SubFlowRef.Invoke.fromValue(node.get("invoke").asText()));
- }
-
- return subflowRef;
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/deserializers/TransitionDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/deserializers/TransitionDeserializer.java
deleted file mode 100644
index 43441434..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/deserializers/TransitionDeserializer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.api.deserializers;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.produce.ProduceEvent;
-import io.serverlessworkflow.api.transitions.Transition;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-public class TransitionDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 510l;
-
- @SuppressWarnings("unused")
- private WorkflowPropertySource context;
-
- public TransitionDeserializer() {
- this(Transition.class);
- }
-
- public TransitionDeserializer(Class> vc) {
- super(vc);
- }
-
- public TransitionDeserializer(WorkflowPropertySource context) {
- this(Transition.class);
- this.context = context;
- }
-
- @Override
- public Transition deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
-
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- JsonNode node = jp.getCodec().readTree(jp);
-
- Transition transition = new Transition();
-
- if (!node.isObject()) {
- transition.setProduceEvents(new ArrayList<>());
- transition.setCompensate(false);
- transition.setNextState(node.asText());
- return transition;
- } else {
- if (node.get("produceEvents") != null) {
- transition.setProduceEvents(
- Arrays.asList(mapper.treeToValue(node.get("produceEvents"), ProduceEvent[].class)));
- }
-
- if (node.get("nextState") != null) {
- transition.setNextState(node.get("nextState").asText());
- }
-
- if (node.get("compensate") != null) {
- transition.setCompensate(node.get("compensate").asBoolean());
- }
-
- return transition;
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/interfaces/Extension.java b/api/src/main/java/io/serverlessworkflow/api/interfaces/Extension.java
deleted file mode 100644
index cb0461f7..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/interfaces/Extension.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.api.interfaces;
-
-public interface Extension {
- String getExtensionId();
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/interfaces/State.java b/api/src/main/java/io/serverlessworkflow/api/interfaces/State.java
deleted file mode 100644
index cdeea8e1..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/interfaces/State.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.api.interfaces;
-
-import io.serverlessworkflow.api.end.End;
-import io.serverlessworkflow.api.error.Error;
-import io.serverlessworkflow.api.filters.StateDataFilter;
-import io.serverlessworkflow.api.states.DefaultState.Type;
-import io.serverlessworkflow.api.timeouts.TimeoutsDefinition;
-import io.serverlessworkflow.api.transitions.Transition;
-import java.util.List;
-import java.util.Map;
-
-public interface State {
-
- String getId();
-
- String getName();
-
- Type getType();
-
- End getEnd();
-
- StateDataFilter getStateDataFilter();
-
- Transition getTransition();
-
- List getOnErrors();
-
- String getCompensatedBy();
-
- Map getMetadata();
-
- TimeoutsDefinition getTimeouts();
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/interfaces/SwitchCondition.java b/api/src/main/java/io/serverlessworkflow/api/interfaces/SwitchCondition.java
deleted file mode 100644
index 4a4368de..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/interfaces/SwitchCondition.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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.api.interfaces;
-
-public interface SwitchCondition {}
diff --git a/api/src/main/java/io/serverlessworkflow/api/interfaces/WorkflowDiagram.java b/api/src/main/java/io/serverlessworkflow/api/interfaces/WorkflowDiagram.java
deleted file mode 100644
index 0c62d4d2..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/interfaces/WorkflowDiagram.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.api.interfaces;
-
-import io.serverlessworkflow.api.Workflow;
-
-public interface WorkflowDiagram {
- WorkflowDiagram setWorkflow(Workflow workflow);
-
- WorkflowDiagram setSource(String source);
-
- WorkflowDiagram setTemplate(String template);
-
- String getSvgDiagram() throws Exception;
-
- WorkflowDiagram showLegend(boolean showLegend);
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/interfaces/WorkflowPropertySource.java b/api/src/main/java/io/serverlessworkflow/api/interfaces/WorkflowPropertySource.java
deleted file mode 100644
index 73b35ac9..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/interfaces/WorkflowPropertySource.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.api.interfaces;
-
-import java.util.Properties;
-
-public interface WorkflowPropertySource {
-
- Properties getPropertySource();
-
- void setPropertySource(Properties source);
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/interfaces/WorkflowValidator.java b/api/src/main/java/io/serverlessworkflow/api/interfaces/WorkflowValidator.java
deleted file mode 100644
index 199a0927..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/interfaces/WorkflowValidator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.api.interfaces;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.validation.ValidationError;
-import java.util.List;
-
-public interface WorkflowValidator {
-
- WorkflowValidator setWorkflow(Workflow workflow);
-
- WorkflowValidator setSource(String source);
-
- List validate();
-
- boolean isValid();
-
- WorkflowValidator setSchemaValidationEnabled(boolean schemaValidationEnabled);
-
- WorkflowValidator reset();
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/mapper/BaseObjectMapper.java b/api/src/main/java/io/serverlessworkflow/api/mapper/BaseObjectMapper.java
deleted file mode 100644
index 2f71947d..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/mapper/BaseObjectMapper.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.api.mapper;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.util.Map;
-
-public class BaseObjectMapper extends ObjectMapper {
-
- private WorkflowModule workflowModule;
-
- public BaseObjectMapper(JsonFactory factory, WorkflowPropertySource workflowPropertySource) {
- super(factory);
-
- workflowModule = new WorkflowModule(workflowPropertySource);
-
- configure(SerializationFeature.INDENT_OUTPUT, true);
- registerModule(workflowModule);
- configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
- configOverride(Map.class)
- .setInclude(
- JsonInclude.Value.construct(
- JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL));
- }
-
- public WorkflowModule getWorkflowModule() {
- return workflowModule;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/mapper/WorkflowModule.java b/api/src/main/java/io/serverlessworkflow/api/mapper/WorkflowModule.java
deleted file mode 100644
index 10c12992..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/mapper/WorkflowModule.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.api.mapper;
-
-import com.fasterxml.jackson.databind.module.SimpleModule;
-import io.serverlessworkflow.api.auth.AuthDefinition;
-import io.serverlessworkflow.api.cron.Cron;
-import io.serverlessworkflow.api.deserializers.*;
-import io.serverlessworkflow.api.end.ContinueAs;
-import io.serverlessworkflow.api.end.End;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.api.events.OnEvents;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.api.functions.FunctionRef;
-import io.serverlessworkflow.api.functions.SubFlowRef;
-import io.serverlessworkflow.api.interfaces.Extension;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.schedule.Schedule;
-import io.serverlessworkflow.api.serializers.*;
-import io.serverlessworkflow.api.start.Start;
-import io.serverlessworkflow.api.states.DefaultState;
-import io.serverlessworkflow.api.states.OperationState;
-import io.serverlessworkflow.api.states.ParallelState;
-import io.serverlessworkflow.api.timeouts.StateExecTimeout;
-import io.serverlessworkflow.api.transitions.Transition;
-import io.serverlessworkflow.api.workflow.*;
-
-public class WorkflowModule extends SimpleModule {
-
- private static final long serialVersionUID = 510l;
-
- private WorkflowPropertySource workflowPropertySource;
- private ExtensionSerializer extensionSerializer;
- private ExtensionDeserializer extensionDeserializer;
-
- public WorkflowModule() {
- this(null);
- }
-
- public WorkflowModule(WorkflowPropertySource workflowPropertySource) {
- super("workflow-module");
- this.workflowPropertySource = workflowPropertySource;
- extensionSerializer = new ExtensionSerializer();
- extensionDeserializer = new ExtensionDeserializer(workflowPropertySource);
- addDefaultSerializers();
- addDefaultDeserializers();
- }
-
- private void addDefaultSerializers() {
- addSerializer(new WorkflowSerializer());
- addSerializer(new EventStateSerializer());
- addSerializer(new SleepStateSerializer());
- addSerializer(new OperationStateSerializer());
- addSerializer(new ParallelStateSerializer());
- addSerializer(new SwitchStateSerializer());
- addSerializer(new InjectStateSerializer());
- addSerializer(new ForEachStateSerializer());
- addSerializer(new CallbackStateSerializer());
- addSerializer(new StartDefinitionSerializer());
- addSerializer(new EndDefinitionSerializer());
- addSerializer(new TransitionSerializer());
- addSerializer(new FunctionRefSerializer());
- addSerializer(new CronSerializer());
- addSerializer(new ScheduleSerializer());
- addSerializer(new SubFlowRefSerializer());
- addSerializer(new AuthDefinitionSerializer());
- addSerializer(new StateExecTimeoutSerializer());
- addSerializer(new ContinueAsSerializer());
- addSerializer(extensionSerializer);
- }
-
- private void addDefaultDeserializers() {
- addDeserializer(State.class, new StateDeserializer(workflowPropertySource));
- addDeserializer(String.class, new StringValueDeserializer(workflowPropertySource));
- addDeserializer(
- OnEvents.ActionMode.class, new OnEventsActionModeDeserializer(workflowPropertySource));
- addDeserializer(
- OperationState.ActionMode.class,
- new OperationStateActionModeDeserializer(workflowPropertySource));
- addDeserializer(
- DefaultState.Type.class, new DefaultStateTypeDeserializer(workflowPropertySource));
- addDeserializer(
- EventDefinition.Kind.class, new EventDefinitionKindDeserializer(workflowPropertySource));
- addDeserializer(
- ParallelState.CompletionType.class,
- new ParallelStateCompletionTypeDeserializer(workflowPropertySource));
- addDeserializer(Retries.class, new RetriesDeserializer(workflowPropertySource));
- addDeserializer(Secrets.class, new SecretsDeserializer(workflowPropertySource));
- addDeserializer(Constants.class, new ConstantsDeserializer(workflowPropertySource));
- addDeserializer(Functions.class, new FunctionsDeserializer(workflowPropertySource));
- addDeserializer(Events.class, new EventsDeserializer(workflowPropertySource));
- addDeserializer(Start.class, new StartDefinitionDeserializer(workflowPropertySource));
- addDeserializer(End.class, new EndDefinitionDeserializer(workflowPropertySource));
- addDeserializer(Extension.class, extensionDeserializer);
- addDeserializer(
- FunctionDefinition.Type.class,
- new FunctionDefinitionTypeDeserializer(workflowPropertySource));
- addDeserializer(Transition.class, new TransitionDeserializer(workflowPropertySource));
- addDeserializer(FunctionRef.class, new FunctionRefDeserializer(workflowPropertySource));
- addDeserializer(SubFlowRef.class, new SubFlowRefDeserializer(workflowPropertySource));
- addDeserializer(Cron.class, new CronDeserializer(workflowPropertySource));
- addDeserializer(Schedule.class, new ScheduleDeserializer(workflowPropertySource));
- addDeserializer(DataInputSchema.class, new DataInputSchemaDeserializer(workflowPropertySource));
- addDeserializer(AuthDefinition.class, new AuthDefinitionDeserializer(workflowPropertySource));
- addDeserializer(
- StateExecTimeout.class, new StateExecTimeoutDeserializer(workflowPropertySource));
- addDeserializer(Errors.class, new ErrorsDeserializer(workflowPropertySource));
- addDeserializer(ContinueAs.class, new ContinueAsDeserializer(workflowPropertySource));
- addDeserializer(Auth.class, new AuthDeserializer(workflowPropertySource));
- }
-
- public ExtensionSerializer getExtensionSerializer() {
- return extensionSerializer;
- }
-
- public ExtensionDeserializer getExtensionDeserializer() {
- return extensionDeserializer;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/AuthDefinitionSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/AuthDefinitionSerializer.java
deleted file mode 100644
index 827ff075..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/AuthDefinitionSerializer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.auth.AuthDefinition;
-import java.io.IOException;
-
-public class AuthDefinitionSerializer extends StdSerializer {
-
- public AuthDefinitionSerializer() {
- this(AuthDefinition.class);
- }
-
- protected AuthDefinitionSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(
- AuthDefinition authDefinition, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- gen.writeStartObject();
- if (authDefinition != null) {
- if (authDefinition.getName() != null && !authDefinition.getName().isEmpty()) {
- gen.writeStringField("name", authDefinition.getName());
- }
-
- if (authDefinition.getScheme() != null) {
- gen.writeStringField("scheme", authDefinition.getScheme().value());
- }
-
- if (authDefinition.getBasicauth() != null
- || authDefinition.getBearerauth() != null
- || authDefinition.getOauth() != null) {
-
- if (authDefinition.getBasicauth() != null) {
- gen.writeObjectField("properties", authDefinition.getBasicauth());
- }
-
- if (authDefinition.getBearerauth() != null) {
- gen.writeObjectField("properties", authDefinition.getBearerauth());
- }
-
- if (authDefinition.getOauth() != null) {
- gen.writeObjectField("properties", authDefinition.getOauth());
- }
- }
- }
- gen.writeEndObject();
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/CallbackStateSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/CallbackStateSerializer.java
deleted file mode 100644
index 4e6e0b82..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/CallbackStateSerializer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.serverlessworkflow.api.states.CallbackState;
-import io.serverlessworkflow.api.states.DefaultState;
-import java.io.IOException;
-
-public class CallbackStateSerializer extends StdSerializer {
-
- public CallbackStateSerializer() {
- this(CallbackState.class);
- }
-
- protected CallbackStateSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(CallbackState callbackState, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- // set defaults for callback state
- callbackState.setType(DefaultState.Type.CALLBACK);
-
- // serialize after setting default bean values...
- BeanSerializerFactory.instance
- .createSerializer(
- provider, TypeFactory.defaultInstance().constructType(CallbackState.class))
- .serialize(callbackState, gen, provider);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/ContinueAsSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/ContinueAsSerializer.java
deleted file mode 100644
index d3b878cd..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/ContinueAsSerializer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.end.ContinueAs;
-import java.io.IOException;
-
-public class ContinueAsSerializer extends StdSerializer {
-
- public ContinueAsSerializer() {
- this(ContinueAs.class);
- }
-
- protected ContinueAsSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(ContinueAs continueAs, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- if (continueAs != null) {
- if ((continueAs.getWorkflowId() != null && !continueAs.getWorkflowId().isEmpty())
- && (continueAs.getVersion() == null || continueAs.getVersion().isEmpty())
- && (continueAs.getData() == null || continueAs.getData().isEmpty())
- && continueAs.getWorkflowExecTimeout() == null) {
- gen.writeString(continueAs.getWorkflowId());
- } else {
- gen.writeStartObject();
-
- if (continueAs.getWorkflowId() != null && continueAs.getWorkflowId().length() > 0) {
- gen.writeStringField("workflowId", continueAs.getWorkflowId());
- }
-
- if (continueAs.getVersion() != null && continueAs.getVersion().length() > 0) {
- gen.writeStringField("version", continueAs.getVersion());
- }
-
- if (continueAs.getData() != null && continueAs.getData().length() > 0) {
- gen.writeStringField("data", continueAs.getData());
- }
-
- if (continueAs.getWorkflowExecTimeout() != null) {
- gen.writeObjectField("workflowExecTimeout", continueAs.getWorkflowExecTimeout());
- }
-
- gen.writeEndObject();
- }
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/CronSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/CronSerializer.java
deleted file mode 100644
index 7de22bd0..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/CronSerializer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.cron.Cron;
-import java.io.IOException;
-
-public class CronSerializer extends StdSerializer {
-
- public CronSerializer() {
- this(Cron.class);
- }
-
- protected CronSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(Cron cron, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- if (cron != null) {
- if ((cron.getValidUntil() == null || cron.getValidUntil().isEmpty())
- && cron.getExpression() != null
- && cron.getExpression().length() > 0) {
- gen.writeString(cron.getExpression());
- } else {
- gen.writeStartObject();
-
- if (cron.getExpression() != null && cron.getExpression().length() > 0) {
- gen.writeStringField("expression", cron.getExpression());
- }
-
- if (cron.getValidUntil() != null && cron.getValidUntil().length() > 0) {
- gen.writeStringField("validUntil", cron.getValidUntil());
- }
-
- gen.writeEndObject();
- }
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/EndDefinitionSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/EndDefinitionSerializer.java
deleted file mode 100644
index 743c50b0..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/EndDefinitionSerializer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.end.End;
-import io.serverlessworkflow.api.produce.ProduceEvent;
-import java.io.IOException;
-
-public class EndDefinitionSerializer extends StdSerializer {
-
- public EndDefinitionSerializer() {
- this(End.class);
- }
-
- protected EndDefinitionSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(End end, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- if (end != null) {
- if ((end.getProduceEvents() == null || end.getProduceEvents().size() < 1)
- && end.getContinueAs() == null
- && !end.isCompensate()
- && !end.isTerminate()) {
- gen.writeBoolean(true);
- } else {
- gen.writeStartObject();
-
- if (end.isTerminate()) {
- gen.writeBooleanField("terminate", true);
- }
-
- if (end.getProduceEvents() != null && !end.getProduceEvents().isEmpty()) {
- gen.writeArrayFieldStart("produceEvents");
- for (ProduceEvent produceEvent : end.getProduceEvents()) {
- gen.writeObject(produceEvent);
- }
- gen.writeEndArray();
- }
-
- if (end.isCompensate()) {
- gen.writeBooleanField("compensate", true);
- }
-
- if (end.getContinueAs() != null) {
- gen.writeObjectField("continueAs", end.getContinueAs());
- }
-
- gen.writeEndObject();
- }
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/EventDefinitionSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/EventDefinitionSerializer.java
deleted file mode 100644
index d9faa8e2..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/EventDefinitionSerializer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.serverlessworkflow.api.events.EventDefinition;
-import java.io.IOException;
-
-public class EventDefinitionSerializer extends StdSerializer {
-
- public EventDefinitionSerializer() {
- this(EventDefinition.class);
- }
-
- protected EventDefinitionSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(
- EventDefinition triggerEvent, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- // serialize after setting default bean values...
- BeanSerializerFactory.instance
- .createSerializer(
- provider, TypeFactory.defaultInstance().constructType(EventDefinition.class))
- .serialize(triggerEvent, gen, provider);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/EventStateSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/EventStateSerializer.java
deleted file mode 100644
index f7aacd8c..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/EventStateSerializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.serverlessworkflow.api.states.DefaultState;
-import io.serverlessworkflow.api.states.EventState;
-import java.io.IOException;
-
-public class EventStateSerializer extends StdSerializer {
-
- public EventStateSerializer() {
- this(EventState.class);
- }
-
- protected EventStateSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(EventState eventState, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- // set defaults for end state
- eventState.setType(DefaultState.Type.EVENT);
-
- // serialize after setting default bean values...
- BeanSerializerFactory.instance
- .createSerializer(provider, TypeFactory.defaultInstance().constructType(EventState.class))
- .serialize(eventState, gen, provider);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/ExtensionSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/ExtensionSerializer.java
deleted file mode 100644
index 9748a561..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/ExtensionSerializer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.serverlessworkflow.api.interfaces.Extension;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-public class ExtensionSerializer extends StdSerializer {
-
- private Map> extensionsMap = new HashMap<>();
-
- public ExtensionSerializer() {
- this(Extension.class);
- }
-
- protected ExtensionSerializer(Class t) {
- super(t);
- }
-
- public void addExtension(String extensionId, Class extends Extension> extensionClass) {
- this.extensionsMap.put(extensionId, extensionClass);
- }
-
- @Override
- public void serialize(Extension extension, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- String extensionId = extension.getExtensionId();
-
- if (extensionsMap.containsKey(extensionId)) {
- // serialize after setting default bean values...
- BeanSerializerFactory.instance
- .createSerializer(
- provider, TypeFactory.defaultInstance().constructType(extensionsMap.get(extensionId)))
- .serialize(extension, gen, provider);
- } else {
- throw new IllegalArgumentException("Extension handler not registered for: " + extensionId);
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/ForEachStateSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/ForEachStateSerializer.java
deleted file mode 100644
index 8b6aee9d..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/ForEachStateSerializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.serverlessworkflow.api.states.DefaultState;
-import io.serverlessworkflow.api.states.ForEachState;
-import java.io.IOException;
-
-public class ForEachStateSerializer extends StdSerializer {
-
- public ForEachStateSerializer() {
- this(ForEachState.class);
- }
-
- protected ForEachStateSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(ForEachState forEachState, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- // set defaults for foreach state
- forEachState.setType(DefaultState.Type.FOREACH);
-
- // serialize after setting default bean values...
- BeanSerializerFactory.instance
- .createSerializer(provider, TypeFactory.defaultInstance().constructType(ForEachState.class))
- .serialize(forEachState, gen, provider);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/FunctionRefSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/FunctionRefSerializer.java
deleted file mode 100644
index cf5ce81f..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/FunctionRefSerializer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.functions.FunctionRef;
-import java.io.IOException;
-
-public class FunctionRefSerializer extends StdSerializer {
-
- public FunctionRefSerializer() {
- this(FunctionRef.class);
- }
-
- protected FunctionRefSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(FunctionRef functionRef, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- if (functionRef != null) {
- if ((functionRef.getArguments() == null || functionRef.getArguments().isEmpty())
- && (functionRef.getSelectionSet() == null || functionRef.getSelectionSet().isEmpty())
- && (functionRef.getInvoke() == null
- || functionRef.getInvoke().equals(FunctionRef.Invoke.SYNC))
- && functionRef.getRefName() != null
- && functionRef.getRefName().length() > 0) {
- gen.writeString(functionRef.getRefName());
- } else {
- gen.writeStartObject();
-
- if (functionRef.getRefName() != null && functionRef.getRefName().length() > 0) {
- gen.writeStringField("refName", functionRef.getRefName());
- }
-
- if (functionRef.getArguments() != null && !functionRef.getArguments().isEmpty()) {
- gen.writeObjectField("arguments", functionRef.getArguments());
- }
-
- if (functionRef.getSelectionSet() != null && functionRef.getSelectionSet().length() > 0) {
- gen.writeStringField("selectionSet", functionRef.getSelectionSet());
- }
-
- if (functionRef.getInvoke() != null) {
- gen.writeStringField("invoke", functionRef.getInvoke().value());
- }
-
- gen.writeEndObject();
- }
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/InjectStateSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/InjectStateSerializer.java
deleted file mode 100644
index 06f488bf..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/InjectStateSerializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.serverlessworkflow.api.states.DefaultState;
-import io.serverlessworkflow.api.states.InjectState;
-import java.io.IOException;
-
-public class InjectStateSerializer extends StdSerializer {
-
- public InjectStateSerializer() {
- this(InjectState.class);
- }
-
- protected InjectStateSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(InjectState relayState, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- // set defaults for relay state
- relayState.setType(DefaultState.Type.INJECT);
-
- // serialize after setting default bean values...
- BeanSerializerFactory.instance
- .createSerializer(provider, TypeFactory.defaultInstance().constructType(InjectState.class))
- .serialize(relayState, gen, provider);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/OperationStateSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/OperationStateSerializer.java
deleted file mode 100644
index a5389a07..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/OperationStateSerializer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.serverlessworkflow.api.states.DefaultState;
-import io.serverlessworkflow.api.states.OperationState;
-import java.io.IOException;
-
-public class OperationStateSerializer extends StdSerializer {
-
- public OperationStateSerializer() {
- this(OperationState.class);
- }
-
- protected OperationStateSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(
- OperationState operationState, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- // set defaults for delay state
- operationState.setType(DefaultState.Type.OPERATION);
-
- // serialize after setting default bean values...
- BeanSerializerFactory.instance
- .createSerializer(
- provider, TypeFactory.defaultInstance().constructType(OperationState.class))
- .serialize(operationState, gen, provider);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/ParallelStateSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/ParallelStateSerializer.java
deleted file mode 100644
index 115ffd00..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/ParallelStateSerializer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.serverlessworkflow.api.states.DefaultState;
-import io.serverlessworkflow.api.states.ParallelState;
-import java.io.IOException;
-
-public class ParallelStateSerializer extends StdSerializer {
-
- public ParallelStateSerializer() {
- this(ParallelState.class);
- }
-
- protected ParallelStateSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(ParallelState parallelState, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- // set defaults for end state
- parallelState.setType(DefaultState.Type.PARALLEL);
-
- // serialize after setting default bean values...
- BeanSerializerFactory.instance
- .createSerializer(
- provider, TypeFactory.defaultInstance().constructType(ParallelState.class))
- .serialize(parallelState, gen, provider);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/ScheduleSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/ScheduleSerializer.java
deleted file mode 100644
index 9f3d6f74..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/ScheduleSerializer.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.schedule.Schedule;
-import java.io.IOException;
-
-public class ScheduleSerializer extends StdSerializer {
-
- public ScheduleSerializer() {
- this(Schedule.class);
- }
-
- protected ScheduleSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(Schedule schedule, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- if (schedule != null) {
- if (schedule.getCron() == null
- && (schedule.getTimezone() == null || schedule.getTimezone().isEmpty())
- && schedule.getInterval() != null
- && schedule.getInterval().length() > 0) {
- gen.writeString(schedule.getInterval());
- } else {
- gen.writeStartObject();
-
- if (schedule.getInterval() != null && schedule.getInterval().length() > 0) {
- gen.writeStringField("interval", schedule.getInterval());
- }
-
- if (schedule.getCron() != null) {
- gen.writeObjectField("cron", schedule.getCron());
- }
-
- if (schedule.getTimezone() != null && schedule.getTimezone().length() > 0) {
- gen.writeStringField("timezone", schedule.getTimezone());
- }
-
- gen.writeEndObject();
- }
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/SleepStateSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/SleepStateSerializer.java
deleted file mode 100644
index 8ba529a6..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/SleepStateSerializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.serverlessworkflow.api.states.DefaultState;
-import io.serverlessworkflow.api.states.SleepState;
-import java.io.IOException;
-
-public class SleepStateSerializer extends StdSerializer {
-
- public SleepStateSerializer() {
- this(SleepState.class);
- }
-
- protected SleepStateSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(SleepState delayState, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- // set defaults for delay state
- delayState.setType(DefaultState.Type.SLEEP);
-
- // serialize after setting default bean values...
- BeanSerializerFactory.instance
- .createSerializer(provider, TypeFactory.defaultInstance().constructType(SleepState.class))
- .serialize(delayState, gen, provider);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/StartDefinitionSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/StartDefinitionSerializer.java
deleted file mode 100644
index 8f1142f1..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/StartDefinitionSerializer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.start.Start;
-import java.io.IOException;
-
-public class StartDefinitionSerializer extends StdSerializer {
-
- public StartDefinitionSerializer() {
- this(Start.class);
- }
-
- protected StartDefinitionSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(Start start, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- if (start != null) {
- if (start.getStateName() != null
- && start.getStateName().length() > 0
- && start.getSchedule() == null) {
- gen.writeString(start.getStateName());
- } else {
- gen.writeStartObject();
-
- if (start.getStateName() != null && start.getStateName().length() > 0) {
- gen.writeStringField("stateName", start.getStateName());
- }
-
- if (start.getSchedule() != null) {
- gen.writeObjectField("schedule", start.getSchedule());
- }
-
- gen.writeEndObject();
- }
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/StateExecTimeoutSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/StateExecTimeoutSerializer.java
deleted file mode 100644
index f28b57da..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/StateExecTimeoutSerializer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.timeouts.StateExecTimeout;
-import java.io.IOException;
-
-public class StateExecTimeoutSerializer extends StdSerializer {
-
- public StateExecTimeoutSerializer() {
- this(StateExecTimeout.class);
- }
-
- protected StateExecTimeoutSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(
- StateExecTimeout stateExecTimeout, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- if (stateExecTimeout != null) {
- if ((stateExecTimeout.getTotal() != null && !stateExecTimeout.getTotal().isEmpty())
- && (stateExecTimeout.getSingle() == null || stateExecTimeout.getSingle().isEmpty())) {
- gen.writeString(stateExecTimeout.getTotal());
- } else {
- gen.writeStartObject();
-
- if (stateExecTimeout.getTotal() != null && stateExecTimeout.getTotal().length() > 0) {
- gen.writeStringField("total", stateExecTimeout.getTotal());
- }
-
- if (stateExecTimeout.getSingle() != null && stateExecTimeout.getSingle().length() > 0) {
- gen.writeStringField("single", stateExecTimeout.getSingle());
- }
-
- gen.writeEndObject();
- }
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/SubFlowRefSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/SubFlowRefSerializer.java
deleted file mode 100644
index 4b94b9e4..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/SubFlowRefSerializer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.functions.SubFlowRef;
-import java.io.IOException;
-
-public class SubFlowRefSerializer extends StdSerializer {
-
- public SubFlowRefSerializer() {
- this(SubFlowRef.class);
- }
-
- protected SubFlowRefSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(SubFlowRef subflowRef, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- if (subflowRef != null) {
- if ((subflowRef.getWorkflowId() == null || subflowRef.getWorkflowId().isEmpty())
- && (subflowRef.getVersion() == null || subflowRef.getVersion().isEmpty())
- && (subflowRef.getInvoke() == null
- || subflowRef.getInvoke().equals(SubFlowRef.Invoke.SYNC))) {
- gen.writeString(subflowRef.getWorkflowId());
- } else {
- gen.writeStartObject();
-
- if (subflowRef.getWorkflowId() != null && subflowRef.getWorkflowId().length() > 0) {
- gen.writeStringField("workflowId", subflowRef.getWorkflowId());
- }
-
- if (subflowRef.getVersion() != null && subflowRef.getVersion().length() > 0) {
- gen.writeStringField("version", subflowRef.getVersion());
- }
-
- if (subflowRef.getOnParentComplete() != null) {
- gen.writeStringField("onParentComplete", subflowRef.getOnParentComplete().value());
- }
-
- if (subflowRef.getInvoke() != null) {
- gen.writeStringField("invoke", subflowRef.getInvoke().value());
- }
-
- gen.writeEndObject();
- }
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/SwitchStateSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/SwitchStateSerializer.java
deleted file mode 100644
index d5a725d0..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/SwitchStateSerializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.serverlessworkflow.api.states.DefaultState;
-import io.serverlessworkflow.api.states.SwitchState;
-import java.io.IOException;
-
-public class SwitchStateSerializer extends StdSerializer {
-
- public SwitchStateSerializer() {
- this(SwitchState.class);
- }
-
- protected SwitchStateSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(SwitchState switchState, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- // set defaults for end state
- switchState.setType(DefaultState.Type.SWITCH);
-
- // serialize after setting default bean values...
- BeanSerializerFactory.instance
- .createSerializer(provider, TypeFactory.defaultInstance().constructType(SwitchState.class))
- .serialize(switchState, gen, provider);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/TransitionSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/TransitionSerializer.java
deleted file mode 100644
index 12699ccc..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/TransitionSerializer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.produce.ProduceEvent;
-import io.serverlessworkflow.api.transitions.Transition;
-import java.io.IOException;
-
-public class TransitionSerializer extends StdSerializer {
-
- public TransitionSerializer() {
- this(Transition.class);
- }
-
- protected TransitionSerializer(Class t) {
- super(t);
- }
-
- @Override
- public void serialize(Transition transition, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- if (transition != null) {
- if ((transition.getProduceEvents() == null || transition.getProduceEvents().size() < 1)
- && !transition.isCompensate()
- && transition.getNextState() != null
- && transition.getNextState().length() > 0) {
- gen.writeString(transition.getNextState());
- } else {
- gen.writeStartObject();
-
- if (transition.getProduceEvents() != null && !transition.getProduceEvents().isEmpty()) {
- gen.writeArrayFieldStart("produceEvents");
- for (ProduceEvent produceEvent : transition.getProduceEvents()) {
- gen.writeObject(produceEvent);
- }
- gen.writeEndArray();
- }
-
- if (transition.isCompensate()) {
- gen.writeBooleanField("compensate", true);
- }
-
- if (transition.getNextState() != null && transition.getNextState().length() > 0) {
- gen.writeStringField("nextState", transition.getNextState());
- }
-
- gen.writeEndObject();
- }
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/serializers/WorkflowSerializer.java b/api/src/main/java/io/serverlessworkflow/api/serializers/WorkflowSerializer.java
deleted file mode 100644
index beeba2fb..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/serializers/WorkflowSerializer.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * 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.api.serializers;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.error.ErrorDefinition;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.api.interfaces.Extension;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.api.retry.RetryDefinition;
-import java.io.IOException;
-import java.security.MessageDigest;
-import java.util.UUID;
-
-public class WorkflowSerializer extends StdSerializer {
-
- public WorkflowSerializer() {
- this(Workflow.class);
- }
-
- protected WorkflowSerializer(Class t) {
- super(t);
- }
-
- private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
-
- @Override
- public void serialize(Workflow workflow, JsonGenerator gen, SerializerProvider provider)
- throws IOException {
-
- gen.writeStartObject();
-
- if (workflow.getId() != null && !workflow.getId().isEmpty()) {
- gen.writeStringField("id", workflow.getId());
- } else {
- gen.writeStringField("id", generateUniqueId());
- }
-
- if (workflow.getKey() != null) {
- gen.writeStringField("key", workflow.getKey());
- }
- gen.writeStringField("name", workflow.getName());
-
- if (workflow.getDescription() != null && !workflow.getDescription().isEmpty()) {
- gen.writeStringField("description", workflow.getDescription());
- }
-
- if (workflow.getVersion() != null && !workflow.getVersion().isEmpty()) {
- gen.writeStringField("version", workflow.getVersion());
- }
-
- if (workflow.getAnnotations() != null && !workflow.getAnnotations().isEmpty()) {
- gen.writeObjectField("annotations", workflow.getAnnotations());
- }
-
- if (workflow.getDataInputSchema() != null) {
- if (workflow.getDataInputSchema().getRefValue() != null
- && workflow.getDataInputSchema().getRefValue().length() > 0
- && workflow.getDataInputSchema().isFailOnValidationErrors()) {
- gen.writeStringField("dataInputSchema", workflow.getDataInputSchema().getRefValue());
-
- } else if (workflow.getDataInputSchema().getSchemaDef() != null
- && !workflow.getDataInputSchema().getSchemaDef().isEmpty()
- && !workflow.getDataInputSchema().isFailOnValidationErrors()) {
- gen.writeObjectField("dataInputSchema", workflow.getDataInputSchema().getSchemaDef());
- }
- }
-
- if (workflow.getStart() != null) {
- gen.writeObjectField("start", workflow.getStart());
- }
-
- if (workflow.getSpecVersion() != null && !workflow.getSpecVersion().isEmpty()) {
- gen.writeStringField("specVersion", workflow.getSpecVersion());
- }
-
- if (workflow.getExtensions() != null && !workflow.getExpressionLang().isEmpty()) {
- gen.writeStringField("expressionLang", workflow.getExpressionLang());
- }
-
- if (workflow.isKeepActive()) {
- gen.writeBooleanField("keepActive", workflow.isKeepActive());
- }
-
- if (workflow.isAutoRetries()) {
- gen.writeBooleanField("autoRetries", workflow.isAutoRetries());
- }
-
- if (workflow.getMetadata() != null && !workflow.getMetadata().isEmpty()) {
- gen.writeObjectField("metadata", workflow.getMetadata());
- }
-
- if (workflow.getEvents() != null && !workflow.getEvents().getEventDefs().isEmpty()) {
- gen.writeArrayFieldStart("events");
- for (EventDefinition eventDefinition : workflow.getEvents().getEventDefs()) {
- gen.writeObject(eventDefinition);
- }
- gen.writeEndArray();
- }
-
- if (workflow.getFunctions() != null && !workflow.getFunctions().getFunctionDefs().isEmpty()) {
- gen.writeArrayFieldStart("functions");
- for (FunctionDefinition function : workflow.getFunctions().getFunctionDefs()) {
- gen.writeObject(function);
- }
- gen.writeEndArray();
- }
-
- if (workflow.getRetries() != null && !workflow.getRetries().getRetryDefs().isEmpty()) {
- gen.writeArrayFieldStart("retries");
- for (RetryDefinition retry : workflow.getRetries().getRetryDefs()) {
- gen.writeObject(retry);
- }
- gen.writeEndArray();
- }
-
- if (workflow.getErrors() != null && !workflow.getErrors().getErrorDefs().isEmpty()) {
- gen.writeArrayFieldStart("errors");
- for (ErrorDefinition error : workflow.getErrors().getErrorDefs()) {
- gen.writeObject(error);
- }
- gen.writeEndArray();
- }
-
- if (workflow.getSecrets() != null && !workflow.getSecrets().getSecretDefs().isEmpty()) {
- gen.writeArrayFieldStart("secrets");
- for (String secretDef : workflow.getSecrets().getSecretDefs()) {
- gen.writeString(secretDef);
- }
- gen.writeEndArray();
- }
-
- if (workflow.getConstants() != null) {
- if (workflow.getConstants().getConstantsDef() != null
- && !workflow.getConstants().getConstantsDef().isEmpty()) {
- gen.writeObjectField("constants", workflow.getConstants().getConstantsDef());
- } else if (workflow.getConstants().getRefValue() != null) {
- gen.writeStringField("constants", workflow.getConstants().getRefValue());
- }
- }
-
- if (workflow.getTimeouts() != null) {
- gen.writeObjectField("timeouts", workflow.getTimeouts());
- }
-
- if (workflow.getAuth() != null && !workflow.getAuth().getAuthDefs().isEmpty()) {
- gen.writeObjectField("auth", workflow.getAuth().getAuthDefs());
- }
-
- if (workflow.getStates() != null && !workflow.getStates().isEmpty()) {
- gen.writeArrayFieldStart("states");
- for (State state : workflow.getStates()) {
- gen.writeObject(state);
- }
- gen.writeEndArray();
- }
-
- if (workflow.getExtensions() != null && !workflow.getExtensions().isEmpty()) {
- gen.writeArrayFieldStart("extensions");
- for (Extension extension : workflow.getExtensions()) {
- gen.writeObject(extension);
- }
- gen.writeEndArray();
- }
-
- gen.writeEndObject();
- }
-
- protected static String generateUniqueId() {
- try {
- MessageDigest salt = MessageDigest.getInstance("SHA-256");
-
- salt.update(UUID.randomUUID().toString().getBytes("UTF-8"));
- return bytesToHex(salt.digest());
- } catch (Exception e) {
- return UUID.randomUUID().toString();
- }
- }
-
- protected static String bytesToHex(byte[] bytes) {
- char[] hexChars = new char[bytes.length * 2];
- for (int j = 0; j < bytes.length; j++) {
- int v = bytes[j] & 0xFF;
- hexChars[j * 2] = hexArray[v >>> 4];
- hexChars[j * 2 + 1] = hexArray[v & 0x0F];
- }
- return new String(hexChars);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/utils/Utils.java b/api/src/main/java/io/serverlessworkflow/api/utils/Utils.java
deleted file mode 100644
index 9bdce416..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/utils/Utils.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.api.utils;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import io.serverlessworkflow.api.mapper.JsonObjectMapperFactory;
-import io.serverlessworkflow.api.mapper.YamlObjectMapperFactory;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.stream.Collectors;
-
-public class Utils {
-
- @SuppressWarnings("DefaultCharset")
- public static String getResourceFileAsString(String fileName) throws IOException {
- ClassLoader classLoader = ClassLoader.getSystemClassLoader();
- try (InputStream is = classLoader.getResourceAsStream(fileName)) {
- if (is == null) return null;
- try (InputStreamReader isr = new InputStreamReader(is);
- BufferedReader reader = new BufferedReader(isr)) {
- return reader.lines().collect(Collectors.joining(System.lineSeparator()));
- }
- }
- }
-
- public static ObjectMapper getObjectMapper(String source) {
- return !source.trim().startsWith("{")
- ? YamlObjectMapperFactory.mapper()
- : JsonObjectMapperFactory.mapper();
- }
-
- public static JsonNode getNode(String source) throws JsonProcessingException {
- return getObjectMapper(source).readTree(source);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/validation/ValidationError.java b/api/src/main/java/io/serverlessworkflow/api/validation/ValidationError.java
deleted file mode 100644
index edb92eff..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/validation/ValidationError.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.api.validation;
-
-public class ValidationError {
- private static final String MSG_FORMAT = "%s:%s";
- public static final String SCHEMA_VALIDATION = "schemavalidation";
- public static final String WORKFLOW_VALIDATION = "workflowvalidation";
-
- private String message;
- private String type;
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- @Override
- public String toString() {
- return String.format(MSG_FORMAT, type, message);
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/validation/WorkflowSchemaLoader.java b/api/src/main/java/io/serverlessworkflow/api/validation/WorkflowSchemaLoader.java
deleted file mode 100644
index 847380fb..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/validation/WorkflowSchemaLoader.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.api.validation;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-
-public class WorkflowSchemaLoader {
-
- public static JsonNode getWorkflowSchema() {
- try {
- return ObjectMapperHolder.objectMapper.readTree(
- WorkflowSchemaLoader.class.getResourceAsStream("/schema/workflow.json"));
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- private static class ObjectMapperHolder {
- public static final ObjectMapper objectMapper = new ObjectMapper();
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/workflow/Auth.java b/api/src/main/java/io/serverlessworkflow/api/workflow/Auth.java
deleted file mode 100644
index 53fa2922..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/workflow/Auth.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2022-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.api.workflow;
-
-import io.serverlessworkflow.api.auth.AuthDefinition;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-public class Auth implements Serializable {
- private String refValue;
- private List authDefs;
-
- public Auth() {}
-
- public Auth(AuthDefinition authDef) {
- this.authDefs = new ArrayList<>();
- this.authDefs.add(authDef);
- }
-
- public Auth(List authDefs) {
- this.authDefs = authDefs;
- }
-
- public Auth(String refValue) {
- this.refValue = refValue;
- }
-
- public String getRefValue() {
- return refValue;
- }
-
- public void setRefValue(String refValue) {
- this.refValue = refValue;
- }
-
- public List getAuthDefs() {
- return authDefs;
- }
-
- public void setAuthDefs(List authDefs) {
- this.authDefs = authDefs;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/workflow/BaseWorkflow.java b/api/src/main/java/io/serverlessworkflow/api/workflow/BaseWorkflow.java
deleted file mode 100644
index 61692caf..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/workflow/BaseWorkflow.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.api.workflow;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
-import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.mapper.JsonObjectMapper;
-import io.serverlessworkflow.api.mapper.YamlObjectMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Base Workflow provides some extra functionality for the Workflow types */
-public class BaseWorkflow {
-
- private static JsonObjectMapper jsonObjectMapper = new JsonObjectMapper();
- private static YamlObjectMapper yamlObjectMapper = new YamlObjectMapper();
-
- private static Logger logger = LoggerFactory.getLogger(BaseWorkflow.class);
-
- public static Workflow fromSource(String source) {
- // try it as json markup first, if fails try yaml
- try {
- return jsonObjectMapper.readValue(source, Workflow.class);
- } catch (Exception e) {
- logger.info("Unable to convert as json markup, trying as yaml");
- try {
- return yamlObjectMapper.readValue(source, Workflow.class);
- } catch (Exception ee) {
- throw new IllegalArgumentException(
- "Could not convert markup to Workflow: " + ee.getMessage());
- }
- }
- }
-
- public static String toJson(Workflow workflow) {
- try {
- return jsonObjectMapper.writeValueAsString(workflow);
- } catch (JsonProcessingException e) {
- logger.error("Error mapping to json: " + e.getMessage());
- return null;
- }
- }
-
- public static String toYaml(Workflow workflow) {
- try {
- String jsonString = jsonObjectMapper.writeValueAsString(workflow);
- JsonNode jsonNode = jsonObjectMapper.readTree(jsonString);
- YAMLFactory yamlFactory =
- new YAMLFactory()
- .disable(YAMLGenerator.Feature.MINIMIZE_QUOTES)
- .disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER);
- return new YAMLMapper(yamlFactory).writeValueAsString(jsonNode);
- } catch (Exception e) {
- logger.error("Error mapping to yaml: " + e.getMessage());
- return null;
- }
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/workflow/Constants.java b/api/src/main/java/io/serverlessworkflow/api/workflow/Constants.java
deleted file mode 100644
index 3afbddc2..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/workflow/Constants.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.api.workflow;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import java.io.Serializable;
-
-public class Constants implements Serializable {
- private String refValue;
- private JsonNode constantsDef;
-
- public Constants() {}
-
- public Constants(String refValue) {
- this.refValue = refValue;
- }
-
- public Constants(JsonNode constantsDef) {
- this.constantsDef = constantsDef;
- }
-
- public String getRefValue() {
- return refValue;
- }
-
- public void setRefValue(String refValue) {
- this.refValue = refValue;
- }
-
- public JsonNode getConstantsDef() {
- return constantsDef;
- }
-
- public void setConstantsDef(JsonNode constantsDef) {
- this.constantsDef = constantsDef;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/workflow/DataInputSchema.java b/api/src/main/java/io/serverlessworkflow/api/workflow/DataInputSchema.java
deleted file mode 100644
index ba0dd333..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/workflow/DataInputSchema.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.api.workflow;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import java.io.Serializable;
-
-public class DataInputSchema implements Serializable {
- private String refValue;
- private JsonNode schemaDef;
- private boolean failOnValidationErrors = true;
-
- public DataInputSchema() {}
-
- public DataInputSchema(String refValue) {
- this.refValue = refValue;
- }
-
- public String getRefValue() {
- return refValue;
- }
-
- public void setRefValue(String refValue) {
- this.refValue = refValue;
- }
-
- public JsonNode getSchemaDef() {
- return schemaDef;
- }
-
- public void setSchemaDef(JsonNode schemaDef) {
- this.schemaDef = schemaDef;
- }
-
- public boolean isFailOnValidationErrors() {
- return failOnValidationErrors;
- }
-
- public void setFailOnValidationErrors(boolean failOnValidationErrors) {
- this.failOnValidationErrors = failOnValidationErrors;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/workflow/Errors.java b/api/src/main/java/io/serverlessworkflow/api/workflow/Errors.java
deleted file mode 100644
index c6418863..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/workflow/Errors.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.api.workflow;
-
-import io.serverlessworkflow.api.error.ErrorDefinition;
-import java.io.Serializable;
-import java.util.List;
-
-public class Errors implements Serializable {
- private String refValue;
- private List errorDefs;
-
- public Errors() {}
-
- public Errors(List errorDefs) {
- this.errorDefs = errorDefs;
- }
-
- public Errors(String refValue) {
- this.refValue = refValue;
- }
-
- public String getRefValue() {
- return refValue;
- }
-
- public void setRefValue(String refValue) {
- this.refValue = refValue;
- }
-
- public List getErrorDefs() {
- return errorDefs;
- }
-
- public void setErrorDefs(List errorDefs) {
- this.errorDefs = errorDefs;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/workflow/Events.java b/api/src/main/java/io/serverlessworkflow/api/workflow/Events.java
deleted file mode 100644
index a90c7d6a..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/workflow/Events.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.api.workflow;
-
-import io.serverlessworkflow.api.events.EventDefinition;
-import java.io.Serializable;
-import java.util.List;
-
-public class Events implements Serializable {
- private String refValue;
- private List eventDefs;
-
- public Events() {}
-
- public Events(List eventDefs) {
- this.eventDefs = eventDefs;
- }
-
- public Events(String refValue) {
- this.refValue = refValue;
- }
-
- public String getRefValue() {
- return refValue;
- }
-
- public void setRefValue(String refValue) {
- this.refValue = refValue;
- }
-
- public List getEventDefs() {
- return eventDefs;
- }
-
- public void setEventDefs(List eventDefs) {
- this.eventDefs = eventDefs;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/workflow/Functions.java b/api/src/main/java/io/serverlessworkflow/api/workflow/Functions.java
deleted file mode 100644
index 1c01c35e..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/workflow/Functions.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.api.workflow;
-
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import java.io.Serializable;
-import java.util.List;
-
-public class Functions implements Serializable {
- private String refValue;
- private List functionDefs;
-
- public Functions() {}
-
- public Functions(List functionDefs) {
- this.functionDefs = functionDefs;
- }
-
- public Functions(String refValue) {
- this.refValue = refValue;
- }
-
- public String getRefValue() {
- return refValue;
- }
-
- public void setRefValue(String refValue) {
- this.refValue = refValue;
- }
-
- public List getFunctionDefs() {
- return functionDefs;
- }
-
- public void setFunctionDefs(List functionDefs) {
- this.functionDefs = functionDefs;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/workflow/Retries.java b/api/src/main/java/io/serverlessworkflow/api/workflow/Retries.java
deleted file mode 100644
index be79f9ab..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/workflow/Retries.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.api.workflow;
-
-import io.serverlessworkflow.api.retry.RetryDefinition;
-import java.io.Serializable;
-import java.util.List;
-
-public class Retries implements Serializable {
- private String refValue;
- private List retryDefs;
-
- public Retries() {}
-
- public Retries(List retryDefs) {
- this.retryDefs = retryDefs;
- }
-
- public Retries(String refValue) {
- this.refValue = refValue;
- }
-
- public String getRefValue() {
- return refValue;
- }
-
- public void setRefValue(String refValue) {
- this.refValue = refValue;
- }
-
- public List getRetryDefs() {
- return retryDefs;
- }
-
- public void setRetryDefs(List retryDefs) {
- this.retryDefs = retryDefs;
- }
-}
diff --git a/api/src/main/java/io/serverlessworkflow/api/workflow/Secrets.java b/api/src/main/java/io/serverlessworkflow/api/workflow/Secrets.java
deleted file mode 100644
index 0783b196..00000000
--- a/api/src/main/java/io/serverlessworkflow/api/workflow/Secrets.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.api.workflow;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class Secrets implements Serializable {
- private String refValue;
- private List secretDefs;
-
- public Secrets() {}
-
- public Secrets(String refValue) {
- this.refValue = refValue;
- }
-
- public Secrets(List secretDefs) {
- this.secretDefs = secretDefs;
- }
-
- public String getRefValue() {
- return refValue;
- }
-
- public void setRefValue(String refValue) {
- this.refValue = refValue;
- }
-
- public List getSecretDefs() {
- return secretDefs;
- }
-
- public void setSecretDefs(List secretDefs) {
- this.secretDefs = secretDefs;
- }
-}
diff --git a/api/src/main/resources/schema/actions/action.json b/api/src/main/resources/schema/actions/action.json
deleted file mode 100644
index 54354029..00000000
--- a/api/src/main/resources/schema/actions/action.json
+++ /dev/null
@@ -1,75 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.actions.Action",
- "description": "Action Definition",
- "properties": {
- "id": {
- "type": "string",
- "description": "Unique action identifier"
- },
- "name": {
- "type": "string",
- "description": "Unique action definition name"
- },
- "functionRef": {
- "description": "References a reusable function definition to be invoked",
- "$ref": "../functions/functionref.json"
- },
- "eventRef": {
- "description": "References a 'trigger' and 'result' reusable event definitions",
- "$ref": "../events/eventref.json"
- },
- "subFlowRef": {
- "description": "References a sub-workflow to invoke",
- "$ref": "../functions/subflowref.json"
- },
- "sleep": {
- "$ref": "../sleep/sleep.json"
- },
- "retryRef": {
- "type": "string",
- "description": "References a defined workflow retry definition. If not defined the default retry policy is assumed"
- },
- "nonRetryableErrors": {
- "type": "array",
- "description": "List of unique references to defined workflow errors for which the action should not be retried. Used only when `autoRetries` is set to `true`",
- "minItems": 1,
- "items": {
- "type": "string"
- }
- },
- "retryableErrors": {
- "type": "array",
- "description": "List of unique references to defined workflow errors for which the action should be retried. Used only when `autoRetries` is set to `false`",
- "minItems": 1,
- "items": {
- "type": "string"
- }
- },
- "actionDataFilter": {
- "$ref": "../filters/actiondatafilter.json"
- },
- "condition": {
- "description": "Expression, if defined, must evaluate to true for this action to be performed. If false, action is disregarded",
- "type": "string",
- "minLength": 1
- }
- },
- "oneOf": [
- {
- "required": [
- "functionRef"
- ]
- },
- {
- "required": [
- "eventRef"
- ]
- },
- {
- "required": [
- "subFlowRef"
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/auth/auth.json b/api/src/main/resources/schema/auth/auth.json
deleted file mode 100644
index c8ece5ee..00000000
--- a/api/src/main/resources/schema/auth/auth.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.auth.AuthDefinition",
- "description": "Auth Definition",
- "properties": {
- "name": {
- "type": "string",
- "description": "Unique auth definition name",
- "minLength": 1
- },
- "scheme": {
- "type": "string",
- "description": "Defines the auth type",
- "enum": [
- "basic",
- "bearer",
- "oauth2"
- ],
- "default": "basic"
- },
- "basicauth": {
- "$ref": "basicauthdef.json"
- },
- "bearerauth": {
- "$ref": "bearerauthdef.json"
- },
- "oauth": {
- "$ref": "oauthdef.json"
- }
- },
- "required": [
-
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/auth/basicauthdef.json b/api/src/main/resources/schema/auth/basicauthdef.json
deleted file mode 100644
index f7c80da1..00000000
--- a/api/src/main/resources/schema/auth/basicauthdef.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.auth.BasicAuthDefinition",
- "properties": {
- "username": {
- "type": "string",
- "description": "String or a workflow expression. Contains the user name",
- "minLength": 1
- },
- "password": {
- "type": "string",
- "description": "String or a workflow expression. Contains the user password",
- "minLength": 1
- },
- "metadata": {
- "$ref": "../metadata/metadata.json"
- }
- },
- "required": [
- "username",
- "password"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/auth/bearerauthdef.json b/api/src/main/resources/schema/auth/bearerauthdef.json
deleted file mode 100644
index 61dfd137..00000000
--- a/api/src/main/resources/schema/auth/bearerauthdef.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.auth.BearerAuthDefinition",
- "properties": {
- "token": {
- "type": "string",
- "description": "String or a workflow expression. Contains the token",
- "minLength": 1
- },
- "metadata": {
- "$ref": "../metadata/metadata.json"
- }
- },
- "required": [
- "token"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/auth/oauthdef.json b/api/src/main/resources/schema/auth/oauthdef.json
deleted file mode 100644
index 4354be2c..00000000
--- a/api/src/main/resources/schema/auth/oauthdef.json
+++ /dev/null
@@ -1,79 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.auth.OauthDefinition",
- "properties": {
- "authority": {
- "type": "string",
- "description": "String or a workflow expression. Contains the authority information",
- "minLength": 1
- },
- "grantType": {
- "type": "string",
- "description": "Defines the grant type",
- "enum": [
- "password",
- "clientCredentials",
- "tokenExchange"
- ],
- "additionalItems": false
- },
- "clientId": {
- "type": "string",
- "description": "String or a workflow expression. Contains the client identifier",
- "minLength": 1
- },
- "clientSecret": {
- "type": "string",
- "description": "Workflow secret or a workflow expression. Contains the client secret",
- "minLength": 1
- },
- "scopes": {
- "type": "array",
- "description": "Array containing strings or workflow expressions. Contains the OAuth2 scopes",
- "items": {
- "type": "string"
- },
- "minItems": 1
- },
- "username": {
- "type": "string",
- "description": "String or a workflow expression. Contains the user name. Used only if grantType is 'resourceOwner'",
- "minLength": 1
- },
- "password": {
- "type": "string",
- "description": "String or a workflow expression. Contains the user password. Used only if grantType is 'resourceOwner'",
- "minLength": 1
- },
- "audiences": {
- "type": "array",
- "description": "Array containing strings or workflow expressions. Contains the OAuth2 audiences",
- "items": {
- "type": "string"
- },
- "minItems": 1
- },
- "subjectToken": {
- "type": "string",
- "description": "String or a workflow expression. Contains the subject token",
- "minLength": 1
- },
- "requestedSubject": {
- "type": "string",
- "description": "String or a workflow expression. Contains the requested subject",
- "minLength": 1
- },
- "requestedIssuer": {
- "type": "string",
- "description": "String or a workflow expression. Contains the requested issuer",
- "minLength": 1
- },
- "metadata": {
- "$ref": "../metadata/metadata.json"
- }
- },
- "required": [
- "grantType",
- "clientId"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/branches/branch.json b/api/src/main/resources/schema/branches/branch.json
deleted file mode 100644
index cdfdb6d0..00000000
--- a/api/src/main/resources/schema/branches/branch.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.branches.Branch",
- "description": "Branch Definition",
- "properties": {
- "name": {
- "type": "string",
- "description": "Branch name"
- },
- "actions": {
- "type": "array",
- "description": "Actions to be executed in this branch",
- "items": {
- "type": "object",
- "$ref": "../actions/action.json"
- }
- },
- "timeouts": {
- "$ref": "../timeouts/timeoutsdef.json"
- }
- },
- "oneOf": [
- {
- "required": [
- "name",
- "actions"
- ]
- },
- {
- "required": [
- "name"
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/correlation/correlationdef.json b/api/src/main/resources/schema/correlation/correlationdef.json
deleted file mode 100644
index 7f271b08..00000000
--- a/api/src/main/resources/schema/correlation/correlationdef.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.correlation.CorrelationDef",
- "description": "CloudEvent correlation definition",
- "properties": {
- "contextAttributeName": {
- "type": "string",
- "description": "CloudEvent Extension Context Attribute name",
- "minLength": 1
- },
- "contextAttributeValue": {
- "type": "string",
- "description": "CloudEvent Extension Context Attribute value",
- "minLength": 1
- }
- },
- "required": [
- "contextAttributeName"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/cron/crondef.json b/api/src/main/resources/schema/cron/crondef.json
deleted file mode 100644
index 67bb43c5..00000000
--- a/api/src/main/resources/schema/cron/crondef.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.cron.Cron",
- "description": "Schedule cron definition",
- "properties": {
- "expression": {
- "type": "string",
- "description": "Repeating interval (cron expression) describing when the workflow instance should be created"
- },
- "validUntil": {
- "type": "string",
- "description": "Specific date and time (ISO 8601 format) when the cron expression invocation is no longer valid"
- }
- },
- "required": [
- "expression"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/defaultcondition/defaultconditiondef.json b/api/src/main/resources/schema/defaultcondition/defaultconditiondef.json
deleted file mode 100644
index 862e5c4c..00000000
--- a/api/src/main/resources/schema/defaultcondition/defaultconditiondef.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.defaultdef.DefaultConditionDefinition",
- "description": "Switch state default condition definition",
- "properties": {
- "transition": {
- "$ref": "../transitions/transition.json",
- "description": "Next transition of the workflow if there is valid matches"
- },
- "end": {
- "$ref": "../end/end.json",
- "description": "Workflow end definition"
- }
- },
- "oneOf": [
- {
- "required": [
- "transition"
- ]
- },
- {
- "required": [
- "end"
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/end/continueas.json b/api/src/main/resources/schema/end/continueas.json
deleted file mode 100644
index 94c10e86..00000000
--- a/api/src/main/resources/schema/end/continueas.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.end.ContinueAs",
- "description": "End definition continue as",
- "properties": {
- "workflowId": {
- "type": "string",
- "description": "Unique id of the workflow to continue execution as"
- },
- "version": {
- "type": "string",
- "description": "Version of the workflow to continue execution as",
- "minLength": 1
- },
- "data": {
- "type": [
- "string"
- ],
- "description": "Expression which selects parts of the states data output to become the workflow data input of continued execution"
- },
- "workflowExecTimeout": {
- "$ref": "../timeouts/workflowexectimeout.json"
- }
- },
- "required": [
- "kind"
- ]
-}s
\ No newline at end of file
diff --git a/api/src/main/resources/schema/end/end.json b/api/src/main/resources/schema/end/end.json
deleted file mode 100644
index 755ca929..00000000
--- a/api/src/main/resources/schema/end/end.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.end.End",
- "description": "State end definition",
- "properties": {
- "terminate": {
- "type": "boolean",
- "default": false,
- "description": "If true, completes all execution flows in the given workflow instance"
- },
- "produceEvents": {
- "type": "array",
- "description": "Array of events to be produced",
- "items": {
- "type": "object",
- "$ref": "../produce/produceevent.json"
- }
- },
- "compensate": {
- "type": "boolean",
- "default": false,
- "description": "If set to true, triggers workflow compensation when before workflow executin completes. Default is false"
- },
- "continueAs": {
- "$ref": "continueas.json"
- }
- },
- "required": [
- "kind"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/error/error.json b/api/src/main/resources/schema/error/error.json
deleted file mode 100644
index c51860de..00000000
--- a/api/src/main/resources/schema/error/error.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.error.Error",
- "properties": {
- "errorRef": {
- "type": "string",
- "description": "Reference to a unique workflow error definition. Used of errorRefs is not used",
- "minLength": 1
- },
- "errorRefs": {
- "type": "array",
- "description": "References one or more workflow error definitions. Used if errorRef is not used",
- "minItems": 1,
- "items": {
- "type": "string"
- }
- },
- "transition": {
- "$ref": "../transitions/transition.json",
- "description": "Transition to next state to handle the error. If retryRef is defined, this transition is taken only if retries were unsuccessful."
- },
- "end": {
- "description": "End workflow execution in case of this error. If retryRef is defined, this ends workflow only if retries were unsuccessful.",
- "$ref": "../end/end.json"
- }
- },
- "required": [
- "error",
- "transition"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/error/errordef.json b/api/src/main/resources/schema/error/errordef.json
deleted file mode 100644
index 613d3cbf..00000000
--- a/api/src/main/resources/schema/error/errordef.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.error.ErrorDefinition",
- "properties": {
- "name": {
- "type": "string",
- "description": "Domain-specific error name",
- "minLength": 1
- },
- "code": {
- "type": "string",
- "description": "Error code. Can be used in addition to the name to help runtimes resolve to technical errors/exceptions. Should not be defined if error is set to '*'",
- "minLength": 1
- },
- "description": {
- "type": "string",
- "description": "Error description"
- }
- },
- "required": [
- "name"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/events/eventdef.json b/api/src/main/resources/schema/events/eventdef.json
deleted file mode 100644
index a585f782..00000000
--- a/api/src/main/resources/schema/events/eventdef.json
+++ /dev/null
@@ -1,62 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.events.EventDefinition",
- "properties": {
- "name": {
- "type": "string",
- "description": "Event Definition unique name",
- "minLength": 1
- },
- "source": {
- "type": "string",
- "description": "CloudEvent source UUID"
- },
- "type": {
- "type": "string",
- "description": "CloudEvent type"
- },
- "correlation": {
- "type": "array",
- "description": "CloudEvent correlation definitions",
- "minItems": 1,
- "items": {
- "type": "object",
- "$ref": "../correlation/correlationdef.json"
- }
- },
- "dataOnly": {
- "type": "boolean",
- "default": true,
- "description": "If `true`, only the Event payload is accessible to consuming Workflow states. If `false`, both event payload and context attributes should be accessible "
- },
- "kind": {
- "type" : "string",
- "enum": ["consumed", "produced"],
- "description": "Defines the events as either being consumed or produced by the workflow. Default is consumed",
- "default": "consumed"
- },
- "metadata": {
- "$ref": "../metadata/metadata.json"
- }
- },
- "if": {
- "properties": {
- "kind": {
- "const": "consumed"
- }
- }
- },
- "then": {
- "required": [
- "name",
- "source",
- "type"
- ]
- },
- "else": {
- "required": [
- "name",
- "type"
- ]
- }
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/events/eventref.json b/api/src/main/resources/schema/events/eventref.json
deleted file mode 100644
index 76334993..00000000
--- a/api/src/main/resources/schema/events/eventref.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.events.EventRef",
- "description": "Event References",
- "properties": {
- "triggerEventRef": {
- "type": "string",
- "description": "Reference to the unique name of a 'produced' event definition"
- },
- "resultEventRef": {
- "type": "string",
- "description": "Reference to the unique name of a 'consumed' event definition"
- },
- "resultEventTimeout": {
- "type": "string",
- "description": "Maximum amount of time (ISO 8601 format) to wait for the result event. If not defined it should default to the actionExecutionTimeout"
- },
- "data": {
- "type": "string",
- "description": "Expression which selects parts of the states data output to become the data of the produced event."
- },
- "contextAttributes": {
- "existingJavaType": "java.util.Map",
- "type": "object",
- "description": "Add additional extension context attributes to the produced event"
- },
- "invoke": {
- "type": "string",
- "enum": [
- "sync",
- "async"
- ],
- "description": "Specifies if the function should be invoked sync or async. Default is sync.",
- "default": "sync"
- }
- },
- "required": [
- "triggerEventRef",
- "resultEventRef"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/events/onevents.json b/api/src/main/resources/schema/events/onevents.json
deleted file mode 100644
index 2d4ed621..00000000
--- a/api/src/main/resources/schema/events/onevents.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.events.OnEvents",
- "description": "Actions to be performed on Events arrival",
- "properties": {
- "eventRefs": {
- "type": "array",
- "description": "References one or more unique event names in the defined workflow events",
- "items": {
- "type": "object",
- "existingJavaType": "java.lang.String"
- }
- },
- "actionMode": {
- "type": "string",
- "enum": [
- "sequential",
- "parallel"
- ],
- "description": "Specifies how actions are to be performed (in sequence of parallel)",
- "default": "sequential"
- },
- "actions": {
- "type": "array",
- "description": "Actions to be performed.",
- "items": {
- "type": "object",
- "$ref": "../actions/action.json"
- }
- },
- "eventDataFilter": {
- "$ref": "../filters/eventdatafilter.json"
- }
- },
- "required": [
- "eventRefs",
- "actions"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/filters/actiondatafilter.json b/api/src/main/resources/schema/filters/actiondatafilter.json
deleted file mode 100644
index 3e6c2443..00000000
--- a/api/src/main/resources/schema/filters/actiondatafilter.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.filters.ActionDataFilter",
- "properties": {
- "fromStateData": {
- "type": "string",
- "description": "Workflow expression that selects state data that the state action can use"
- },
- "results": {
- "type": "string",
- "description": "Workflow expression that filters the actions data results"
- },
- "toStateData": {
- "type": "string",
- "description": "Workflow expression that selects a state data element to which the action results should be added/merged into. If not specified, denote, the top-level state data element"
- },
- "useResults": {
- "type": "boolean",
- "description": "If set to false, action data results are not added/merged to state data. In this case 'results' and 'toStateData' should be ignored. Default is true.",
- "default": true
- }
- },
- "required": []
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/filters/eventdatafilter.json b/api/src/main/resources/schema/filters/eventdatafilter.json
deleted file mode 100644
index b6fc25d7..00000000
--- a/api/src/main/resources/schema/filters/eventdatafilter.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.filters.EventDataFilter",
- "properties": {
- "data": {
- "type": "string",
- "description": "Workflow expression that filters of the event data (payload)"
- },
- "toStateData": {
- "type": "string",
- "description": " Workflow expression that selects a state data element to which the event payload should be added/merged into. If not specified, denotes, the top-level state data element."
- },
- "useData": {
- "type": "boolean",
- "description": "If set to false, event payload is not added/merged to state data. In this case 'data' and 'toStateData' should be ignored. Default is true.",
- "default": true
- }
- },
- "required": []
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/filters/statedatafilter.json b/api/src/main/resources/schema/filters/statedatafilter.json
deleted file mode 100644
index 0859d2d1..00000000
--- a/api/src/main/resources/schema/filters/statedatafilter.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.filters.StateDataFilter",
- "properties": {
- "input": {
- "type": "string",
- "description": "Workflow expression to filter the state data input"
- },
- "output": {
- "type": "string",
- "description": "Workflow expression that filters the state data output"
- }
- },
- "required": []
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/functions/functiondef.json b/api/src/main/resources/schema/functions/functiondef.json
deleted file mode 100644
index 9114f284..00000000
--- a/api/src/main/resources/schema/functions/functiondef.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.functions.FunctionDefinition",
- "properties": {
- "name": {
- "type": "string",
- "description": "Function unique name",
- "minLength": 1
- },
- "operation": {
- "type": "string",
- "description": "If type is `rest`, #. If type is `rpc`, ##. If type is `expression`, defines the workflow expression.",
- "minLength": 1
- },
- "type": {
- "type": "string",
- "description": "Defines the function type. Is either `rest`, `asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `rest`",
- "enum": [
- "rest",
- "asyncapi",
- "rpc",
- "graphql",
- "odata",
- "expression",
- "custom"
- ],
- "default": "rest"
- },
- "authRef": {
- "type": "string",
- "description": "References an auth definition name to be used to access to resource defined in the operation parameter",
- "minLength": 1
- },
- "metadata": {
- "$ref": "../metadata/metadata.json"
- }
- },
- "required": [
- "name"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/functions/functionref.json b/api/src/main/resources/schema/functions/functionref.json
deleted file mode 100644
index 731e6c12..00000000
--- a/api/src/main/resources/schema/functions/functionref.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.functions.FunctionRef",
- "properties": {
- "refName": {
- "type": "string",
- "description": "Name of the referenced function",
- "minLength": 1
- },
- "arguments": {
- "type": "object",
- "description": "Function arguments",
- "existingJavaType": "com.fasterxml.jackson.databind.JsonNode"
- },
- "selectionSet": {
- "type": "string",
- "description": "Only used if function type is 'graphql'. A string containing a valid GraphQL selection set"
- },
- "invoke": {
- "type": "string",
- "enum": [
- "sync",
- "async"
- ],
- "description": "Specifies if the function should be invoked sync or async. Default is sync.",
- "default": "sync"
- }
- },
- "required": [
- "refName"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/functions/subflowref.json b/api/src/main/resources/schema/functions/subflowref.json
deleted file mode 100644
index 5eca7b17..00000000
--- a/api/src/main/resources/schema/functions/subflowref.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.functions.SubFlowRef",
- "properties": {
- "workflowId": {
- "type": "string",
- "description": "Unique id of the sub-workflow to be invoked"
- },
- "version": {
- "type": "string",
- "description": "Version of the sub-workflow to be invoked",
- "minLength": 1
- },
- "onParentComplete": {
- "type": "string",
- "enum": [
- "continue",
- "terminate"
- ],
- "description": "If invoke is 'async', specifies how subflow execution should behave when parent workflow completes. Default is 'terminate'",
- "default": "terminate"
- },
- "invoke": {
- "type": "string",
- "enum": [
- "sync",
- "async"
- ],
- "description": "Specifies if the function should be invoked sync or async. Default is sync.",
- "default": "sync"
- }
- },
- "required": [
- "workflowId"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/metadata/metadata.json b/api/src/main/resources/schema/metadata/metadata.json
deleted file mode 100644
index c56687a5..00000000
--- a/api/src/main/resources/schema/metadata/metadata.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "type": "object",
- "description": "Metadata",
- "existingJavaType": "java.util.Map"
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/produce/produceevent.json b/api/src/main/resources/schema/produce/produceevent.json
deleted file mode 100644
index f094824e..00000000
--- a/api/src/main/resources/schema/produce/produceevent.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.produce.ProduceEvent",
- "properties": {
- "eventRef": {
- "type": "string",
- "description": "References a name of a defined event",
- "minLength": 1
- },
- "data": {
- "type": "string",
- "description": "Workflow expression which selects parts of the states data output to become the data of the produced event"
- },
- "contextAttributes": {
- "type": "object",
- "description": "Add additional event extension context attributes",
- "existingJavaType": "java.util.Map"
- }
- },
- "required": [
- "eventRef"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/repeat/repeat.json b/api/src/main/resources/schema/repeat/repeat.json
deleted file mode 100644
index 826b2787..00000000
--- a/api/src/main/resources/schema/repeat/repeat.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.repeat.Repeat",
- "properties": {
- "expression": {
- "type": "string",
- "description": "Expression evaluated against SubFlow state data. SubFlow will repeat execution as long as this expression is true or until the max property count is reached",
- "minLength": 1
- },
- "checkBefore": {
- "type": "boolean",
- "description": "If true, the expression is evaluated before each repeat execution, if false the expression is evaluated after each repeat execution",
- "default": true
- },
- "max": {
- "type": "integer",
- "description": "Sets the maximum amount of repeat executions",
- "minimum": 0
- },
- "continueOnError": {
- "type": "boolean",
- "description": "If true, repeats executions in a case unhandled errors propagate from the sub-workflow to this state",
- "default": false
- },
- "stopOnEvents": {
- "type" : "array",
- "description": "List referencing defined consumed workflow events. SubFlow will repeat execution until one of the defined events is consumed, or until the max property count is reached",
- "items": {
- "type": "object",
- "existingJavaType": "java.lang.String"
- }
- }
- },
- "required": [
- "nextState"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/retry/retrydef.json b/api/src/main/resources/schema/retry/retrydef.json
deleted file mode 100644
index 9d6ea91c..00000000
--- a/api/src/main/resources/schema/retry/retrydef.json
+++ /dev/null
@@ -1,43 +0,0 @@
- {
- "type": "object",
- "javaType": "io.serverlessworkflow.api.retry.RetryDefinition",
- "description": "Retry Definition",
- "properties": {
- "name": {
- "type": "string",
- "description": "Unique retry strategy name",
- "minLength": 1
- },
- "delay": {
- "type": "string",
- "description": "Time delay between retry attempts (ISO 8601 duration format)"
- },
- "maxDelay": {
- "type": "string",
- "description": "Maximum time delay between retry attempts (ISO 8601 duration format)"
- },
- "increment": {
- "type": "string",
- "description": "Static value by which the delay increases during each attempt (ISO 8601 time format)"
- },
- "multiplier": {
- "type": "string",
- "description": "Multiplier value by which interval increases during each attempt (ISO 8601 time format)"
- },
- "maxAttempts": {
- "type": "string",
- "default": "0",
- "description": "Maximum number of retry attempts. Value of 0 means no retries are performed"
- },
- "jitter": {
- "type": "string",
- "minimum": 0.0,
- "maximum": 1.0,
- "description": "Absolute maximum amount of random time added or subtracted from the delay between each retry (ISO 8601 duration format)"
- }
- },
- "required": [
- "name",
- "maxAttempts"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/schedule/schedule.json b/api/src/main/resources/schema/schedule/schedule.json
deleted file mode 100644
index c384540f..00000000
--- a/api/src/main/resources/schema/schedule/schedule.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.schedule.Schedule",
- "description": "Start state schedule definition",
- "properties": {
- "interval": {
- "type": "string",
- "description": "Time interval (ISO 8601 format) describing when the workflow starting state is active"
- },
- "cron": {
- "description": "Schedule cron definition",
- "$ref": "../cron/crondef.json"
- },
- "timezone": {
- "type": "string",
- "description": "Timezone name used to evaluate the cron expression. Not used for interval as timezone can be specified there directly. If not specified, should default to local machine timezone."
- }
- },
- "oneOf": [
- {
- "required": [
- "interval"
- ]
- },
- {
- "required": [
- "cron"
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/sleep/sleep.json b/api/src/main/resources/schema/sleep/sleep.json
deleted file mode 100644
index 94807a04..00000000
--- a/api/src/main/resources/schema/sleep/sleep.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.sleep.Sleep",
- "properties": {
- "before": {
- "type": "string",
- "description": "Amount of time (ISO 8601 duration format) to sleep before function/subflow invocation. Does not apply if 'eventRef' is defined."
- },
- "after": {
- "type": "string",
- "description": "Amount of time (ISO 8601 duration format) to sleep after function/subflow invocation. Does not apply if 'eventRef' is defined."
- }
- },
- "required": [
- "before",
- "after"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/start/start.json b/api/src/main/resources/schema/start/start.json
deleted file mode 100644
index 3f1e10ee..00000000
--- a/api/src/main/resources/schema/start/start.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.start.Start",
- "description": "State start definition",
- "properties": {
- "stateName": {
- "type": "string",
- "description": "Name of the starting workflow state",
- "minLength": 1
- },
- "schedule": {
- "description": "Define when the time/repeating intervals at which workflow instances can/should be started",
- "$ref": "../schedule/schedule.json"
- }
- },
- "required": [
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/states/callbackstate.json b/api/src/main/resources/schema/states/callbackstate.json
deleted file mode 100644
index c8a2c5a7..00000000
--- a/api/src/main/resources/schema/states/callbackstate.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.states.CallbackState",
- "javaInterfaces": [
- "io.serverlessworkflow.api.interfaces.State"
- ],
- "description": "This state is used to wait for events from event sources and then transitioning to a next state",
- "extends": {
- "$ref": "defaultstate.json"
- },
- "properties": {
- "action": {
- "description": "Defines the action to be executed",
- "$ref": "../actions/action.json"
- },
- "eventRef": {
- "type" : "string",
- "description": "References an unique callback event name in the defined workflow events"
- },
- "eventDataFilter": {
- "description": "Callback event data filter definition",
- "$ref": "../filters/eventdatafilter.json"
- },
- "usedForCompensation": {
- "type": "boolean",
- "default": false,
- "description": "If true, this state is used to compensate another state. Default is false"
- }
- },
- "required": [
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/states/defaultstate.json b/api/src/main/resources/schema/states/defaultstate.json
deleted file mode 100644
index 9e502276..00000000
--- a/api/src/main/resources/schema/states/defaultstate.json
+++ /dev/null
@@ -1,69 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.states.DefaultState",
- "javaInterfaces": [
- "io.serverlessworkflow.api.interfaces.State"
- ],
- "description": "Default State",
- "properties": {
- "id": {
- "type": "string",
- "description": "State unique identifier",
- "minLength": 1
- },
- "name": {
- "type": "string",
- "description": "Unique name of the state",
- "minLength": 1
- },
- "type": {
- "type": "string",
- "enum": [
- "event",
- "operation",
- "switch",
- "sleep",
- "parallel",
- "subflow",
- "inject",
- "foreach",
- "callback"
- ],
- "description": "State type"
- },
- "end": {
- "$ref": "../end/end.json",
- "description": "Defines this states end"
- },
- "stateDataFilter": {
- "$ref": "../filters/statedatafilter.json",
- "description": "State data filter definition"
- },
- "metadata": {
- "$ref": "../metadata/metadata.json"
- },
- "transition": {
- "$ref": "../transitions/transition.json"
- },
- "onErrors": {
- "type": "array",
- "description": "State error handling definitions",
- "items": {
- "type": "object",
- "$ref": "../error/error.json"
- }
- },
- "compensatedBy": {
- "type": "string",
- "minLength": 1,
- "description": "Unique Name of a workflow state which is responsible for compensation of this state"
- },
- "timeouts": {
- "$ref": "../timeouts/timeoutsdef.json"
- }
- },
- "required": [
- "name",
- "type"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/states/eventstate.json b/api/src/main/resources/schema/states/eventstate.json
deleted file mode 100644
index e476c2ca..00000000
--- a/api/src/main/resources/schema/states/eventstate.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.states.EventState",
- "javaInterfaces": [
- "io.serverlessworkflow.api.interfaces.State"
- ],
- "description": "This state is used to wait for events from event sources and then to invoke one or more functions to run in sequence or in parallel.",
- "extends": {
- "$ref": "defaultstate.json"
- },
- "properties": {
- "exclusive": {
- "type": "boolean",
- "default": true,
- "description": "If true consuming one of the defined events causes its associated actions to be performed. If false all of the defined events must be consumed in order for actions to be performed"
- },
- "onEvents": {
- "type": "array",
- "description": "Define what events trigger one or more actions to be performed",
- "items": {
- "type": "object",
- "$ref": "../events/onevents.json"
- }
- }
- },
- "required": [
- "onevents"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/states/foreachstate.json b/api/src/main/resources/schema/states/foreachstate.json
deleted file mode 100644
index 06c0807f..00000000
--- a/api/src/main/resources/schema/states/foreachstate.json
+++ /dev/null
@@ -1,135 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.states.ForEachState",
- "javaInterfaces": [
- "io.serverlessworkflow.api.interfaces.State"
- ],
- "description": "Execute a set of defined actions or workflows for each element of a data array",
- "extends": {
- "$ref": "defaultstate.json"
- },
- "properties": {
- "inputCollection": {
- "type": "string",
- "description": "Workflow expression selecting an array element of the states data"
- },
- "outputCollection": {
- "type": "string",
- "description": "Workflow expression specifying an array element of the states data to add the results of each iteration"
- },
- "iterationParam": {
- "type": "string",
- "description": "Name of the iteration parameter that can be referenced in actions/workflow. For each parallel iteration, this param should contain an unique element of the inputCollection array"
- },
- "batchSize": {
- "type": "integer",
- "default": "0",
- "minimum": 0,
- "description": "Specifies how many iterations may run in parallel at the same time. Used if 'mode' property is set to 'parallel' (default)"
- },
- "actions": {
- "type": "array",
- "description": "Actions to be executed for each of the elements of inputCollection",
- "items": {
- "type": "object",
- "$ref": "../actions/action.json"
- }
- },
- "usedForCompensation": {
- "type": "boolean",
- "default": false,
- "description": "If true, this state is used to compensate another state. Default is false"
- },
- "mode": {
- "type": "string",
- "enum": [
- "sequential",
- "parallel"
- ],
- "description": "Specifies how iterations are to be performed (sequentially or in parallel)",
- "default": "parallel"
- }
- },
- "oneOf": [
- {
- "required": [
- "name",
- "type",
- "inputCollection",
- "inputParameter",
- "end"
- ]
- },
- {
- "required": [
- "name",
- "type",
- "inputCollection",
- "inputParameter",
- "transition"
- ]
- },
- {
- "required": [
- "start",
- "name",
- "type",
- "inputCollection",
- "inputParameter",
- "end"
- ]
- },
- {
- "required": [
- "start",
- "name",
- "type",
- "inputCollection",
- "inputParameter",
- "transition"
- ]
- },
- {
- "required": [
- "name",
- "type",
- "inputCollection",
- "inputParameter",
- "actions",
- "end"
- ]
- },
- {
- "required": [
- "name",
- "type",
- "inputCollection",
- "inputParameter",
- "actions",
- "transition"
- ]
- },
- {
- "required": [
- "start",
- "name",
- "type",
- "inputCollection",
- "inputParameter",
- "actions",
- "end"
- ]
- },
- {
- "required": [
- "start",
- "name",
- "type",
- "inputCollection",
- "inputParameter",
- "actions",
- "transition"
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/states/injectstate.json b/api/src/main/resources/schema/states/injectstate.json
deleted file mode 100644
index d0d10589..00000000
--- a/api/src/main/resources/schema/states/injectstate.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.states.InjectState",
- "javaInterfaces": [
- "io.serverlessworkflow.api.interfaces.State"
- ],
- "description": "Set up and inject the state's data input to data output. Does not perform any actions",
- "extends": {
- "$ref": "defaultstate.json"
- },
- "properties": {
- "data": {
- "type": "object",
- "description": "JSON object which can be set as states data input and can be manipulated via filters",
- "existingJavaType": "com.fasterxml.jackson.databind.JsonNode"
- },
- "usedForCompensation": {
- "type": "boolean",
- "default": false,
- "description": "If true, this state is used to compensate another state. Default is false"
- }
- },
- "required": [
- "inject"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/states/operationstate.json b/api/src/main/resources/schema/states/operationstate.json
deleted file mode 100644
index 8d8211a9..00000000
--- a/api/src/main/resources/schema/states/operationstate.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.states.OperationState",
- "javaInterfaces": [
- "io.serverlessworkflow.api.interfaces.State"
- ],
- "description": "This state allows one or more functions to run in sequence or in parallel without waiting for any event.",
- "extends": {
- "$ref": "defaultstate.json"
- },
- "properties": {
- "actionMode": {
- "type": "string",
- "enum": [
- "sequential",
- "parallel"
- ],
- "description": "Specifies whether functions are executed in sequence or in parallel."
- },
- "actions": {
- "type": "array",
- "description": "Actions Definitions",
- "items": {
- "type": "object",
- "$ref": "../actions/action.json"
- }
- },
- "usedForCompensation": {
- "type": "boolean",
- "default": false,
- "description": "If true, this state is used to compensate another state. Default is false"
- }
- },
- "required": [
- "name",
- "actionMode",
- "actions"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/states/parallelstate.json b/api/src/main/resources/schema/states/parallelstate.json
deleted file mode 100644
index 919c472f..00000000
--- a/api/src/main/resources/schema/states/parallelstate.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.states.ParallelState",
- "javaInterfaces": [
- "io.serverlessworkflow.api.interfaces.State"
- ],
- "description": "Consists of a number of states that are executed in parallel",
- "extends": {
- "$ref": "defaultstate.json"
- },
- "properties": {
- "branches": {
- "type": "array",
- "description": "Branch Definitions",
- "items": {
- "type": "object",
- "$ref": "../branches/branch.json"
- }
- },
- "completionType": {
- "type" : "string",
- "enum": ["allOf", "atLeast"],
- "description": "Option types on how to complete branch execution.",
- "default": "allOf"
- },
- "numCompleted": {
- "type": "string",
- "default": "0",
- "description": "Used when completionType is set to 'atLeast' to specify the minimum number of branches that must complete before the state will transition."
- },
- "usedForCompensation": {
- "type": "boolean",
- "default": false,
- "description": "If true, this state is used to compensate another state. Default is false"
- }
- },
- "required": [
- "branches"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/states/sleepstate.json b/api/src/main/resources/schema/states/sleepstate.json
deleted file mode 100644
index d0d3ade7..00000000
--- a/api/src/main/resources/schema/states/sleepstate.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.states.SleepState",
- "javaInterfaces": [
- "io.serverlessworkflow.api.interfaces.State"
- ],
- "description": "This state is used to wait for events from event sources and then transitioning to a next state",
- "extends": {
- "$ref": "defaultstate.json"
- },
- "properties": {
- "duration": {
- "type": "string",
- "description": "Duration (ISO 8601 duration format) to sleep"
- },
- "usedForCompensation": {
- "type": "boolean",
- "default": false,
- "description": "If true, this state is used to compensate another state. Default is false"
- }
- },
- "required": [
- "duration"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/states/switchstate.json b/api/src/main/resources/schema/states/switchstate.json
deleted file mode 100644
index 7634c512..00000000
--- a/api/src/main/resources/schema/states/switchstate.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.states.SwitchState",
- "javaInterfaces": [
- "io.serverlessworkflow.api.interfaces.State"
- ],
- "description": "Permits transitions to other states based on criteria matching",
- "extends": {
- "$ref": "defaultstate.json"
- },
- "properties": {
- "eventConditions": {
- "type": "array",
- "description": "Defines conditions evaluated against events",
- "items": {
- "type": "object",
- "$ref": "../switchconditions/eventcondition.json"
- }
- },
- "dataConditions": {
- "type": "array",
- "description": "Defines conditions evaluated against state data",
- "items": {
- "type": "object",
- "$ref": "../switchconditions/datacondition.json"
- }
- },
- "defaultCondition": {
- "description": "Default transition of the workflow if there is no matching data conditions. Can include a transition or end definition",
- "$ref": "../defaultcondition/defaultconditiondef.json"
- },
- "usedForCompensation": {
- "type": "boolean",
- "default": false,
- "description": "If true, this state is used to compensate another state. Default is false"
- }
- },
- "required": [
- "defaultCondition"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/switchconditions/datacondition.json b/api/src/main/resources/schema/switchconditions/datacondition.json
deleted file mode 100644
index e72db3d3..00000000
--- a/api/src/main/resources/schema/switchconditions/datacondition.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.switchconditions.DataCondition",
- "javaInterfaces": [
- "io.serverlessworkflow.api.interfaces.SwitchCondition"
- ],
- "description": "Switch state data based condition",
- "properties": {
- "name": {
- "type": "string",
- "description": "Data condition name"
- },
- "condition": {
- "type": "string",
- "description": "Workflow expression evaluated against state data. True if results are not empty"
- },
- "transition": {
- "$ref": "../transitions/transition.json",
- "description": "Next transition of the workflow if there is valid matches"
- },
- "end": {
- "$ref": "../end/end.json",
- "description": "Workflow end definition"
- }
- },
- "oneOf": [
- {
- "required": [
- "condition",
- "transition"
- ]
- },
- {
- "required": [
- "condition",
- "end"
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/switchconditions/eventcondition.json b/api/src/main/resources/schema/switchconditions/eventcondition.json
deleted file mode 100644
index 887a96f7..00000000
--- a/api/src/main/resources/schema/switchconditions/eventcondition.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.switchconditions.EventCondition",
- "javaInterfaces": ["io.serverlessworkflow.api.interfaces.SwitchCondition"],
- "description": "Switch state data event condition",
- "properties": {
- "name": {
- "type": "string",
- "description": "Event condition name"
- },
- "eventRef": {
- "type" : "string",
- "description": "References an unique event name in the defined workflow events"
- },
- "eventDataFilter": {
- "description": "Callback event data filter definition",
- "$ref": "../filters/eventdatafilter.json"
- },
- "transition": {
- "$ref": "../transitions/transition.json",
- "description": "Next transition of the workflow if there is valid matches"
- },
- "end": {
- "$ref": "../end/end.json",
- "description": "Workflow end definition"
- }
- },
- "required": [
- "eventRef",
- "transition"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/timeouts/stateexectimeout.json b/api/src/main/resources/schema/timeouts/stateexectimeout.json
deleted file mode 100644
index 68f237e9..00000000
--- a/api/src/main/resources/schema/timeouts/stateexectimeout.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.timeouts.StateExecTimeout",
- "properties": {
- "single": {
- "type": "string",
- "description": "Single state execution timeout, not including retries (ISO 8601 duration format)",
- "minLength": 1
- },
- "total": {
- "type": "string",
- "description": "Total state execution timeout, including retries (ISO 8601 duration format)",
- "minLength": 1
- }
- },
- "required": [
- "total"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/timeouts/timeoutsdef.json b/api/src/main/resources/schema/timeouts/timeoutsdef.json
deleted file mode 100644
index 322c386e..00000000
--- a/api/src/main/resources/schema/timeouts/timeoutsdef.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.timeouts.TimeoutsDefinition",
- "description": "Timeouts Definition",
- "properties": {
- "workflowExecTimeout": {
- "$ref": "workflowexectimeout.json"
- },
- "stateExecTimeout": {
- "$ref": "stateexectimeout.json"
- },
- "actionExecTimeout": {
- "type": "string",
- "description": "Single actions definition execution timeout duration (ISO 8601 duration format)",
- "minLength": 1
- },
- "branchExecTimeout": {
- "type": "string",
- "description": "Single branch execution timeout duration (ISO 8601 duration format)",
- "minLength": 1
- },
- "eventTimeout": {
- "type": "string",
- "description": "Timeout duration to wait for consuming defined events (ISO 8601 duration format)",
- "minLength": 1
- }
- },
- "required": []
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/timeouts/workflowexectimeout.json b/api/src/main/resources/schema/timeouts/workflowexectimeout.json
deleted file mode 100644
index 9010b1e4..00000000
--- a/api/src/main/resources/schema/timeouts/workflowexectimeout.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.timeouts.WorkflowExecTimeout",
- "properties": {
- "duration": {
- "type": "string",
- "description": "Workflow execution timeout duration (ISO 8601 duration format). If not specified should be 'unlimited'",
- "minLength": 1
- },
- "interrupt": {
- "type": "boolean",
- "description": "If `false`, workflow instance is allowed to finish current execution. If `true`, current workflow execution is abrupted.",
- "default": true
- },
- "runBefore": {
- "type": "string",
- "description": "Name of a workflow state to be executed before workflow instance is terminated",
- "minLength": 1
- }
- },
- "required": [
- "duration"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/transitions/transition.json b/api/src/main/resources/schema/transitions/transition.json
deleted file mode 100644
index c540089f..00000000
--- a/api/src/main/resources/schema/transitions/transition.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "type": "object",
- "javaType": "io.serverlessworkflow.api.transitions.Transition",
- "properties": {
- "produceEvents": {
- "type": "array",
- "description": "Array of events to be produced",
- "items": {
- "type": "object",
- "$ref": "../produce/produceevent.json"
- }
- },
- "nextState": {
- "type": "string",
- "description": "State to transition to next",
- "minLength": 1
- },
- "compensate": {
- "type": "boolean",
- "default": false,
- "description": "If set to true, triggers workflow compensation before this transition is taken. Default is false"
- }
- },
- "required": [
- "nextState"
- ]
-}
\ No newline at end of file
diff --git a/api/src/main/resources/schema/workflow.json b/api/src/main/resources/schema/workflow.json
deleted file mode 100644
index aa53061d..00000000
--- a/api/src/main/resources/schema/workflow.json
+++ /dev/null
@@ -1,174 +0,0 @@
-{
- "$id": "classpath:schema/workflow.schema.json",
- "$schema": "http://json-schema.org/draft-07/schema#",
- "description": "Serverless Workflow is a vendor-neutral specification for defining the model of workflows responsible for orchestrating event-driven serverless applications.",
- "type": "object",
- "extendsJavaClass": "io.serverlessworkflow.api.workflow.BaseWorkflow",
- "javaType": "io.serverlessworkflow.api.Workflow",
- "javaInterfaces": [
- "java.io.Serializable"
- ],
- "properties": {
- "id": {
- "type": "string",
- "description": "Workflow unique identifier",
- "minLength": 1
- },
- "key": {
- "type": "string",
- "description": "Workflow Domain-specific identifier"
- },
- "name": {
- "type": "string",
- "description": "Workflow name",
- "minLength": 1
- },
- "description": {
- "type": "string",
- "description": "Workflow description"
- },
- "version": {
- "type": "string",
- "description": "Workflow version"
- },
- "annotations": {
- "type": "array",
- "description": "List of helpful terms describing the workflows intended purpose, subject areas, or other important qualities",
- "minItems": 1,
- "items": {
- "type": "string"
- }
- },
- "dataInputSchema": {
- "type": "object",
- "existingJavaType": "io.serverlessworkflow.api.workflow.DataInputSchema",
- "description": "Workflow data input schema"
- },
- "start": {
- "$ref": "start/start.json",
- "description": "Defines workflow start"
- },
- "specVersion": {
- "type": "string",
- "description": "Serverless Workflow schema version"
- },
- "expressionLang": {
- "type": "string",
- "description": "Identifies the expression language used for workflow expressions. Default is 'jq'",
- "default": "jq",
- "minLength": 1
- },
- "keepActive": {
- "type": "boolean",
- "default": false,
- "description": "If 'true', workflow instances is not terminated when there are no active execution paths. Instance can be terminated via 'terminate end definition' or reaching defined 'execTimeout'"
- },
- "autoRetries": {
- "type": "boolean",
- "default": false,
- "description": "If set to true, actions should automatically be retried on unchecked errors. Default is false"
- },
- "metadata": {
- "$ref": "metadata/metadata.json"
- },
- "events": {
- "type": "object",
- "existingJavaType": "io.serverlessworkflow.api.workflow.Events",
- "description": "Workflow event definitions"
- },
- "functions": {
- "type": "object",
- "existingJavaType": "io.serverlessworkflow.api.workflow.Functions",
- "description": "Workflow function definitions"
- },
- "errors": {
- "type": "object",
- "existingJavaType": "io.serverlessworkflow.api.workflow.Errors",
- "description": "Workflow error definitions"
- },
- "retries": {
- "type": "object",
- "existingJavaType": "io.serverlessworkflow.api.workflow.Retries",
- "description": "Workflow retry definitions"
- },
- "secrets": {
- "type": "object",
- "existingJavaType": "io.serverlessworkflow.api.workflow.Secrets",
- "description": "Workflow secrets definitions"
- },
- "constants": {
- "type": "object",
- "existingJavaType": "io.serverlessworkflow.api.workflow.Constants",
- "description": "Workflow constants definitions"
- },
- "timeouts": {
- "$ref": "timeouts/timeoutsdef.json"
- },
- "auth": {
- "type": "object",
- "existingJavaType": "io.serverlessworkflow.api.workflow.Auth",
- "description": "Workflow Auth definitions"
- },
- "states": {
- "type": "array",
- "description": "State Definitions",
- "items": {
- "type": "object",
- "existingJavaType": "io.serverlessworkflow.api.interfaces.State",
- "anyOf": [
- {
- "title": "Sleep State",
- "$ref": "states/sleepstate.json"
- },
- {
- "title": "Event State",
- "$ref": "states/eventstate.json"
- },
- {
- "title": "Operation State",
- "$ref": "states/operationstate.json"
- },
- {
- "title": "Parallel State",
- "$ref": "states/parallelstate.json"
- },
- {
- "title": "Switch State",
- "$ref": "states/switchstate.json"
- },
- {
- "title": "Relay State",
- "$ref": "states/injectstate.json"
- },
- {
- "title": "ForEach State",
- "$ref": "states/foreachstate.json"
- },
- {
- "title": "Callback State",
- "$ref": "states/callbackstate.json"
- }
- ]
- }
- },
- "extensions": {
- "type": "array",
- "description": "Workflow Extensions",
- "items": {
- "type": "object",
- "existingJavaType": "io.serverlessworkflow.api.interfaces.Extension"
- }
- }
- },
- "required": [
- "id",
- "name",
- "version",
- "states"
- ],
- "dependencies":
- {
- "id": { "not": { "required": ["key"] } },
- "key": { "not": { "required": ["id"] } }
- }
-}
diff --git a/api/src/main/resources/schema/workflow.yaml b/api/src/main/resources/schema/workflow.yaml
new file mode 100644
index 00000000..d3a20f2f
--- /dev/null
+++ b/api/src/main/resources/schema/workflow.yaml
@@ -0,0 +1,1000 @@
+$id: https://serverlessworkflow.io/schemas/1.0.0-alpha1/workflow.yaml
+$schema: https://json-schema.org/draft/2020-12/schema
+description: Serverless Workflow DSL - Workflow Schema
+type: object
+properties:
+ document:
+ type: object
+ properties:
+ dsl:
+ type: string
+ pattern: ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
+ description: The version of the DSL used by the workflow.
+ namespace:
+ type: string
+ pattern: ^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$
+ description: The workflow's namespace.
+ name:
+ type: string
+ pattern: ^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$
+ description: The workflow's name.
+ version:
+ type: string
+ pattern: ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
+ description: The workflow's semantic version.
+ title:
+ type: string
+ description: The workflow's title.
+ summary:
+ type: string
+ description: The workflow's Markdown summary.
+ tags:
+ type: object
+ description: A key/value mapping of the workflow's tags, if any.
+ additionalProperties: true
+ required: [ dsl, namespace, name, version ]
+ description: Documents the workflow
+ input:
+ $ref: '#/$defs/input'
+ description: Configures the workflow's input.
+ use:
+ type: object
+ properties:
+ authentications:
+ type: object
+ additionalProperties:
+ $ref: '#/$defs/authenticationPolicy'
+ description: The workflow's reusable authentication policies.
+ errors:
+ type: object
+ additionalProperties:
+ $ref: '#/$defs/error'
+ description: The workflow's reusable errors.
+ extensions:
+ type: array
+ items:
+ type: object
+ title: ExtensionItem
+ minProperties: 1
+ maxProperties: 1
+ additionalProperties:
+ $ref: '#/$defs/extension'
+ description: The workflow's extensions.
+ functions:
+ type: object
+ additionalProperties:
+ $ref: '#/$defs/task'
+ description: The workflow's reusable functions.
+ retries:
+ type: object
+ additionalProperties:
+ $ref: '#/$defs/retryPolicy'
+ description: The workflow's reusable retry policies.
+ secrets:
+ type: array
+ items:
+ type: string
+ description: The workflow's secrets.
+ description: Defines the workflow's reusable components.
+ do:
+ description: Defines the task(s) the workflow must perform
+ $ref: '#/$defs/taskList'
+ timeout:
+ $ref: '#/$defs/timeout'
+ description: The workflow's timeout configuration, if any.
+ output:
+ $ref: '#/$defs/output'
+ description: Configures the workflow's output.
+ schedule:
+ type: object
+ properties:
+ every:
+ $ref: '#/$defs/duration'
+ description: Specifies the duration of the interval at which the workflow should be executed.
+ cron:
+ type: string
+ description: Specifies the schedule using a cron expression, e.g., '0 0 * * *' for daily at midnight."
+ after:
+ $ref: '#/$defs/duration'
+ description: Specifies a delay duration that the workflow must wait before starting again after it completes.
+ on:
+ $ref: '#/$defs/eventConsumptionStrategy'
+ description: Specifies the events that trigger the workflow execution.
+ description: Schedules the workflow
+$defs:
+ taskList:
+ type: array
+ items:
+ type: object
+ title: TaskItem
+ minProperties: 1
+ maxProperties: 1
+ additionalProperties:
+ $ref: '#/$defs/task'
+ taskBase:
+ type: object
+ properties:
+ if:
+ type: string
+ description: A runtime expression, if any, used to determine whether or not the task should be run.
+ input:
+ $ref: '#/$defs/input'
+ description: Configure the task's input.
+ output:
+ $ref: '#/$defs/output'
+ description: Configure the task's output.
+ export:
+ $ref: '#/$defs/export'
+ description: Export task output to context.
+ timeout:
+ $ref: '#/$defs/timeout'
+ description: The task's timeout configuration, if any.
+ then:
+ $ref: '#/$defs/flowDirective'
+ description: The flow directive to be performed upon completion of the task.
+ task:
+ unevaluatedProperties: false
+ oneOf:
+ - $ref: '#/$defs/callTask'
+ - $ref: '#/$defs/doTask'
+ - $ref: '#/$defs/forkTask'
+ - $ref: '#/$defs/emitTask'
+ - $ref: '#/$defs/forTask'
+ - $ref: '#/$defs/listenTask'
+ - $ref: '#/$defs/raiseTask'
+ - $ref: '#/$defs/runTask'
+ - $ref: '#/$defs/setTask'
+ - $ref: '#/$defs/switchTask'
+ - $ref: '#/$defs/tryTask'
+ - $ref: '#/$defs/waitTask'
+ callTask:
+ oneOf:
+ - title: CallAsyncAPI
+ $ref: '#/$defs/taskBase'
+ type: object
+ required: [ call, with ]
+ unevaluatedProperties: false
+ properties:
+ call:
+ type: string
+ const: asyncapi
+ with:
+ title: WithAsyncAPI
+ type: object
+ properties:
+ document:
+ $ref: '#/$defs/externalResource'
+ description: The document that defines the AsyncAPI operation to call.
+ operationRef:
+ type: string
+ description: A reference to the AsyncAPI operation to call.
+ server:
+ type: string
+ description: A a reference to the server to call the specified AsyncAPI operation on. If not set, default to the first server matching the operation's channel.
+ message:
+ type: string
+ description: The name of the message to use. If not set, defaults to the first message defined by the operation.
+ binding:
+ type: string
+ description: The name of the binding to use. If not set, defaults to the first binding defined by the operation.
+ payload:
+ type: object
+ description: The payload to call the AsyncAPI operation with, if any.
+ authentication:
+ description: The authentication policy, if any, to use when calling the AsyncAPI operation.
+ oneOf:
+ - $ref: '#/$defs/authenticationPolicy'
+ - type: string
+ required: [ document, operationRef ]
+ additionalProperties: false
+ description: Defines the AsyncAPI call to perform.
+ - title: CallGRPC
+ $ref: '#/$defs/taskBase'
+ type: object
+ unevaluatedProperties: false
+ required: [ call, with ]
+ properties:
+ call:
+ type: string
+ const: grpc
+ with:
+ title: WithGRPC
+ type: object
+ properties:
+ proto:
+ $ref: '#/$defs/externalResource'
+ description: The proto resource that describes the GRPC service to call.
+ service:
+ type: object
+ properties:
+ name:
+ type: string
+ description: The name of the GRPC service to call.
+ host:
+ type: string
+ pattern: ^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$
+ description: The hostname of the GRPC service to call.
+ port:
+ type: integer
+ min: 0
+ max: 65535
+ description: The port number of the GRPC service to call.
+ authentication:
+ description: The endpoint's authentication policy, if any.
+ oneOf:
+ - $ref: '#/$defs/authenticationPolicy'
+ - type: string
+ required: [ name, host ]
+ method:
+ type: string
+ description: The name of the method to call on the defined GRPC service.
+ arguments:
+ type: object
+ additionalProperties: true
+ description: The arguments, if any, to call the method with.
+ required: [ proto, service, method ]
+ additionalProperties: false
+ description: Defines the GRPC call to perform.
+ - title: CallHTTP
+ $ref: '#/$defs/taskBase'
+ type: object
+ unevaluatedProperties: false
+ required: [ call, with ]
+ properties:
+ call:
+ type: string
+ const: http
+ with:
+ title: WithHTTP
+ type: object
+ properties:
+ method:
+ type: string
+ description: The HTTP method of the HTTP request to perform.
+ endpoint:
+ description: The HTTP endpoint to send the request to.
+ oneOf:
+ - $ref: '#/$defs/endpoint'
+ - type: string
+ format: uri-template
+ headers:
+ type: object
+ description: A name/value mapping of the headers, if any, of the HTTP request to perform.
+ body:
+ description: The body, if any, of the HTTP request to perform.
+ output:
+ type: string
+ enum: [ raw, content, response ]
+ description: The http call output format. Defaults to 'content'.
+ required: [ method, endpoint ]
+ additionalProperties: false
+ description: Defines the HTTP call to perform.
+ - title: CallOpenAPI
+ $ref: '#/$defs/taskBase'
+ type: object
+ unevaluatedProperties: false
+ required: [ call, with ]
+ properties:
+ call:
+ type: string
+ const: openapi
+ with:
+ title: WithOpenAPI
+ type: object
+ properties:
+ document:
+ $ref: '#/$defs/externalResource'
+ description: The document that defines the OpenAPI operation to call.
+ operationId:
+ type: string
+ description: The id of the OpenAPI operation to call.
+ parameters:
+ type: object
+ additionalProperties: true
+ description: A name/value mapping of the parameters of the OpenAPI operation to call.
+ authentication:
+ description: The authentication policy, if any, to use when calling the OpenAPI operation.
+ oneOf:
+ - $ref: '#/$defs/authenticationPolicy'
+ - type: string
+ output:
+ type: string
+ enum: [ raw, content, response ]
+ description: The http call output format. Defaults to 'content'.
+ required: [ document, operationId ]
+ additionalProperties: false
+ description: Defines the OpenAPI call to perform.
+ - title: CallFunction
+ $ref: '#/$defs/taskBase'
+ type: object
+ unevaluatedProperties: false
+ required: [ call ]
+ properties:
+ call:
+ type: string
+ not:
+ enum: ["asyncapi", "grpc", "http", "openapi"]
+ description: The name of the function to call.
+ with:
+ type: object
+ additionalProperties: true
+ description: A name/value mapping of the parameters, if any, to call the function with.
+ forkTask:
+ description: Allows workflows to execute multiple tasks concurrently and optionally race them against each other, with a single possible winner, which sets the task's output.
+ $ref: '#/$defs/taskBase'
+ type: object
+ unevaluatedProperties: false
+ required: [ fork ]
+ properties:
+ fork:
+ type: object
+ required: [ branches ]
+ properties:
+ branches:
+ $ref: '#/$defs/taskList'
+ compete:
+ description: Indicates whether or not the concurrent tasks are racing against each other, with a single possible winner, which sets the composite task's output.
+ type: boolean
+ default: false
+ doTask:
+ description: Allows to execute a list of tasks in sequence
+ $ref: '#/$defs/taskBase'
+ type: object
+ unevaluatedProperties: false
+ required: [ do ]
+ properties:
+ do:
+ $ref: '#/$defs/taskList'
+ emitTask:
+ description: Allows workflows to publish events to event brokers or messaging systems, facilitating communication and coordination between different components and services.
+ $ref: '#/$defs/taskBase'
+ type: object
+ required: [ emit ]
+ unevaluatedProperties: false
+ properties:
+ emit:
+ type: object
+ properties:
+ event:
+ type: object
+ properties:
+ id:
+ type: string
+ description: The event's unique identifier
+ source:
+ type: string
+ format: uri
+ description: Identifies the context in which an event happened
+ type:
+ type: string
+ description: This attribute contains a value describing the type of event related to the originating occurrence.
+ time:
+ type: string
+ format: date-time
+ subject:
+ type: string
+ datacontenttype:
+ type: string
+ description: Content type of data value. This attribute enables data to carry any type of content, whereby format and encoding might differ from that of the chosen event format.
+ dataschema:
+ type: string
+ format: uri
+ required: [ source, type ]
+ additionalProperties: true
+ required: [ event ]
+ forTask:
+ description: Allows workflows to iterate over a collection of items, executing a defined set of subtasks for each item in the collection. This task type is instrumental in handling scenarios such as batch processing, data transformation, and repetitive operations across datasets.
+ $ref: '#/$defs/taskBase'
+ type: object
+ required: [ for, do ]
+ unevaluatedProperties: false
+ properties:
+ for:
+ type: object
+ properties:
+ each:
+ type: string
+ description: The name of the variable used to store the current item being enumerated.
+ default: item
+ in:
+ type: string
+ description: A runtime expression used to get the collection to enumerate.
+ at:
+ type: string
+ description: The name of the variable used to store the index of the current item being enumerated.
+ default: index
+ required: [ in ]
+ while:
+ type: string
+ description: A runtime expression that represents the condition, if any, that must be met for the iteration to continue.
+ do:
+ $ref: '#/$defs/taskList'
+ listenTask:
+ description: Provides a mechanism for workflows to await and react to external events, enabling event-driven behavior within workflow systems.
+ $ref: '#/$defs/taskBase'
+ type: object
+ required: [ listen ]
+ unevaluatedProperties: false
+ properties:
+ listen:
+ type: object
+ properties:
+ to:
+ $ref: '#/$defs/eventConsumptionStrategy'
+ description: Defines the event(s) to listen to.
+ required: [ to ]
+ raiseTask:
+ description: Intentionally triggers and propagates errors.
+ $ref: '#/$defs/taskBase'
+ type: object
+ required: [ raise ]
+ unevaluatedProperties: false
+ properties:
+ raise:
+ type: object
+ properties:
+ error:
+ $ref: '#/$defs/error'
+ description: Defines the error to raise.
+ required: [ error ]
+ runTask:
+ description: Provides the capability to execute external containers, shell commands, scripts, or workflows.
+ $ref: '#/$defs/taskBase'
+ type: object
+ required: [ run ]
+ unevaluatedProperties: false
+ properties:
+ run:
+ type: object
+ oneOf:
+ - title: RunContainer
+ properties:
+ container:
+ type: object
+ properties:
+ image:
+ type: string
+ description: The name of the container image to run.
+ command:
+ type: string
+ description: The command, if any, to execute on the container
+ ports:
+ type: object
+ description: The container's port mappings, if any.
+ volumes:
+ type: object
+ description: The container's volume mappings, if any.
+ environment:
+ title: ContainerEnvironment
+ type: object
+ description: A key/value mapping of the environment variables, if any, to use when running the configured process.
+ required: [ image ]
+ required: [ container ]
+ description: Enables the execution of external processes encapsulated within a containerized environment.
+ - title: RunScript
+ properties:
+ script:
+ type: object
+ properties:
+ language:
+ type: string
+ description: The language of the script to run.
+ environment:
+ title: ScriptEnvironment
+ type: object
+ additionalProperties: true
+ description: A key/value mapping of the environment variables, if any, to use when running the configured process.
+ oneOf:
+ - title: ScriptInline
+ properties:
+ code:
+ type: string
+ required: [ code ]
+ description: The script's code.
+ - title: ScriptExternal
+ properties:
+ source:
+ $ref: '#/$defs/externalResource'
+ description: The script's resource.
+ required: [ source ]
+ required: [ language ]
+ required: [ script ]
+ description: Enables the execution of custom scripts or code within a workflow, empowering workflows to perform specialized logic, data processing, or integration tasks by executing user-defined scripts written in various programming languages.
+ - title: RunShell
+ properties:
+ shell:
+ type: object
+ properties:
+ command:
+ type: string
+ description: The shell command to run.
+ arguments:
+ title: ShellArguments
+ type: object
+ additionalProperties: true
+ description: A list of the arguments of the shell command to run.
+ environment:
+ title: ShellEnvironment
+ type: object
+ additionalProperties: true
+ description: A key/value mapping of the environment variables, if any, to use when running the configured process.
+ required: [ command ]
+ required: [ shell ]
+ description: Enables the execution of shell commands within a workflow, enabling workflows to interact with the underlying operating system and perform system-level operations, such as file manipulation, environment configuration, or system administration tasks.
+ - title: RunWokflow
+ properties:
+ workflow:
+ title: RunWorkflowDescriptor
+ type: object
+ properties:
+ namespace:
+ type: string
+ description: The namespace the workflow to run belongs to.
+ name:
+ type: string
+ description: The name of the workflow to run.
+ version:
+ type: string
+ default: latest
+ description: The version of the workflow to run. Defaults to latest
+ input:
+ title: WorkflowInput
+ type: object
+ additionalProperties: true
+ description: The data, if any, to pass as input to the workflow to execute. The value should be validated against the target workflow's input schema, if specified.
+ required: [ namespace, name, version ]
+ required: [ workflow ]
+ description: Enables the invocation and execution of nested workflows within a parent workflow, facilitating modularization, reusability, and abstraction of complex logic or business processes by encapsulating them into standalone workflow units.
+ setTask:
+ description: A task used to set data
+ $ref: '#/$defs/taskBase'
+ type: object
+ required: [ set ]
+ unevaluatedProperties: false
+ properties:
+ set:
+ type: object
+ minProperties: 1
+ additionalProperties: true
+ description: The data to set
+ switchTask:
+ description: Enables conditional branching within workflows, allowing them to dynamically select different paths based on specified conditions or criteria
+ $ref: '#/$defs/taskBase'
+ type: object
+ required: [ switch ]
+ unevaluatedProperties: false
+ properties:
+ switch:
+ type: array
+ minItems: 1
+ items:
+ type: object
+ minProperties: 1
+ maxProperties: 1
+ additionalProperties:
+ type: object
+ properties:
+ name:
+ type: string
+ description: The case's name.
+ when:
+ type: string
+ description: A runtime expression used to determine whether or not the case matches.
+ then:
+ $ref: '#/$defs/flowDirective'
+ description: The flow directive to execute when the case matches.
+ tryTask:
+ description: Serves as a mechanism within workflows to handle errors gracefully, potentially retrying failed tasks before proceeding with alternate ones.
+ $ref: '#/$defs/taskBase'
+ type: object
+ required: [ try, catch ]
+ unevaluatedProperties: false
+ properties:
+ try:
+ description: The task(s) to perform.
+ $ref: '#/$defs/taskList'
+ catch:
+ type: object
+ properties:
+ errors:
+ title: CatchErrors
+ type: object
+ as:
+ type: string
+ description: The name of the runtime expression variable to save the error as. Defaults to 'error'.
+ when:
+ type: string
+ description: A runtime expression used to determine whether or not to catch the filtered error
+ exceptWhen:
+ type: string
+ description: A runtime expression used to determine whether or not to catch the filtered error
+ retry:
+ $ref: '#/$defs/retryPolicy'
+ description: The retry policy to use, if any, when catching errors.
+ do:
+ description: The definition of the task(s) to run when catching an error.
+ $ref: '#/$defs/taskList'
+ waitTask:
+ description: Allows workflows to pause or delay their execution for a specified period of time.
+ $ref: '#/$defs/taskBase'
+ type: object
+ required: [ wait ]
+ unevaluatedProperties: false
+ properties:
+ wait:
+ description: The amount of time to wait.
+ $ref: '#/$defs/duration'
+ flowDirective:
+ additionalProperties: false
+ anyOf:
+ - type: string
+ enum: [ continue, exit, end ]
+ default: continue
+ - type: string
+ authenticationPolicy:
+ type: object
+ oneOf:
+ - title: BasicAuthenticationPolicy
+ properties:
+ basic:
+ type: object
+ properties:
+ username:
+ type: string
+ description: The username to use.
+ password:
+ type: string
+ description: The password to use.
+ required: [ username, password ]
+ required: [ basic ]
+ description: Use basic authentication.
+ - title: BearerAuthenticationPolicy
+ properties:
+ bearer:
+ type: object
+ properties:
+ token:
+ type: string
+ description: The bearer token to use.
+ required: [ token ]
+ required: [ bearer ]
+ description: Use bearer authentication.
+ - title: OAuth2AuthenticationPolicy
+ properties:
+ oauth2:
+ type: object
+ properties:
+ authority:
+ type: string
+ format: uri
+ description: The URI that references the OAuth2 authority to use.
+ grant:
+ type: string
+ description: The grant type to use.
+ client:
+ type: object
+ properties:
+ id:
+ type: string
+ description: The client id to use.
+ secret:
+ type: string
+ description: The client secret to use, if any.
+ required: [ id ]
+ scopes:
+ type: array
+ items:
+ type: string
+ description: The scopes, if any, to request the token for.
+ audiences:
+ type: array
+ items:
+ type: string
+ description: The audiences, if any, to request the token for.
+ username:
+ type: string
+ description: The username to use. Used only if the grant type is Password.
+ password:
+ type: string
+ description: The password to use. Used only if the grant type is Password.
+ subject:
+ $ref: '#/$defs/oauth2Token'
+ description: The security token that represents the identity of the party on behalf of whom the request is being made.
+ actor:
+ $ref: '#/$defs/oauth2Token'
+ description: The security token that represents the identity of the acting party.
+ required: [ authority, grant, client ]
+ required: [ oauth2 ]
+ description: Use OAUTH2 authentication.
+ description: Defines an authentication policy.
+ oauth2Token:
+ type: object
+ properties:
+ token:
+ type: string
+ description: The security token to use to use.
+ type:
+ type: string
+ description: The type of the security token to use to use.
+ required: [ token, type ]
+ duration:
+ type: object
+ minProperties: 1
+ properties:
+ days:
+ type: integer
+ description: Number of days, if any.
+ hours:
+ type: integer
+ description: Number of days, if any.
+ minutes:
+ type: integer
+ description: Number of minutes, if any.
+ seconds:
+ type: integer
+ description: Number of seconds, if any.
+ milliseconds:
+ type: integer
+ description: Number of milliseconds, if any.
+ description: The definition of a duration.
+ error:
+ type: object
+ properties:
+ type:
+ type: string
+ format: uri
+ description: A URI reference that identifies the error type.
+ status:
+ type: integer
+ description: The status code generated by the origin for this occurrence of the error.
+ instance:
+ type: string
+ format: json-pointer
+ description: A JSON Pointer used to reference the component the error originates from.
+ title:
+ type: string
+ description: A short, human-readable summary of the error.
+ detail:
+ type: string
+ description: A human-readable explanation specific to this occurrence of the error.
+ required: [ type, status, instance ]
+ endpoint:
+ type: object
+ properties:
+ uri:
+ type: string
+ format: uri-template
+ description: The endpoint's URI.
+ authentication:
+ description: The authentication policy to use.
+ oneOf:
+ - $ref: '#/$defs/authenticationPolicy'
+ - type: string
+ required: [ uri ]
+ eventConsumptionStrategy:
+ type: object
+ oneOf:
+ - title: AllEventConsumptionStrategy
+ properties:
+ all:
+ type: array
+ items:
+ $ref: '#/$defs/eventFilter'
+ description: A list containing all the events that must be consumed.
+ required: [ all ]
+ - title: AnyEventConsumptionStrategy
+ properties:
+ any:
+ type: array
+ items:
+ $ref: '#/$defs/eventFilter'
+ description: A list containing any of the events to consume.
+ required: [ any ]
+ - title: OneEventConsumptionStrategy
+ properties:
+ one:
+ $ref: '#/$defs/eventFilter'
+ description: The single event to consume.
+ required: [ one ]
+ eventFilter:
+ type: object
+ properties:
+ with:
+ title: WithEvent
+ type: object
+ minProperties: 1
+ properties:
+ id:
+ type: string
+ description: The event's unique identifier
+ source:
+ type: string
+ description: Identifies the context in which an event happened
+ type:
+ type: string
+ description: This attribute contains a value describing the type of event related to the originating occurrence.
+ time:
+ type: string
+ subject:
+ type: string
+ datacontenttype:
+ type: string
+ description: Content type of data value. This attribute enables data to carry any type of content, whereby format and encoding might differ from that of the chosen event format.
+ dataschema:
+ type: string
+ additionalProperties: true
+ description: An event filter is a mechanism used to selectively process or handle events based on predefined criteria, such as event type, source, or specific attributes.
+ correlate:
+ type: object
+ additionalProperties:
+ type: object
+ properties:
+ from:
+ type: string
+ description: A runtime expression used to extract the correlation value from the filtered event.
+ expect:
+ type: string
+ description: A constant or a runtime expression, if any, used to determine whether or not the extracted correlation value matches expectations. If not set, the first extracted value will be used as the correlation's expectation.
+ required: [ from ]
+ description: A correlation is a link between events and data, established by mapping event attributes to specific data attributes, allowing for coordinated processing or handling based on event characteristics.
+ required: [ with ]
+ description: An event filter is a mechanism used to selectively process or handle events based on predefined criteria, such as event type, source, or specific attributes.
+ extension:
+ type: object
+ properties:
+ extend:
+ type: string
+ enum: [ call, composite, emit, for, listen, raise, run, set, switch, try, wait, all ]
+ description: The type of task to extend.
+ when:
+ type: string
+ description: A runtime expression, if any, used to determine whether or not the extension should apply in the specified context.
+ before:
+ description: The task(s) to execute before the extended task, if any.
+ $ref: '#/$defs/taskList'
+ after:
+ description: The task(s) to execute after the extended task, if any.
+ $ref: '#/$defs/taskList'
+ required: [ extend ]
+ description: The definition of a an extension.
+ externalResource:
+ oneOf:
+ - type: string
+ format: uri
+ - title: ExternalResourceURI
+ type: object
+ properties:
+ uri:
+ type: string
+ format: uri
+ description: The endpoint's URI.
+ authentication:
+ description: The authentication policy to use.
+ oneOf:
+ - $ref: '#/$defs/authenticationPolicy'
+ - type: string
+ name:
+ type: string
+ description: The external resource's name, if any.
+ required: [ uri ]
+ input:
+ type: object
+ properties:
+ schema:
+ $ref: '#/$defs/schema'
+ description: The schema used to describe and validate the input of the workflow or task.
+ from:
+ type: string
+ description: A runtime expression, if any, used to mutate and/or filter the input of the workflow or task.
+ description: Configures the input of a workflow or task.
+ output:
+ type: object
+ properties:
+ schema:
+ $ref: '#/$defs/schema'
+ description: The schema used to describe and validate the output of the workflow or task.
+ as:
+ type: string
+ description: A runtime expression, if any, used to mutate and/or filter the output of the workflow or task.
+ description: Configures the output of a workflow or task.
+ export:
+ type: object
+ properties:
+ schema:
+ $ref: '#/$defs/schema'
+ description: The schema used to describe and validate the workflow context.
+ as:
+ type: string
+ description: A runtime expression, if any, used to export the output data to the context.
+ description: Set the content of the context.
+ retryPolicy:
+ type: object
+ properties:
+ when:
+ type: string
+ description: A runtime expression, if any, used to determine whether or not to retry running the task, in a given context.
+ exceptWhen:
+ type: string
+ description: A runtime expression used to determine whether or not to retry running the task, in a given context.
+ delay:
+ $ref: '#/$defs/duration'
+ description: The duration to wait between retry attempts.
+ backoff:
+ type: object
+ oneOf:
+ - title: ConstantBackoff
+ properties:
+ constant:
+ type: object
+ description: The definition of the constant backoff to use, if any.
+ required: [ constant ]
+ - title: ExponentialBackOff
+ properties:
+ exponential:
+ type: object
+ description: The definition of the exponential backoff to use, if any.
+ required: [ exponential ]
+ - title: LinearBackoff
+ properties:
+ linear:
+ type: object
+ description: The definition of the linear backoff to use, if any.
+ required: [ linear ]
+ description: The retry duration backoff.
+ limit:
+ type: object
+ properties:
+ attempt:
+ type: object
+ properties:
+ count:
+ type: integer
+ description: The maximum amount of retry attempts, if any.
+ duration:
+ $ref: '#/$defs/duration'
+ description: The maximum duration for each retry attempt.
+ duration:
+ $ref: '#/$defs/duration'
+ description: The duration limit, if any, for all retry attempts.
+ description: The retry limit, if any
+ jitter:
+ type: object
+ properties:
+ from:
+ $ref: '#/$defs/duration'
+ description: The minimum duration of the jitter range
+ to:
+ $ref: '#/$defs/duration'
+ description: The maximum duration of the jitter range
+ required: [ from, to ]
+ description: The parameters, if any, that control the randomness or variability of the delay between retry attempts.
+ description: Defines a retry policy.
+ schema:
+ type: object
+ properties:
+ format:
+ type: string
+ default: json
+ description: The schema's format. Defaults to 'json'. The (optional) version of the format can be set using `{format}:{version}`.
+ oneOf:
+ - title: SchemaInline
+ properties:
+ document:
+ description: The schema's inline definition.
+ required: [ document ]
+ - title: SchemaExternal
+ properties:
+ resource:
+ $ref: '#/$defs/externalResource'
+ description: The schema's external resource.
+ required: [ resource ]
+ description: Represents the definition of a schema.
+ timeout:
+ type: object
+ properties:
+ after:
+ $ref: '#/$defs/duration'
+ description: The duration after which to timeout.
+ required: [ after ]
+ description: The definition of a timeout.
+required: [ document, do ]
\ No newline at end of file
diff --git a/api/src/test/java/io/serverlessworkflow/api/ApiTest.java b/api/src/test/java/io/serverlessworkflow/api/ApiTest.java
new file mode 100644
index 00000000..87924497
--- /dev/null
+++ b/api/src/test/java/io/serverlessworkflow/api/ApiTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.api;
+
+import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import io.serverlessworkflow.api.types.CallHTTP;
+import io.serverlessworkflow.api.types.CallTask;
+import io.serverlessworkflow.api.types.Task;
+import io.serverlessworkflow.api.types.Workflow;
+import java.io.IOException;
+import org.junit.jupiter.api.Test;
+
+public class ApiTest {
+
+ @Test
+ void testCallHTTPAPI() throws IOException {
+ Workflow workflow = readWorkflowFromClasspath("features/callHttp.yaml");
+ assertThat(workflow.getDo()).isNotEmpty();
+ assertThat(workflow.getDo().get(0).getAdditionalProperties()).isNotEmpty();
+ assertThat(workflow.getDo().get(0).getAdditionalProperties().values()).isNotEmpty();
+ Task task = workflow.getDo().get(0).getAdditionalProperties().values().iterator().next();
+ CallTask callTask = task.getCallTask();
+ assertThat(callTask).isNotNull();
+ assertThat(task.getDoTask()).isNull();
+ CallHTTP httpCall = callTask.getCallHTTP();
+ assertThat(httpCall).isNotNull();
+ assertThat(callTask.getCallAsyncAPI()).isNull();
+ assertThat(httpCall.getWith().getMethod()).isEqualTo("get");
+ }
+}
diff --git a/api/src/test/java/io/serverlessworkflow/api/FeaturesTest.java b/api/src/test/java/io/serverlessworkflow/api/FeaturesTest.java
new file mode 100644
index 00000000..de2591a3
--- /dev/null
+++ b/api/src/test/java/io/serverlessworkflow/api/FeaturesTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.api;
+
+import static io.serverlessworkflow.api.WorkflowReader.readWorkflow;
+import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath;
+import static io.serverlessworkflow.api.WorkflowWriter.writeWorkflow;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import io.serverlessworkflow.api.types.Workflow;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+public class FeaturesTest {
+
+ @ParameterizedTest
+ @ValueSource(
+ strings = {
+ "features/callHttp.yaml",
+ "features/callOpenAPI.yaml",
+ "features/composite.yaml",
+ "features/data-flow.yaml",
+ "features/emit.yaml",
+ "features/flow.yaml",
+ "features/for.yaml",
+ "features/raise.yaml",
+ "features/set.yaml",
+ "features/switch.yaml",
+ "features/try.yaml"
+ })
+ public void testSpecFeaturesParsing(String workflowLocation) throws IOException {
+ Workflow workflow = readWorkflowFromClasspath(workflowLocation);
+ assertWorkflow(workflow);
+ assertWorkflow(writeAndReadInMemory(workflow));
+ }
+
+ private static Workflow writeAndReadInMemory(Workflow workflow) throws IOException {
+ byte[] bytes;
+ try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+ writeWorkflow(out, workflow, WorkflowFormat.JSON);
+ bytes = out.toByteArray();
+ }
+ try (ByteArrayInputStream in = new ByteArrayInputStream(bytes)) {
+ return readWorkflow(in, WorkflowFormat.JSON);
+ }
+ }
+
+ private static void assertWorkflow(Workflow workflow) {
+ assertNotNull(workflow);
+ assertNotNull(workflow.getDocument());
+ assertNotNull(workflow.getDo());
+ }
+}
diff --git a/api/src/test/java/io/serverlessworkflow/api/test/CodegenTest.java b/api/src/test/java/io/serverlessworkflow/api/test/CodegenTest.java
deleted file mode 100644
index 885d87b9..00000000
--- a/api/src/test/java/io/serverlessworkflow/api/test/CodegenTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.api.test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.test.utils.WorkflowTestUtils;
-import org.junit.jupiter.api.Test;
-
-class CodegenTest {
-
- @Test
- void collectionsShouldNotBeInitializedByDefault() {
- Workflow workflow =
- Workflow.fromSource(WorkflowTestUtils.readWorkflowFile("/features/functionrefs.json"));
- assertThat(workflow.getAnnotations()).isNull();
- }
-}
diff --git a/api/src/test/java/io/serverlessworkflow/api/test/MarkupToWorkflowTest.java b/api/src/test/java/io/serverlessworkflow/api/test/MarkupToWorkflowTest.java
deleted file mode 100644
index 25159d50..00000000
--- a/api/src/test/java/io/serverlessworkflow/api/test/MarkupToWorkflowTest.java
+++ /dev/null
@@ -1,965 +0,0 @@
-/*
- * 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.api.test;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.actions.Action;
-import io.serverlessworkflow.api.auth.AuthDefinition;
-import io.serverlessworkflow.api.branches.Branch;
-import io.serverlessworkflow.api.defaultdef.DefaultConditionDefinition;
-import io.serverlessworkflow.api.end.End;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.api.events.EventRef;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.api.functions.FunctionRef;
-import io.serverlessworkflow.api.functions.SubFlowRef;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.api.retry.RetryDefinition;
-import io.serverlessworkflow.api.states.EventState;
-import io.serverlessworkflow.api.states.OperationState;
-import io.serverlessworkflow.api.states.ParallelState;
-import io.serverlessworkflow.api.states.SwitchState;
-import io.serverlessworkflow.api.switchconditions.DataCondition;
-import io.serverlessworkflow.api.test.utils.WorkflowTestUtils;
-import io.serverlessworkflow.api.timeouts.WorkflowExecTimeout;
-import io.serverlessworkflow.api.workflow.*;
-import java.util.List;
-import java.util.Map;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-public class MarkupToWorkflowTest {
-
- @ParameterizedTest
- @ValueSource(
- strings = {
- "/examples/applicantrequest.json",
- "/examples/applicantrequest.yml",
- "/examples/carauctionbids.json",
- "/examples/carauctionbids.yml",
- "/examples/creditcheck.json",
- "/examples/creditcheck.yml",
- "/examples/eventbasedgreeting.json",
- "/examples/eventbasedgreeting.yml",
- "/examples/finalizecollegeapplication.json",
- "/examples/finalizecollegeapplication.yml",
- "/examples/greeting.json",
- "/examples/greeting.yml",
- "/examples/helloworld.json",
- "/examples/helloworld.yml",
- "/examples/jobmonitoring.json",
- "/examples/jobmonitoring.yml",
- "/examples/monitorpatient.json",
- "/examples/monitorpatient.yml",
- "/examples/parallel.json",
- "/examples/parallel.yml",
- "/examples/provisionorder.json",
- "/examples/provisionorder.yml",
- "/examples/sendcloudevent.json",
- "/examples/sendcloudevent.yml",
- "/examples/solvemathproblems.json",
- "/examples/solvemathproblems.yml",
- "/examples/foreachstatewithactions.json",
- "/examples/foreachstatewithactions.yml",
- "/examples/periodicinboxcheck.json",
- "/examples/periodicinboxcheck.yml",
- "/examples/vetappointmentservice.json",
- "/examples/vetappointmentservice.yml",
- "/examples/eventbasedtransition.json",
- "/examples/eventbasedtransition.yml",
- "/examples/roomreadings.json",
- "/examples/roomreadings.yml",
- "/examples/checkcarvitals.json",
- "/examples/checkcarvitals.yml",
- "/examples/booklending.json",
- "/examples/booklending.yml"
- })
- public void testSpecExamplesParsing(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
- assertTrue(workflow.getStates().size() > 0);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/applicantrequest.json", "/features/applicantrequest.yml"})
- public void testSpecFeatureFunctionRef(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNull(workflow.getKey());
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
- assertTrue(workflow.getStates().size() > 0);
-
- assertNotNull(workflow.getFunctions());
- assertEquals(1, workflow.getFunctions().getFunctionDefs().size());
- }
-
- @ParameterizedTest
- @ValueSource(
- strings = {
- "/features/applicantrequest-with-key.json",
- "/features/applicantrequest-with-key.yml"
- })
- public void testSpecFeatureFunctionRefWithKey(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertEquals("applicant-key-request", workflow.getKey());
- assertNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
- assertTrue(workflow.getStates().size() > 0);
-
- assertNotNull(workflow.getFunctions());
- assertEquals(1, workflow.getFunctions().getFunctionDefs().size());
- }
-
- @ParameterizedTest
- @ValueSource(
- strings = {
- "/features/applicantrequest-with-id-and-key.json",
- "/features/applicantrequest-with-id-and-key.yml"
- })
- public void testSpecFeatureFunctionRefWithIdAndKey(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertEquals("applicant-key-request", workflow.getKey());
- assertEquals("applicant-with-key-and-id", workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
- assertTrue(workflow.getStates().size() > 0);
-
- assertNotNull(workflow.getFunctions());
- assertEquals(1, workflow.getFunctions().getFunctionDefs().size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/vetappointment.json", "/features/vetappointment.yml"})
- public void testSpecFreatureEventRef(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
- assertTrue(workflow.getStates().size() > 0);
-
- assertNotNull(workflow.getEvents());
- assertEquals(2, workflow.getEvents().getEventDefs().size());
-
- assertNotNull(workflow.getRetries());
- assertEquals(1, workflow.getRetries().getRetryDefs().size());
- }
-
- @ParameterizedTest
- @ValueSource(
- strings = {"/features/compensationworkflow.json", "/features/compensationworkflow.yml"})
- public void testSpecFreatureCompensation(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(2, workflow.getStates().size());
-
- State firstState = workflow.getStates().get(0);
- assertTrue(firstState instanceof EventState);
- assertNotNull(firstState.getCompensatedBy());
- assertEquals("CancelPurchase", firstState.getCompensatedBy());
-
- State secondState = workflow.getStates().get(1);
- assertTrue(secondState instanceof OperationState);
- OperationState operationState = (OperationState) secondState;
-
- assertTrue(operationState.isUsedForCompensation());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/functiontypes.json", "/features/functiontypes.yml"})
- public void testFunctionTypes(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
-
- State state = workflow.getStates().get(0);
- assertTrue(state instanceof OperationState);
-
- List functionDefs = workflow.getFunctions().getFunctionDefs();
- assertNotNull(functionDefs);
- assertEquals(2, functionDefs.size());
-
- FunctionDefinition restFunc = functionDefs.get(0);
- assertEquals(restFunc.getType(), FunctionDefinition.Type.REST);
-
- FunctionDefinition restFunc2 = functionDefs.get(1);
- assertEquals(restFunc2.getType(), FunctionDefinition.Type.EXPRESSION);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/transitions.json", "/features/transitions.yml"})
- public void testTransitions(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
-
- State state = workflow.getStates().get(0);
- assertTrue(state instanceof SwitchState);
-
- SwitchState switchState = (SwitchState) workflow.getStates().get(0);
- assertNotNull(switchState.getDataConditions());
- List dataConditions = switchState.getDataConditions();
-
- assertEquals(2, dataConditions.size());
-
- DataCondition cond1 = switchState.getDataConditions().get(0);
- assertNotNull(cond1.getTransition());
- assertEquals("StartApplication", cond1.getTransition().getNextState());
- assertNotNull(cond1.getTransition().getProduceEvents());
- assertTrue(cond1.getTransition().getProduceEvents().isEmpty());
- assertFalse(cond1.getTransition().isCompensate());
-
- DataCondition cond2 = switchState.getDataConditions().get(1);
- assertNotNull(cond2.getTransition());
- assertEquals("RejectApplication", cond2.getTransition().getNextState());
- assertNotNull(cond2.getTransition().getProduceEvents());
- assertEquals(1, cond2.getTransition().getProduceEvents().size());
- assertNotNull(cond2.getTransition().getProduceEvents().get(0).getContextAttributes());
- Map contextAttributes =
- cond2.getTransition().getProduceEvents().get(0).getContextAttributes();
- assertEquals(2, contextAttributes.size());
- assertEquals("IN", contextAttributes.get("order_location"));
- assertEquals("online", contextAttributes.get("order_type"));
- assertFalse(cond2.getTransition().isCompensate());
-
- assertNotNull(switchState.getDefaultCondition());
- DefaultConditionDefinition defaultDefinition = switchState.getDefaultCondition();
- assertNotNull(defaultDefinition.getTransition());
- assertEquals("RejectApplication", defaultDefinition.getTransition().getNextState());
- assertNull(defaultDefinition.getTransition().getProduceEvents());
- assertTrue(defaultDefinition.getTransition().isCompensate());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/functionrefs.json", "/features/functionrefs.yml"})
- public void testFunctionRefs(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
-
- State state = workflow.getStates().get(0);
- assertTrue(state instanceof OperationState);
-
- OperationState operationState = (OperationState) workflow.getStates().get(0);
- assertNotNull(operationState.getActions());
- assertEquals(2, operationState.getActions().size());
-
- Action action1 = operationState.getActions().get(0);
- assertNotNull(action1);
- assertNotNull(action1.getFunctionRef());
- FunctionRef functionRef1 = action1.getFunctionRef();
- assertEquals("creditCheckFunction", functionRef1.getRefName());
- assertNull(functionRef1.getArguments());
-
- Action action2 = operationState.getActions().get(1);
- assertNotNull(action2);
- assertNotNull(action2.getFunctionRef());
- FunctionRef functionRef2 = action2.getFunctionRef();
- assertEquals("sendRejectionEmailFunction", functionRef2.getRefName());
- assertEquals(1, functionRef2.getArguments().size());
- assertEquals("${ .customer }", functionRef2.getArguments().get("applicant").asText());
- }
-
- @ParameterizedTest
- @ValueSource(
- strings = {"/features/keepactiveexectimeout.json", "/features/keepactiveexectimeout.yml"})
- public void testKeepActiveExecTimeout(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertTrue(workflow.isKeepActive());
- assertNotNull(workflow.getTimeouts());
- assertNotNull(workflow.getTimeouts().getWorkflowExecTimeout());
-
- WorkflowExecTimeout execTimeout = workflow.getTimeouts().getWorkflowExecTimeout();
- assertEquals("PT1H", execTimeout.getDuration());
- assertEquals("GenerateReport", execTimeout.getRunBefore());
- }
-
- @ParameterizedTest
- @ValueSource(
- strings = {"/features/functionrefjsonparams.json", "/features/functionrefjsonparams.yml"})
- public void testFunctionRefJsonParams(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
- assertTrue(workflow.getStates().get(0) instanceof OperationState);
-
- OperationState operationState = (OperationState) workflow.getStates().get(0);
- assertNotNull(operationState.getActions());
- assertEquals(1, operationState.getActions().size());
- List actions = operationState.getActions();
- assertNotNull(actions.get(0).getFunctionRef());
- assertEquals("addPet", actions.get(0).getFunctionRef().getRefName());
-
- JsonNode params = actions.get(0).getFunctionRef().getArguments();
- assertNotNull(params);
- assertEquals(4, params.size());
- assertEquals(123, params.get("id").intValue());
- assertEquals("My Address, 123 MyCity, MyCountry", params.get("address").asText());
- assertEquals("${ .owner.name }", params.get("owner").asText());
- assertEquals("Pluto", params.get("body").get("name").asText());
- assertEquals("${ .pet.tagnumber }", params.get("body").get("tag").asText());
- }
-
- @ParameterizedTest
- @ValueSource(
- strings = {"/features/functionrefnoparams.json", "/features/functionrefnoparams.yml"})
- public void testFunctionRefNoParams(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
- assertTrue(workflow.getStates().get(0) instanceof OperationState);
-
- OperationState operationState = (OperationState) workflow.getStates().get(0);
- assertNotNull(operationState.getActions());
- assertEquals(2, operationState.getActions().size());
- List actions = operationState.getActions();
- assertNotNull(actions.get(0).getFunctionRef());
- assertNotNull(actions.get(1).getFunctionRef());
- assertEquals("addPet", actions.get(0).getFunctionRef().getRefName());
- assertEquals("addPet", actions.get(1).getFunctionRef().getRefName());
-
- JsonNode params = actions.get(0).getFunctionRef().getArguments();
- assertNull(params);
- JsonNode params2 = actions.get(1).getFunctionRef().getArguments();
- assertNull(params2);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/simpleschedule.json", "/features/simpleschedule.yml"})
- public void testSimplifiedSchedule(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
-
- assertNotNull(workflow.getStart());
- assertNotNull(workflow.getStart().getSchedule());
-
- assertEquals(
- "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z",
- workflow.getStart().getSchedule().getInterval());
-
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/simplecron.json", "/features/simplecron.yml"})
- public void testSimplifiedCron(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
-
- assertNotNull(workflow.getStart());
- assertNotNull(workflow.getStart().getSchedule());
-
- assertEquals("0 0/15 * * * ?", workflow.getStart().getSchedule().getCron().getExpression());
-
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(2, workflow.getStates().size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/expressionlang.json", "/features/expressionlang.yml"})
- public void testExpressionLang(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getExpressionLang());
- assertEquals("abc", workflow.getExpressionLang());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/shortstart.json", "/features/shortstart.yml"})
- public void testShortStart(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStart());
- assertEquals("TestFunctionRefs", workflow.getStart().getStateName());
- assertNull(workflow.getStart().getSchedule());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/longstart.json", "/features/longstart.yml"})
- public void testLongStart(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStart());
- assertEquals("TestFunctionRefs", workflow.getStart().getStateName());
- assertNotNull(workflow.getStart().getSchedule());
- assertNotNull(workflow.getStart().getSchedule().getCron());
- assertEquals("0 0/15 * * * ?", workflow.getStart().getSchedule().getCron().getExpression());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/retriesprops.json", "/features/retriesprops.yml"})
- public void testRetriesProps(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getRetries());
- assertNotNull(workflow.getStates());
-
- Retries retries = workflow.getRetries();
- assertNotNull(retries.getRetryDefs());
- assertEquals(1, retries.getRetryDefs().size());
-
- RetryDefinition retryDefinition = retries.getRetryDefs().get(0);
- assertEquals("Test Retries", retryDefinition.getName());
- assertEquals("PT1M", retryDefinition.getDelay());
- assertEquals("PT2M", retryDefinition.getMaxDelay());
- assertEquals("PT2S", retryDefinition.getIncrement());
- assertEquals("1.2", retryDefinition.getMultiplier());
- assertEquals("20", retryDefinition.getMaxAttempts());
- assertEquals("0.4", retryDefinition.getJitter());
- }
-
- @ParameterizedTest
- @ValueSource(
- strings = {
- "/features/datainputschemastring.json",
- "/features/datainputschemastring.yml",
- "/features/datainputschemaobjstring.json",
- "/features/datainputschemaobjstring.yml"
- })
- public void testDataInputSchemaFromString(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- DataInputSchema dataInputSchema = workflow.getDataInputSchema();
- assertNotNull(dataInputSchema);
- assertEquals("features/somejsonschema.json", dataInputSchema.getRefValue());
- assertTrue(dataInputSchema.isFailOnValidationErrors());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/datainputschemawithnullschema.json"})
- public void testDataInputSchemaWithNullSchema(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- DataInputSchema dataInputSchema = workflow.getDataInputSchema();
- assertNotNull(dataInputSchema);
- assertEquals("null", dataInputSchema.getRefValue());
- assertTrue(dataInputSchema.isFailOnValidationErrors());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/datainputschemaobj.json", "/features/datainputschemaobj.yml"})
- public void testDataInputSchemaFromObject(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getDataInputSchema());
- DataInputSchema dataInputSchema = workflow.getDataInputSchema();
- assertNotNull(dataInputSchema.getSchemaDef());
-
- JsonNode schemaObj = dataInputSchema.getSchemaDef();
- assertNotNull(schemaObj.get("properties"));
- JsonNode properties = schemaObj.get("properties");
- assertNotNull(properties.get("firstName"));
- JsonNode typeNode = properties.get("firstName");
- JsonNode stringNode = typeNode.get("type");
- assertEquals("string", stringNode.asText());
- assertFalse(dataInputSchema.isFailOnValidationErrors());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/subflowref.json", "/features/subflowref.yml"})
- public void testSubFlowRef(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
-
- assertTrue(workflow.getStates().get(0) instanceof OperationState);
-
- OperationState operationState = (OperationState) workflow.getStates().get(0);
-
- List actions = operationState.getActions();
- assertNotNull(actions);
- assertEquals(2, actions.size());
-
- Action firstAction = operationState.getActions().get(0);
- assertNotNull(firstAction.getSubFlowRef());
- SubFlowRef firstSubflowRef = firstAction.getSubFlowRef();
- assertEquals("subflowRefReference", firstSubflowRef.getWorkflowId());
-
- Action secondAction = operationState.getActions().get(1);
- assertNotNull(secondAction.getSubFlowRef());
- SubFlowRef secondSubflowRef = secondAction.getSubFlowRef();
- assertEquals("subflowrefworkflowid", secondSubflowRef.getWorkflowId());
- assertEquals("1.0", secondSubflowRef.getVersion());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/secrets.json", "/features/secrets.yml"})
- public void testSecrets(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getSecrets());
- Secrets secrets = workflow.getSecrets();
- assertNotNull(secrets.getSecretDefs());
- assertEquals(3, secrets.getSecretDefs().size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/constants.json", "/features/constants.yml"})
- public void testConstants(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getConstants());
- Constants constants = workflow.getConstants();
- assertNotNull(constants.getConstantsDef());
-
- JsonNode constantObj = constants.getConstantsDef();
- assertNotNull(constantObj.get("Translations"));
- JsonNode translationNode = constantObj.get("Translations");
- assertNotNull(translationNode.get("Dog"));
- JsonNode translationDogNode = translationNode.get("Dog");
- JsonNode serbianTranslationNode = translationDogNode.get("Serbian");
- assertEquals("pas", serbianTranslationNode.asText());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/constantsRef.json", "/features/constantsRef.yml"})
- public void testConstantsRef(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getConstants());
- Constants constants = workflow.getConstants();
- assertEquals("constantValues.json", constants.getRefValue());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/timeouts.json", "/features/timeouts.yml"})
- public void testTimeouts(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getTimeouts());
- assertNotNull(workflow.getTimeouts().getWorkflowExecTimeout());
-
- WorkflowExecTimeout execTimeout = workflow.getTimeouts().getWorkflowExecTimeout();
- assertEquals("PT1H", execTimeout.getDuration());
- assertEquals("GenerateReport", execTimeout.getRunBefore());
-
- assertNotNull(workflow.getStates());
- assertEquals(2, workflow.getStates().size());
- assertTrue(workflow.getStates().get(0) instanceof EventState);
-
- EventState firstState = (EventState) workflow.getStates().get(0);
- assertNotNull(firstState.getTimeouts());
- assertNotNull(firstState.getTimeouts().getStateExecTimeout());
- assertNotNull(firstState.getTimeouts().getEventTimeout());
- assertEquals("PT5M", firstState.getTimeouts().getStateExecTimeout().getTotal());
- assertEquals("PT2M", firstState.getTimeouts().getEventTimeout());
-
- assertTrue(workflow.getStates().get(1) instanceof ParallelState);
- ParallelState secondState = (ParallelState) workflow.getStates().get(1);
- assertNotNull(secondState.getTimeouts());
- assertNotNull(secondState.getTimeouts().getStateExecTimeout());
- assertEquals("PT5M", secondState.getTimeouts().getStateExecTimeout().getTotal());
-
- assertNotNull(secondState.getBranches());
- assertEquals(2, secondState.getBranches().size());
- List branches = secondState.getBranches();
-
- assertNotNull(branches.get(0).getTimeouts());
- assertNotNull(branches.get(0).getTimeouts().getBranchExecTimeout());
- assertEquals("PT3S", branches.get(0).getTimeouts().getBranchExecTimeout());
-
- assertNotNull(branches.get(1).getTimeouts());
- assertNotNull(branches.get(1).getTimeouts().getBranchExecTimeout());
- assertEquals("PT4S", branches.get(1).getTimeouts().getBranchExecTimeout());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/authbasic.json", "/features/authbasic.yml"})
- public void testAuthBasic(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
-
- assertNotNull(workflow.getAuth());
- AuthDefinition auth = workflow.getAuth().getAuthDefs().get(0);
- assertNotNull(auth.getName());
- assertEquals("authname", auth.getName());
- assertNotNull(auth.getScheme());
- assertEquals("basic", auth.getScheme().value());
- assertNotNull(auth.getBasicauth());
- assertEquals("testuser", auth.getBasicauth().getUsername());
- assertEquals("testpassword", auth.getBasicauth().getPassword());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/authbearer.json", "/features/authbearer.yml"})
- public void testAuthBearer(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
-
- assertNotNull(workflow.getAuth());
- AuthDefinition auth = workflow.getAuth().getAuthDefs().get(0);
- assertNotNull(auth.getName());
- assertEquals("authname", auth.getName());
- assertNotNull(auth.getScheme());
- assertEquals("bearer", auth.getScheme().value());
- assertNotNull(auth.getBearerauth());
- assertEquals("testtoken", auth.getBearerauth().getToken());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/authoauth.json", "/features/authoauth.yml"})
- public void testAuthOAuth(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
-
- assertNotNull(workflow.getAuth());
- AuthDefinition auth = workflow.getAuth().getAuthDefs().get(0);
- assertNotNull(auth.getName());
- assertEquals("authname", auth.getName());
- assertNotNull(auth.getScheme());
- assertEquals("oauth2", auth.getScheme().value());
- assertNotNull(auth.getOauth());
- assertEquals("testauthority", auth.getOauth().getAuthority());
- assertEquals("clientCredentials", auth.getOauth().getGrantType().value());
- assertEquals("${ $SECRETS.clientid }", auth.getOauth().getClientId());
- assertEquals("${ $SECRETS.clientsecret }", auth.getOauth().getClientSecret());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/actionssleep.json", "/features/actionssleep.yml"})
- public void testActionsSleep(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
-
- State state = workflow.getStates().get(0);
- assertTrue(state instanceof OperationState);
-
- OperationState operationState = (OperationState) workflow.getStates().get(0);
- assertNotNull(operationState.getActions());
- assertEquals(2, operationState.getActions().size());
-
- Action action1 = operationState.getActions().get(0);
- assertNotNull(action1);
- assertNotNull(action1.getFunctionRef());
- assertNotNull(action1.getSleep());
- assertEquals("PT5S", action1.getSleep().getBefore());
- assertEquals("PT10S", action1.getSleep().getAfter());
- FunctionRef functionRef1 = action1.getFunctionRef();
- assertEquals("creditCheckFunction", functionRef1.getRefName());
- assertNull(functionRef1.getArguments());
-
- Action action2 = operationState.getActions().get(1);
- assertNotNull(action2);
- assertNotNull(action2.getFunctionRef());
- assertNotNull(action2.getSleep());
- assertEquals("PT5S", action2.getSleep().getBefore());
- assertEquals("PT10S", action2.getSleep().getAfter());
- FunctionRef functionRef2 = action2.getFunctionRef();
- assertEquals("sendRejectionEmailFunction", functionRef2.getRefName());
- assertEquals(1, functionRef2.getArguments().size());
- assertEquals("${ .customer }", functionRef2.getArguments().get("applicant").asText());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/errors.json", "/features/errors.yml"})
- public void testErrorsParams(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
- assertTrue(workflow.isAutoRetries());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
-
- assertNotNull(workflow.getErrors());
- assertEquals(2, workflow.getErrors().getErrorDefs().size());
-
- assertTrue(workflow.getStates().get(0) instanceof OperationState);
-
- OperationState operationState = (OperationState) workflow.getStates().get(0);
- assertNotNull(operationState.getActions());
- assertEquals(1, operationState.getActions().size());
- List actions = operationState.getActions();
- assertNotNull(actions.get(0).getFunctionRef());
- assertEquals("addPet", actions.get(0).getFunctionRef().getRefName());
- assertNotNull(actions.get(0).getRetryRef());
- assertEquals("testRetry", actions.get(0).getRetryRef());
- assertNotNull(actions.get(0).getNonRetryableErrors());
- assertEquals(2, actions.get(0).getNonRetryableErrors().size());
- assertNotNull(actions.get(0).getCondition());
- assertEquals("${ .data }", actions.get(0).getCondition());
-
- assertNotNull(operationState.getOnErrors());
- assertEquals(1, operationState.getOnErrors().size());
- assertNotNull(operationState.getOnErrors().get(0).getErrorRefs());
- assertEquals(2, operationState.getOnErrors().get(0).getErrorRefs().size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/continueasstring.json", "/features/continueasstring.yml"})
- public void testContinueAsString(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
-
- OperationState operationState = (OperationState) workflow.getStates().get(0);
- assertNotNull(operationState.getEnd());
- End end = operationState.getEnd();
- assertNotNull(end.getContinueAs());
- assertNotNull(end.getContinueAs().getWorkflowId());
- assertEquals("myworkflowid", end.getContinueAs().getWorkflowId());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/continueasobject.json", "/features/continueasobject.yml"})
- public void testContinueAsObject(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
-
- OperationState operationState = (OperationState) workflow.getStates().get(0);
- assertNotNull(operationState.getEnd());
- End end = operationState.getEnd();
- assertNotNull(end.getContinueAs());
- assertNotNull(end.getContinueAs().getWorkflowId());
- assertEquals("myworkflowid", end.getContinueAs().getWorkflowId());
- assertEquals("1.0", end.getContinueAs().getVersion());
- assertEquals("${ .data }", end.getContinueAs().getData());
- assertNotNull(end.getContinueAs().getWorkflowExecTimeout());
- assertEquals("PT1M", end.getContinueAs().getWorkflowExecTimeout().getDuration());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/invoke.json", "/features/invoke.yml"})
- public void testFunctionInvoke(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- assertNotNull(workflow.getStates());
- assertEquals(1, workflow.getStates().size());
-
- OperationState operationState = (OperationState) workflow.getStates().get(0);
- assertNotNull(operationState.getEnd());
- assertNotNull(operationState.getActions());
- assertEquals(3, operationState.getActions().size());
-
- Action action1 = operationState.getActions().get(0);
- assertNotNull(action1.getFunctionRef());
- assertNotNull(action1.getFunctionRef().getInvoke());
- assertEquals(FunctionRef.Invoke.ASYNC, action1.getFunctionRef().getInvoke());
-
- Action action2 = operationState.getActions().get(1);
- assertNotNull(action2.getSubFlowRef());
- assertNotNull(action2.getSubFlowRef().getOnParentComplete());
- assertEquals(
- SubFlowRef.OnParentComplete.CONTINUE, action2.getSubFlowRef().getOnParentComplete());
- assertNotNull(action2.getSubFlowRef().getInvoke());
- assertEquals(SubFlowRef.Invoke.ASYNC, action2.getSubFlowRef().getInvoke());
-
- Action action3 = operationState.getActions().get(2);
- assertNotNull(action3.getEventRef());
- assertNotNull(action3.getEventRef().getInvoke());
- assertEquals(EventRef.Invoke.ASYNC, action3.getEventRef().getInvoke());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/annotations.json", "/features/annotations.yml"})
- public void testAnnotations(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
-
- assertNotNull(workflow.getAnnotations());
- List annotations = workflow.getAnnotations();
- assertEquals(4, annotations.size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/features/eventdefdataonly.json", "/features/eventdefdataonly.yml"})
- public void testEventDefDataOnly(String workflowLocation) {
- Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
-
- assertNotNull(workflow.getEvents());
- Events events = workflow.getEvents();
- assertNotNull(workflow.getEvents().getEventDefs());
- assertEquals(2, events.getEventDefs().size());
- EventDefinition eventDefOne = events.getEventDefs().get(0);
- EventDefinition eventDefTwo = events.getEventDefs().get(1);
- assertEquals("visaApprovedEvent", eventDefOne.getName());
- assertFalse(eventDefOne.isDataOnly());
- assertEquals("visaRejectedEvent", eventDefTwo.getName());
- assertTrue(eventDefTwo.isDataOnly());
- }
-}
diff --git a/api/src/test/java/io/serverlessworkflow/api/test/WorkflowToMarkupTest.java b/api/src/test/java/io/serverlessworkflow/api/test/WorkflowToMarkupTest.java
deleted file mode 100644
index f9204ca9..00000000
--- a/api/src/test/java/io/serverlessworkflow/api/test/WorkflowToMarkupTest.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * 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.api.test;
-
-import static io.serverlessworkflow.api.states.DefaultState.Type.SLEEP;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.auth.AuthDefinition;
-import io.serverlessworkflow.api.auth.BasicAuthDefinition;
-import io.serverlessworkflow.api.defaultdef.DefaultConditionDefinition;
-import io.serverlessworkflow.api.end.End;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.api.produce.ProduceEvent;
-import io.serverlessworkflow.api.schedule.Schedule;
-import io.serverlessworkflow.api.start.Start;
-import io.serverlessworkflow.api.states.SleepState;
-import io.serverlessworkflow.api.states.SwitchState;
-import io.serverlessworkflow.api.switchconditions.DataCondition;
-import io.serverlessworkflow.api.switchconditions.EventCondition;
-import io.serverlessworkflow.api.transitions.Transition;
-import io.serverlessworkflow.api.workflow.Auth;
-import io.serverlessworkflow.api.workflow.Constants;
-import io.serverlessworkflow.api.workflow.Events;
-import io.serverlessworkflow.api.workflow.Functions;
-import java.util.Arrays;
-import org.junit.jupiter.api.Test;
-
-public class WorkflowToMarkupTest {
- @Test
- public void testSingleState() {
-
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withName("test-workflow-name")
- .withVersion("1.0")
- .withStart(new Start().withSchedule(new Schedule().withInterval("PT1S")))
- .withConstants(new Constants("constantsValues.json"))
- .withStates(
- Arrays.asList(
- new SleepState()
- .withName("sleepState")
- .withType(SLEEP)
- .withEnd(
- new End()
- .withTerminate(true)
- .withCompensate(true)
- .withProduceEvents(
- Arrays.asList(new ProduceEvent().withEventRef("someEvent"))))
- .withDuration("PT1M")));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getStart());
- Constants constants = workflow.getConstants();
- assertNotNull(constants);
- assertEquals("constantsValues.json", constants.getRefValue());
- assertEquals(1, workflow.getStates().size());
- State state = workflow.getStates().get(0);
- assertTrue(state instanceof SleepState);
- assertNotNull(state.getEnd());
- assertNotNull(Workflow.toJson(workflow));
- assertNotNull(Workflow.toYaml(workflow));
- }
-
- @Test
- public void testSingleFunction() {
-
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withName("test-workflow-name")
- .withVersion("1.0")
- .withStart(new Start())
- .withFunctions(
- new Functions(
- Arrays.asList(
- new FunctionDefinition()
- .withName("testFunction")
- .withOperation("testSwaggerDef#testOperationId"))))
- .withStates(
- Arrays.asList(
- new SleepState()
- .withName("delayState")
- .withType(SLEEP)
- .withEnd(new End())
- .withDuration("PT1M")));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getStart());
- assertEquals(1, workflow.getStates().size());
- State state = workflow.getStates().get(0);
- assertTrue(state instanceof SleepState);
- assertNotNull(workflow.getFunctions());
- assertEquals(1, workflow.getFunctions().getFunctionDefs().size());
- assertEquals("testFunction", workflow.getFunctions().getFunctionDefs().get(0).getName());
-
- assertNotNull(Workflow.toJson(workflow));
- assertNotNull(Workflow.toYaml(workflow));
- }
-
- @Test
- public void testSingleEvent() {
-
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withName("test-workflow-name")
- .withVersion("1.0")
- .withStart(new Start())
- .withEvents(
- new Events(
- Arrays.asList(
- new EventDefinition()
- .withName("testEvent")
- .withSource("testSource")
- .withType("testType")
- .withKind(EventDefinition.Kind.PRODUCED))))
- .withFunctions(
- new Functions(
- Arrays.asList(
- new FunctionDefinition()
- .withName("testFunction")
- .withOperation("testSwaggerDef#testOperationId"))))
- .withStates(
- Arrays.asList(
- new SleepState()
- .withName("delayState")
- .withType(SLEEP)
- .withEnd(new End())
- .withDuration("PT1M")));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getStart());
- assertEquals(1, workflow.getStates().size());
- State state = workflow.getStates().get(0);
- assertTrue(state instanceof SleepState);
- assertNotNull(workflow.getFunctions());
- assertEquals(1, workflow.getFunctions().getFunctionDefs().size());
- assertEquals("testFunction", workflow.getFunctions().getFunctionDefs().get(0).getName());
- assertNotNull(workflow.getEvents());
- assertEquals(1, workflow.getEvents().getEventDefs().size());
- assertEquals("testEvent", workflow.getEvents().getEventDefs().get(0).getName());
- assertEquals(
- EventDefinition.Kind.PRODUCED, workflow.getEvents().getEventDefs().get(0).getKind());
-
- assertNotNull(Workflow.toJson(workflow));
- assertNotNull(Workflow.toYaml(workflow));
- }
-
- @Test
- public void testAuth() {
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withName("test-workflow-name")
- .withVersion("1.0")
- .withStart(new Start())
- .withAuth(
- new Auth(
- new AuthDefinition()
- .withName("authname")
- .withScheme(AuthDefinition.Scheme.BASIC)
- .withBasicauth(
- new BasicAuthDefinition()
- .withUsername("testuser")
- .withPassword("testPassword"))));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getAuth());
- assertNotNull(workflow.getAuth().getAuthDefs().get(0));
- assertEquals("authname", workflow.getAuth().getAuthDefs().get(0).getName());
- assertNotNull(workflow.getAuth().getAuthDefs().get(0).getScheme());
- assertEquals("basic", workflow.getAuth().getAuthDefs().get(0).getScheme().value());
- assertNotNull(workflow.getAuth().getAuthDefs().get(0).getBasicauth());
- assertEquals("testuser", workflow.getAuth().getAuthDefs().get(0).getBasicauth().getUsername());
- assertEquals(
- "testPassword", workflow.getAuth().getAuthDefs().get(0).getBasicauth().getPassword());
- }
-
- @Test
- public void testSwitchConditionWithTransition() {
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withName("test-workflow-name")
- .withVersion("1.0")
- .withSpecVersion("0.8")
- .withStates(
- Arrays.asList(
- new SwitchState()
- .withDataConditions(
- Arrays.asList(
- new DataCondition()
- .withCondition("test-condition")
- .withTransition(
- new Transition().withNextState("test-next-state"))))
- .withDefaultCondition(
- new DefaultConditionDefinition()
- .withTransition(new Transition("test-next-state-default")))));
- assertNotNull(Workflow.toJson(workflow));
- assertNotNull(Workflow.toYaml(workflow));
- }
-
- @Test
- public void testSwitchConditionWithEnd() {
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withName("test-workflow-name")
- .withVersion("1.0")
- .withSpecVersion("0.8")
- .withStates(
- Arrays.asList(
- new SwitchState()
- .withEventConditions(Arrays.asList(new EventCondition().withEnd(new End())))
- .withDefaultCondition(
- new DefaultConditionDefinition().withEnd(new End()))));
- assertNotNull(Workflow.toJson(workflow));
- assertNotNull(Workflow.toYaml(workflow));
- }
-}
diff --git a/api/src/test/java/io/serverlessworkflow/api/test/utils/WorkflowTestUtils.java b/api/src/test/java/io/serverlessworkflow/api/test/utils/WorkflowTestUtils.java
deleted file mode 100644
index a21c8070..00000000
--- a/api/src/test/java/io/serverlessworkflow/api/test/utils/WorkflowTestUtils.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.api.test.utils;
-
-import io.serverlessworkflow.api.mapper.JsonObjectMapper;
-import io.serverlessworkflow.api.mapper.YamlObjectMapper;
-import java.io.*;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-public class WorkflowTestUtils {
- private static JsonObjectMapper jsonObjectMapper = new JsonObjectMapper();
- private static YamlObjectMapper yamlObjectMapper = new YamlObjectMapper();
-
- public static final Path resourceDirectory = Paths.get("src", "test", "resources");
- public static final String absolutePath = resourceDirectory.toFile().getAbsolutePath();
-
- public static Path getResourcePath(String file) {
- return Paths.get(absolutePath + File.separator + file);
- }
-
- public static InputStream getInputStreamFromPath(Path path) throws Exception {
- return Files.newInputStream(path);
- }
-
- public static String readWorkflowFile(String location) {
- return readFileAsString(classpathResourceReader(location));
- }
-
- public static Reader classpathResourceReader(String location) {
- return new InputStreamReader(WorkflowTestUtils.class.getResourceAsStream(location));
- }
-
- public static String readFileAsString(Reader reader) {
- try {
- StringBuilder fileData = new StringBuilder(1000);
- char[] buf = new char[1024];
- int numRead;
- while ((numRead = reader.read(buf)) != -1) {
- String readData = String.valueOf(buf, 0, numRead);
- fileData.append(readData);
- buf = new char[1024];
- }
- reader.close();
- return fileData.toString();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/api/src/test/resources/examples/applicantrequest.json b/api/src/test/resources/examples/applicantrequest.json
deleted file mode 100644
index 652e361b..00000000
--- a/api/src/test/resources/examples/applicantrequest.json
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- "id": "applicantrequest",
- "key": "applicant-key-request",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Applicant Request Decision Workflow",
- "description": "Determine if applicant request is valid",
- "start": "CheckApplication",
- "functions": [
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/applicationapi.json#emailRejection"
- }
- ],
- "states":[
- {
- "name":"CheckApplication",
- "type":"switch",
- "dataConditions": [
- {
- "condition": "${ .applicants | .age >= 18 }",
- "transition": "StartApplication"
- },
- {
- "condition": "${ .applicants | .age < 18 }",
- "transition": "RejectApplication"
- }
- ],
- "defaultCondition": {
- "transition": "RejectApplication"
- }
- },
- {
- "name": "StartApplication",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "startApplicationWorkflowId"
- }
- ],
- "end": true
- },
- {
- "name":"RejectApplication",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .applicant }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/applicantrequest.yml b/api/src/test/resources/examples/applicantrequest.yml
deleted file mode 100644
index ae0db1be..00000000
--- a/api/src/test/resources/examples/applicantrequest.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-id: applicantrequest
-version: '1.0'
-specVersion: '0.8'
-name: Applicant Request Decision Workflow
-description: Determine if applicant request is valid
-start: CheckApplication
-functions:
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/applicationapi.json#emailRejection
-states:
- - name: CheckApplication
- type: switch
- dataConditions:
- - condition: "${ .applicants | .age >= 18 }"
- transition: StartApplication
- - condition: "${ .applicants | .age < 18 }"
- transition: RejectApplication
- defaultCondition:
- transition: RejectApplication
- - name: StartApplication
- type: operation
- actions:
- - subFlowRef: startApplicationWorkflowId
- end: true
- - name: RejectApplication
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .applicant }"
- end: true
diff --git a/api/src/test/resources/examples/booklending.json b/api/src/test/resources/examples/booklending.json
deleted file mode 100644
index 74089115..00000000
--- a/api/src/test/resources/examples/booklending.json
+++ /dev/null
@@ -1,130 +0,0 @@
-{
- "id": "booklending",
- "name": "Book Lending Workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "Book Lending Request",
- "states": [
- {
- "name": "Book Lending Request",
- "type": "event",
- "onEvents": [
- {
- "eventRefs": ["Book Lending Request Event"]
- }
- ],
- "transition": "Get Book Status"
- },
- {
- "name": "Get Book Status",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "Get status for book",
- "arguments": {
- "bookid": "${ .book.id }"
- }
- }
- }
- ],
- "transition": "Book Status Decision"
- },
- {
- "name": "Book Status Decision",
- "type": "switch",
- "dataConditions": [
- {
- "name": "Book is on loan",
- "condition": "${ .book.status == \"onloan\" }",
- "transition": "Report Status To Lender"
- },
- {
- "name": "Check is available",
- "condition": "${ .book.status == \"available\" }",
- "transition": "Check Out Book"
- }
- ]
- },
- {
- "name": "Report Status To Lender",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "Send status to lender",
- "arguments": {
- "bookid": "${ .book.id }",
- "message": "Book ${ .book.title } is already on loan"
- }
- }
- }
- ],
- "transition": "Wait for Lender response"
- },
- {
- "name": "Wait for Lender response",
- "type": "switch",
- "eventConditions": [
- {
- "name": "Hold Book",
- "eventRef": "Hold Book Event",
- "transition": "Request Hold"
- },
- {
- "name": "Decline Book Hold",
- "eventRef": "Decline Hold Event",
- "transition": "Cancel Request"
- }
- ]
- },
- {
- "name": "Request Hold",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "Request hold for lender",
- "arguments": {
- "bookid": "${ .book.id }",
- "lender": "${ .lender }"
- }
- }
- }
- ],
- "transition": "Wait two weeks"
- },
- {
- "name": "Sleep two weeks",
- "type": "sleep",
- "duration": "P2W",
- "transition": "Get Book Status"
- },
- {
- "name": "Check Out Book",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "Check out book with id",
- "arguments": {
- "bookid": "${ .book.id }"
- }
- }
- },
- {
- "functionRef": {
- "refName": "Notify Lender for checkout",
- "arguments": {
- "bookid": "${ .book.id }",
- "lender": "${ .lender }"
- }
- }
- }
- ],
- "end": true
- }
- ],
- "functions": "file://books/lending/functions.json",
- "events": "file://books/lending/events.json"
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/booklending.yml b/api/src/test/resources/examples/booklending.yml
deleted file mode 100644
index 7a8459e2..00000000
--- a/api/src/test/resources/examples/booklending.yml
+++ /dev/null
@@ -1,75 +0,0 @@
-id: booklending
-name: Book Lending Workflow
-version: '1.0'
-specVersion: '0.8'
-start: Book Lending Request
-states:
- - name: Book Lending Request
- type: event
- onEvents:
- - eventRefs:
- - Book Lending Request Event
- transition: Get Book Status
- - name: Get Book Status
- type: operation
- actions:
- - functionRef:
- refName: Get status for book
- arguments:
- bookid: "${ .book.id }"
- transition: Book Status Decision
- - name: Book Status Decision
- type: switch
- dataConditions:
- - name: Book is on loan
- condition: ${ .book.status == "onloan" }
- transition: Report Status To Lender
- - name: Check is available
- condition: ${ .book.status == "available" }
- transition: Check Out Book
- - name: Report Status To Lender
- type: operation
- actions:
- - functionRef:
- refName: Send status to lender
- arguments:
- bookid: "${ .book.id }"
- message: Book ${ .book.title } is already on loan
- transition: Wait for Lender response
- - name: Wait for Lender response
- type: switch
- eventConditions:
- - name: Hold Book
- eventRef: Hold Book Event
- transition: Request Hold
- - name: Decline Book Hold
- eventRef: Decline Hold Event
- transition: Cancel Request
- - name: Request Hold
- type: operation
- actions:
- - functionRef:
- refName: Request fold for lender
- arguments:
- bookid: "${ .book.id }"
- lender: "${ .lender }"
- transition: Wait two weeks
- - name: Wait two weeks
- type: sleep
- duration: P2W
- transition: Get Book Status
- - name: Check Out Book
- type: operation
- actions:
- - functionRef:
- refName: Check out book with id
- arguments:
- bookid: "${ .book.id }"
- - functionRef:
- refName: Notify Lender for checkout
- arguments:
- bookid: "${ .book.id }"
- lender: "${ .lender }"
- end: true
-functions: file://books/lending/functions.json
-events: file://books/lending/events.json
\ No newline at end of file
diff --git a/api/src/test/resources/examples/carauctionbids.json b/api/src/test/resources/examples/carauctionbids.json
deleted file mode 100644
index 7ea84d9a..00000000
--- a/api/src/test/resources/examples/carauctionbids.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "id": "handleCarAuctionBid",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Car Auction Bidding Workflow",
- "description": "Store a single bid whole the car auction is active",
- "start": {
- "stateName": "StoreCarAuctionBid",
- "schedule": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z"
- },
- "functions": [
- {
- "name": "StoreBidFunction",
- "operation": "http://myapis.org/carauctionapi.json#storeBid"
- }
- ],
- "events": [
- {
- "name": "CarBidEvent",
- "type": "carBidMadeType",
- "source": "carBidEventSource"
- }
- ],
- "states": [
- {
- "name": "StoreCarAuctionBid",
- "type": "event",
- "exclusive": true,
- "onEvents": [
- {
- "eventRefs": ["CarBidEvent"],
- "actions": [{
- "functionRef": {
- "refName": "StoreBidFunction",
- "arguments": {
- "bid": "${ .bid }"
- }
- }
- }]
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/carauctionbids.yml b/api/src/test/resources/examples/carauctionbids.yml
deleted file mode 100644
index adfe0d08..00000000
--- a/api/src/test/resources/examples/carauctionbids.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-id: handleCarAuctionBid
-version: '1.0'
-specVersion: '0.8'
-name: Car Auction Bidding Workflow
-description: Store a single bid whole the car auction is active
-start:
- stateName: StoreCarAuctionBid
- schedule: 2020-03-20T09:00:00Z/2020-03-20T15:00:00Z
-functions:
- - name: StoreBidFunction
- operation: http://myapis.org/carauctionapi.json#storeBid
-events:
- - name: CarBidEvent
- type: carBidMadeType
- source: carBidEventSource
-states:
- - name: StoreCarAuctionBid
- type: event
- exclusive: true
- onEvents:
- - eventRefs:
- - CarBidEvent
- actions:
- - functionRef:
- refName: StoreBidFunction
- arguments:
- bid: "${ .bid }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/examples/checkcarvitals.json b/api/src/test/resources/examples/checkcarvitals.json
deleted file mode 100644
index 973153fc..00000000
--- a/api/src/test/resources/examples/checkcarvitals.json
+++ /dev/null
@@ -1,122 +0,0 @@
-{
- "id": "vitalscheck",
- "name": "Car Vitals Check",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "CheckVitals",
- "states": [
- {
- "name": "CheckVitals",
- "type": "operation",
- "actions": [
- {
- "functionRef": "checkTirePressure"
- },
- {
- "functionRef": "checkOilPressure"
- },
- {
- "functionRef": "checkCoolantLevel"
- },
- {
- "functionRef": "checkBattery"
- }
- ],
- "transition": "EvaluateChecks"
- },
- {
- "name": "EvaluateChecks",
- "type": "switch",
- "dataConditions": [
- {
- "name": "Some Evaluations failed",
- "condition": ".evaluations[?(@.check == 'failed')]",
- "end": {
- "produceEvents": [
- {
- "eventRef": "DisplayFailedChecksOnDashboard",
- "data": "${ .evaluations }"
- }
- ]
-
- }
- }
- ],
- "defaultCondition": {
- "transition": "WaitTwoMinutes"
- }
- },
- {
- "name": "WaitTwoMinutes",
- "type": "event",
- "onEvents": [
- {
- "eventRefs": ["StopVitalsCheck"],
- "eventDataFilter": {
- "toStateData": "${ .stopReceived }"
- }
- }
- ],
- "timeouts": {
- "eventTimeout": "PT2M"
- },
- "transition": "ShouldStopOrContinue"
- },
- {
- "name": "ShouldStopOrContinue",
- "type": "switch",
- "dataConditions": [
- {
- "name": "Stop Event Received",
- "condition": "${ has(\"stopReceived\") }",
- "end": {
- "produceEvents": [
- {
- "eventRef": "VitalsCheckingStopped"
- }
- ]
-
- }
- }
- ],
- "defaultCondition": {
- "transition": "CheckVitals"
- }
- }
- ],
- "events": [
- {
- "name": "StopVitalsCheck",
- "type": "car.events",
- "source": "my/car"
- },
- {
- "name": "VitalsCheckingStopped",
- "type": "car.events",
- "source": "my/car"
- },
- {
- "name": "DisplayFailedChecksOnDashboard",
- "kind": "produced",
- "type": "my.car.events"
- }
- ],
- "functions": [
- {
- "name": "checkTirePressure",
- "operation": "mycarservices.json#checktirepressure"
- },
- {
- "name": "checkOilPressure",
- "operation": "mycarservices.json#checkoilpressure"
- },
- {
- "name": "checkCoolantLevel",
- "operation": "mycarservices.json#checkcoolantlevel"
- },
- {
- "name": "checkBattery",
- "operation": "mycarservices.json#checkbattery"
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/checkcarvitals.yml b/api/src/test/resources/examples/checkcarvitals.yml
deleted file mode 100644
index 31bd571a..00000000
--- a/api/src/test/resources/examples/checkcarvitals.yml
+++ /dev/null
@@ -1,64 +0,0 @@
-id: vitalscheck
-name: Car Vitals Check
-version: '1.0'
-specVersion: '0.8'
-start: CheckVitals
-states:
- - name: CheckVitals
- type: operation
- actions:
- - functionRef: checkTirePressure
- - functionRef: checkOilPressure
- - functionRef: checkCoolantLevel
- - functionRef: checkBattery
- transition: EvaluateChecks
- - name: EvaluateChecks
- type: switch
- dataConditions:
- - name: Some Evaluations failed
- condition: ".evaluations[?(@.check == 'failed')]"
- end:
- produceEvents:
- - eventRef: DisplayFailedChecksOnDashboard
- data: "${ .evaluations }"
- defaultCondition:
- transition: WaitTwoMinutes
- - name: WaitTwoMinutes
- type: event
- onEvents:
- - eventRefs:
- - StopVitalsCheck
- eventDataFilter:
- toStateData: "${ .stopReceived }"
- timeouts:
- eventTimeout: PT2M
- transition: ShouldStopOrContinue
- - name: ShouldStopOrContinue
- type: switch
- dataConditions:
- - name: Stop Event Received
- condition: ${ has("stopReceived") }
- end:
- produceEvents:
- - eventRef: VitalsCheckingStopped
- defaultCondition:
- transition: CheckVitals
-events:
- - name: StopVitalsCheck
- type: car.events
- source: my/car
- - name: VitalsCheckingStopped
- type: car.events
- source: my/car
- - name: DisplayFailedChecksOnDashboard
- kind: produced
- type: my.car.events
-functions:
- - name: checkTirePressure
- operation: mycarservices.json#checktirepressure
- - name: checkOilPressure
- operation: mycarservices.json#checkoilpressure
- - name: checkCoolantLevel
- operation: mycarservices.json#checkcoolantlevel
- - name: checkBattery
- operation: mycarservices.json#checkbattery
diff --git a/api/src/test/resources/examples/creditcheck.json b/api/src/test/resources/examples/creditcheck.json
deleted file mode 100644
index 466d2eb7..00000000
--- a/api/src/test/resources/examples/creditcheck.json
+++ /dev/null
@@ -1,92 +0,0 @@
-{
- "id": "customercreditcheck",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Customer Credit Check Workflow",
- "description": "Perform Customer Credit Check",
- "start": "CheckCredit",
- "functions": [
- {
- "name": "creditCheckFunction",
- "operation": "http://myapis.org/creditcheckapi.json#doCreditCheck"
- },
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/creditcheckapi.json#rejectionEmail"
- }
- ],
- "events": [
- {
- "name": "CreditCheckCompletedEvent",
- "type": "creditCheckCompleteType",
- "source": "creditCheckSource",
- "correlation": [
- {
- "contextAttributeName": "customerId"
- }
- ]
- }
- ],
- "states": [
- {
- "name": "CheckCredit",
- "type": "callback",
- "action": {
- "functionRef": {
- "refName": "callCreditCheckMicroservice",
- "arguments": {
- "customer": "${ .customer }"
- }
- }
- },
- "eventRef": "CreditCheckCompletedEvent",
- "timeouts": {
- "stateExecTimeout": "PT15M"
- },
- "transition": "EvaluateDecision"
- },
- {
- "name": "EvaluateDecision",
- "type": "switch",
- "dataConditions": [
- {
- "condition": "${ .creditCheck | .decision == \"Approved\" }",
- "transition": "StartApplication"
- },
- {
- "condition": "${ .creditCheck | .decision == \"Denied\" }",
- "transition": "RejectApplication"
- }
- ],
- "defaultCondition": {
- "transition": "RejectApplication"
- }
- },
- {
- "name": "StartApplication",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "startApplicationWorkflowId"
- }
- ],
- "end": true
- },
- {
- "name": "RejectApplication",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/creditcheck.yml b/api/src/test/resources/examples/creditcheck.yml
deleted file mode 100644
index 8831ada7..00000000
--- a/api/src/test/resources/examples/creditcheck.yml
+++ /dev/null
@@ -1,52 +0,0 @@
-id: customercreditcheck
-version: '1.0'
-specVersion: '0.8'
-name: Customer Credit Check Workflow
-description: Perform Customer Credit Check
-start: CheckCredit
-functions:
- - name: creditCheckFunction
- operation: http://myapis.org/creditcheckapi.json#doCreditCheck
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/creditcheckapi.json#rejectionEmail
-events:
- - name: CreditCheckCompletedEvent
- type: creditCheckCompleteType
- source: creditCheckSource
- correlation:
- - contextAttributeName: customerId
-states:
- - name: CheckCredit
- type: callback
- action:
- functionRef:
- refName: callCreditCheckMicroservice
- arguments:
- customer: "${ .customer }"
- eventRef: CreditCheckCompletedEvent
- timeouts:
- stateExecTimeout: PT15M
- transition: EvaluateDecision
- - name: EvaluateDecision
- type: switch
- dataConditions:
- - condition: ${ .creditCheck | .decision == "Approved" }
- transition: StartApplication
- - condition: ${ .creditCheck | .decision == "Denied" }
- transition: RejectApplication
- defaultCondition:
- transition: RejectApplication
- - name: StartApplication
- type: operation
- actions:
- - subFlowRef: startApplicationWorkflowId
- end: true
- - name: RejectApplication
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
diff --git a/api/src/test/resources/examples/eventbasedgreeting.json b/api/src/test/resources/examples/eventbasedgreeting.json
deleted file mode 100644
index efdc2c92..00000000
--- a/api/src/test/resources/examples/eventbasedgreeting.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- "id": "eventbasedgreeting",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Event Based Greeting Workflow",
- "description": "Event Based Greeting",
- "start": "Greet",
- "events": [
- {
- "name": "GreetingEvent",
- "type": "greetingEventType",
- "source": "greetingEventSource"
- }
- ],
- "functions": [
- {
- "name": "greetingFunction",
- "operation": "file://myapis/greetingapis.json#greeting"
- }
- ],
- "states":[
- {
- "name":"Greet",
- "type":"event",
- "onEvents": [{
- "eventRefs": ["GreetingEvent"],
- "eventDataFilter": {
- "data": "${ .data.greet }"
- },
- "actions":[
- {
- "functionRef": {
- "refName": "greetingFunction",
- "arguments": {
- "name": "${ .greet.name }"
- }
- }
- }
- ]
- }],
- "stateDataFilter": {
- "output": "${ .payload.greeting }"
- },
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/eventbasedgreeting.yml b/api/src/test/resources/examples/eventbasedgreeting.yml
deleted file mode 100644
index c18b61fe..00000000
--- a/api/src/test/resources/examples/eventbasedgreeting.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-id: eventbasedgreeting
-version: '1.0'
-specVersion: '0.8'
-name: Event Based Greeting Workflow
-description: Event Based Greeting
-start: Greet
-events:
- - name: GreetingEvent
- type: greetingEventType
- source: greetingEventSource
-functions:
- - name: greetingFunction
- operation: file://myapis/greetingapis.json#greeting
-states:
- - name: Greet
- type: event
- onEvents:
- - eventRefs:
- - GreetingEvent
- eventDataFilter:
- data: "${ .data.greet }"
- actions:
- - functionRef:
- refName: greetingFunction
- arguments:
- name: "${ .greet.name }"
- stateDataFilter:
- output: "${ .payload.greeting }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/examples/eventbasedtransition.json b/api/src/test/resources/examples/eventbasedtransition.json
deleted file mode 100644
index da0b8d6e..00000000
--- a/api/src/test/resources/examples/eventbasedtransition.json
+++ /dev/null
@@ -1,72 +0,0 @@
-{
- "id": "eventbasedswitch",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Event Based Switch Transitions",
- "description": "Event Based Switch Transitions",
- "start": "CheckVisaStatus",
- "events": [
- {
- "name": "visaApprovedEvent",
- "type": "VisaApproved",
- "source": "visaCheckSource"
- },
- {
- "name": "visaRejectedEvent",
- "type": "VisaRejected",
- "source": "visaCheckSource"
- }
- ],
- "states":[
- {
- "name":"CheckVisaStatus",
- "type":"switch",
- "eventConditions": [
- {
- "eventRef": "visaApprovedEvent",
- "transition": "HandleApprovedVisa"
- },
- {
- "eventRef": "visaRejectedEvent",
- "transition": "HandleRejectedVisa"
- }
- ],
- "timeouts": {
- "eventTimeout": "PT1H"
- },
- "defaultCondition": {
- "transition": "HandleNoVisaDecision"
- }
- },
- {
- "name": "HandleApprovedVisa",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleApprovedVisaWorkflowID"
- }
- ],
- "end": true
- },
- {
- "name": "HandleRejectedVisa",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleRejectedVisaWorkflowID"
- }
- ],
- "end": true
- },
- {
- "name": "HandleNoVisaDecision",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleNoVisaDecisionWorkflowId"
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/eventbasedtransition.yml b/api/src/test/resources/examples/eventbasedtransition.yml
deleted file mode 100644
index bb1203a1..00000000
--- a/api/src/test/resources/examples/eventbasedtransition.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-id: eventbasedswitch
-version: '1.0'
-specVersion: '0.8'
-name: Event Based Switch Transitions
-description: Event Based Switch Transitions
-start: CheckVisaStatus
-events:
- - name: visaApprovedEvent
- type: VisaApproved
- source: visaCheckSource
- - name: visaRejectedEvent
- type: VisaRejected
- source: visaCheckSource
-states:
- - name: CheckVisaStatus
- type: switch
- eventConditions:
- - eventRef: visaApprovedEvent
- transition: HandleApprovedVisa
- - eventRef: visaRejectedEvent
- transition: HandleRejectedVisa
- timeouts:
- eventTimeout: PT1H
- defaultCondition:
- transition: HandleNoVisaDecision
- - name: HandleApprovedVisa
- type: operation
- actions:
- - subFlowRef: handleApprovedVisaWorkflowID
- end: true
- - name: HandleRejectedVisa
- type: operation
- actions:
- - subFlowRef: handleRejectedVisaWorkflowID
- end: true
- - name: HandleNoVisaDecision
- type: operation
- actions:
- - subFlowRef: handleNoVisaDecisionWorkflowId
- end: true
diff --git a/api/src/test/resources/examples/finalizecollegeapplication.json b/api/src/test/resources/examples/finalizecollegeapplication.json
deleted file mode 100644
index 8fcb7670..00000000
--- a/api/src/test/resources/examples/finalizecollegeapplication.json
+++ /dev/null
@@ -1,74 +0,0 @@
-{
- "id": "finalizeCollegeApplication",
- "name": "Finalize College Application",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "FinalizeApplication",
- "events": [
- {
- "name": "ApplicationSubmitted",
- "type": "org.application.submitted",
- "source": "applicationsource",
- "correlation": [
- {
- "contextAttributeName": "applicantId"
- }
- ]
- },
- {
- "name": "SATScoresReceived",
- "type": "org.application.satscores",
- "source": "applicationsource",
- "correlation": [
- {
- "contextAttributeName": "applicantId"
- }
- ]
- },
- {
- "name": "RecommendationLetterReceived",
- "type": "org.application.recommendationLetter",
- "source": "applicationsource",
- "correlation": [
- {
- "contextAttributeName": "applicantId"
- }
- ]
- }
- ],
- "functions": [
- {
- "name": "finalizeApplicationFunction",
- "operation": "http://myapis.org/collegeapplicationapi.json#finalize"
- }
- ],
- "states": [
- {
- "name": "FinalizeApplication",
- "type": "event",
- "exclusive": false,
- "onEvents": [
- {
- "eventRefs": [
- "ApplicationSubmitted",
- "SATScoresReceived",
- "RecommendationLetterReceived"
- ],
- "actions": [
- {
- "functionRef": {
- "refName": "finalizeApplicationFunction",
- "arguments": {
- "student": "${ .applicantId }"
- }
- }
- }
- ]
- }
- ],
- "end": {
- "terminate": true
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/finalizecollegeapplication.yml b/api/src/test/resources/examples/finalizecollegeapplication.yml
deleted file mode 100644
index 0d2fd30c..00000000
--- a/api/src/test/resources/examples/finalizecollegeapplication.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-id: finalizeCollegeApplication
-name: Finalize College Application
-version: '1.0'
-specVersion: '0.8'
-start: FinalizeApplication
-events:
- - name: ApplicationSubmitted
- type: org.application.submitted
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: SATScoresReceived
- type: org.application.satscores
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: RecommendationLetterReceived
- type: org.application.recommendationLetter
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
-functions:
- - name: finalizeApplicationFunction
- operation: http://myapis.org/collegeapplicationapi.json#finalize
-states:
- - name: FinalizeApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
\ No newline at end of file
diff --git a/api/src/test/resources/examples/foreachstatewithactions.json b/api/src/test/resources/examples/foreachstatewithactions.json
deleted file mode 100644
index e9953705..00000000
--- a/api/src/test/resources/examples/foreachstatewithactions.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "id": "foreachstatewithactions",
- "name": "ForEach State With Actions",
- "description": "ForEach State With Actions",
- "version": "1.0",
- "specVersion": "0.8",
- "functions": [
- {
- "name": "sendConfirmationFunction",
- "operation": "http://myapis.org/confirmationapi.json#sendConfirmation"
- }
- ],
- "states": [
- {
- "name":"SendConfirmationForEachCompletedhOrder",
- "type":"foreach",
- "inputCollection": "${ .orders[?(@.completed == true)] }",
- "iterationParam": "${ .completedorder }",
- "actions":[
- {
- "functionRef": {
- "refName": "sendConfirmationFunction",
- "arguments": {
- "orderNumber": "${ .completedorder.orderNumber }",
- "email": "${ .completedorder.email }"
- }
- }
- }],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/foreachstatewithactions.yml b/api/src/test/resources/examples/foreachstatewithactions.yml
deleted file mode 100644
index dfbcf4aa..00000000
--- a/api/src/test/resources/examples/foreachstatewithactions.yml
+++ /dev/null
@@ -1,21 +0,0 @@
----
-id: foreachstatewithactions
-name: ForEach State With Actions
-description: ForEach State With Actions
-version: '1.0'
-specVersion: '0.8'
-functions:
- - name: sendConfirmationFunction
- operation: http://myapis.org/confirmationapi.json#sendConfirmation
-states:
- - name: SendConfirmationForEachCompletedhOrder
- type: foreach
- inputCollection: "${ .orders[?(@.completed == true)] }"
- iterationParam: "${ .completedorder }"
- actions:
- - functionRef:
- refName: sendConfirmationFunction
- arguments:
- orderNumber: "${ .completedorder.orderNumber }"
- email: "${ .completedorder.email }"
- end: true
diff --git a/api/src/test/resources/examples/greeting.json b/api/src/test/resources/examples/greeting.json
deleted file mode 100644
index f9138d90..00000000
--- a/api/src/test/resources/examples/greeting.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "id": "greeting",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Greeting Workflow",
- "description": "Greet Someone",
- "start": "Greet",
- "functions": [
- {
- "name": "greetingFunction",
- "operation": "file://myapis/greetingapis.json#greeting"
- }
- ],
- "states":[
- {
- "name":"Greet",
- "type":"operation",
- "actions":[
- {
- "functionRef": {
- "refName": "greetingFunction",
- "arguments": {
- "name": "${ .person.name }"
- }
- },
- "actionDataFilter": {
- "results": "${ .greeting }"
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/greeting.yml b/api/src/test/resources/examples/greeting.yml
deleted file mode 100644
index ceb14ae0..00000000
--- a/api/src/test/resources/examples/greeting.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-id: greeting
-version: '1.0'
-specVersion: '0.8'
-name: Greeting Workflow
-description: Greet Someone
-start: Greet
-functions:
- - name: greetingFunction
- operation: file://myapis/greetingapis.json#greeting
-states:
- - name: Greet
- type: operation
- actions:
- - functionRef:
- refName: greetingFunction
- arguments:
- name: "${ .person.name }"
- actionDataFilter:
- results: "${ .greeting }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/examples/helloworld.json b/api/src/test/resources/examples/helloworld.json
deleted file mode 100644
index c8d48ca8..00000000
--- a/api/src/test/resources/examples/helloworld.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "id": "helloworld",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Hello World Workflow",
- "description": "Inject Hello World",
- "start": "Hello State",
- "states":[
- {
- "name":"Hello State",
- "type":"inject",
- "data": {
- "result": "Hello World!"
- },
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/helloworld.yml b/api/src/test/resources/examples/helloworld.yml
deleted file mode 100644
index 32a84296..00000000
--- a/api/src/test/resources/examples/helloworld.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-id: helloworld
-version: '1.0'
-specVersion: '0.8'
-name: Hello World Workflow
-description: Inject Hello World
-start: Hello State
-states:
- - name: Hello State
- type: inject
- data:
- result: Hello World!
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/examples/jobmonitoring.json b/api/src/test/resources/examples/jobmonitoring.json
deleted file mode 100644
index 8b0b8e9c..00000000
--- a/api/src/test/resources/examples/jobmonitoring.json
+++ /dev/null
@@ -1,143 +0,0 @@
-{
- "id": "jobmonitoring",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Job Monitoring",
- "description": "Monitor finished execution of a submitted job",
- "start": "SubmitJob",
- "functions": [
- {
- "name": "submitJob",
- "operation": "http://myapis.org/monitorapi.json#doSubmit"
- },
- {
- "name": "checkJobStatus",
- "operation": "http://myapis.org/monitorapi.json#checkStatus"
- },
- {
- "name": "reportJobSuceeded",
- "operation": "http://myapis.org/monitorapi.json#reportSucceeded"
- },
- {
- "name": "reportJobFailed",
- "operation": "http://myapis.org/monitorapi.json#reportFailure"
- }
- ],
- "states":[
- {
- "name":"SubmitJob",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "submitJob",
- "arguments": {
- "name": "${ .job.name }"
- }
- },
- "actionDataFilter": {
- "results": "${ .jobuid }"
- }
- }
- ],
- "onErrors": [
- {
- "errorRef": "AllErrors",
- "transition": "SubmitError"
- }
- ],
- "stateDataFilter": {
- "output": "${ .jobuid }"
- },
- "transition": "WaitForCompletion"
- },
- {
- "name": "SubmitError",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleJobSubmissionErrorWorkflow"
- }
- ],
- "end": true
- },
- {
- "name": "WaitForCompletion",
- "type": "sleep",
- "duration": "PT5S",
- "transition": "GetJobStatus"
- },
- {
- "name":"GetJobStatus",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "checkJobStatus",
- "arguments": {
- "name": "${ .jobuid }"
- }
- },
- "actionDataFilter": {
- "results": "${ .jobstatus }"
- }
- }
- ],
- "stateDataFilter": {
- "output": "${ .jobstatus }"
- },
- "transition": "DetermineCompletion"
- },
- {
- "name":"DetermineCompletion",
- "type":"switch",
- "dataConditions": [
- {
- "condition": "${ .jobStatus == \"SUCCEEDED\" }",
- "transition": "JobSucceeded"
- },
- {
- "condition": "${ .jobStatus == \"FAILED\" }",
- "transition": "JobFailed"
- }
- ],
- "defaultCondition": {
- "transition": "WaitForCompletion"
- }
- },
- {
- "name":"JobSucceeded",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "reportJobSuceeded",
- "arguments": {
- "name": "${ .jobuid }"
- }
- }
- }
- ],
- "end": true
- },
- {
- "name":"JobFailed",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "reportJobFailed",
- "arguments": {
- "name": "${ .jobuid }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/jobmonitoring.yml b/api/src/test/resources/examples/jobmonitoring.yml
deleted file mode 100644
index eab235d5..00000000
--- a/api/src/test/resources/examples/jobmonitoring.yml
+++ /dev/null
@@ -1,81 +0,0 @@
-id: jobmonitoring
-version: '1.0'
-specVersion: '0.8'
-name: Job Monitoring
-description: Monitor finished execution of a submitted job
-start: SubmitJob
-functions:
- - name: submitJob
- operation: http://myapis.org/monitorapi.json#doSubmit
- - name: checkJobStatus
- operation: http://myapis.org/monitorapi.json#checkStatus
- - name: reportJobSuceeded
- operation: http://myapis.org/monitorapi.json#reportSucceeded
- - name: reportJobFailed
- operation: http://myapis.org/monitorapi.json#reportFailure
-states:
- - name: SubmitJob
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: submitJob
- arguments:
- name: "${ .job.name }"
- actionDataFilter:
- results: "${ .jobuid }"
- onErrors:
- - errorRef: "AllErrors"
- transition: SubmitError
- stateDataFilter:
- output: "${ .jobuid }"
- transition: WaitForCompletion
- - name: SubmitError
- type: operation
- actions:
- - subFlowRef: handleJobSubmissionErrorWorkflow
- end: true
- - name: WaitForCompletion
- type: sleep
- duration: PT5S
- transition: GetJobStatus
- - name: GetJobStatus
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: checkJobStatus
- arguments:
- name: "${ .jobuid }"
- actionDataFilter:
- results: "${ .jobstatus }"
- stateDataFilter:
- output: "${ .jobstatus }"
- transition: DetermineCompletion
- - name: DetermineCompletion
- type: switch
- dataConditions:
- - condition: ${ .jobStatus == "SUCCEEDED" }
- transition: JobSucceeded
- - condition: ${ .jobStatus == "FAILED" }
- transition: JobFailed
- defaultCondition:
- transition: WaitForCompletion
- - name: JobSucceeded
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: reportJobSuceeded
- arguments:
- name: "${ .jobuid }"
- end: true
- - name: JobFailed
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: reportJobFailed
- arguments:
- name: "${ .jobuid }"
- end: true
diff --git a/api/src/test/resources/examples/monitorpatient.json b/api/src/test/resources/examples/monitorpatient.json
deleted file mode 100644
index 594bf18c..00000000
--- a/api/src/test/resources/examples/monitorpatient.json
+++ /dev/null
@@ -1,96 +0,0 @@
-{
- "id": "patientVitalsWorkflow",
- "name": "Monitor Patient Vitals",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "MonitorVitals",
- "events": [
- {
- "name": "HighBodyTemperature",
- "type": "org.monitor.highBodyTemp",
- "source": "monitoringSource",
- "correlation": [
- {
- "contextAttributeName": "patientId"
- }
- ]
- },
- {
- "name": "HighBloodPressure",
- "type": "org.monitor.highBloodPressure",
- "source": "monitoringSource",
- "correlation": [
- {
- "contextAttributeName": "patientId"
- }
- ]
- },
- {
- "name": "HighRespirationRate",
- "type": "org.monitor.highRespirationRate",
- "source": "monitoringSource",
- "correlation": [
- {
- "contextAttributeName": "patientId"
- }
- ]
- }
- ],
- "functions": [
- {
- "name": "callPulmonologist",
- "operation": "http://myapis.org/patientapis.json#callPulmonologist"
- },
- {
- "name": "sendTylenolOrder",
- "operation": "http://myapis.org/patientapis.json#tylenolOrder"
- },
- {
- "name": "callNurse",
- "operation": "http://myapis.org/patientapis.json#callNurse"
- }
- ],
- "states": [
- {
- "name": "MonitorVitals",
- "type": "event",
- "exclusive": true,
- "onEvents": [{
- "eventRefs": ["HighBodyTemperature"],
- "actions": [{
- "functionRef": {
- "refName": "sendTylenolOrder",
- "arguments": {
- "patientid": "${ .patientId }"
- }
- }
- }]
- },
- {
- "eventRefs": ["HighBloodPressure"],
- "actions": [{
- "functionRef": {
- "refName": "callNurse",
- "arguments": {
- "patientid": "${ .patientId }"
- }
- }
- }]
- },
- {
- "eventRefs": ["HighRespirationRate"],
- "actions": [{
- "functionRef": {
- "refName": "callPulmonologist",
- "arguments": {
- "patientid": "${ .patientId }"
- }
- }
- }]
- }
- ],
- "end": {
- "terminate": true
- }
- }]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/monitorpatient.yml b/api/src/test/resources/examples/monitorpatient.yml
deleted file mode 100644
index 034bc0ec..00000000
--- a/api/src/test/resources/examples/monitorpatient.yml
+++ /dev/null
@@ -1,56 +0,0 @@
-id: patientVitalsWorkflow
-name: Monitor Patient Vitals
-version: '1.0'
-specVersion: '0.8'
-start: Monitor Vitals
-events:
- - name: HighBodyTemperature
- type: org.monitor.highBodyTemp
- source: monitoringSource
- correlation:
- - contextAttributeName: patientId
- - name: HighBloodPressure
- type: org.monitor.highBloodPressure
- source: monitoringSource
- correlation:
- - contextAttributeName: patientId
- - name: HighRespirationRate
- type: org.monitor.highRespirationRate
- source: monitoringSource
- correlation:
- - contextAttributeName: patientId
-functions:
- - name: callPulmonologist
- operation: http://myapis.org/patientapis.json#callPulmonologist
- - name: sendTylenolOrder
- operation: http://myapis.org/patientapis.json#tylenolOrder
- - name: callNurse
- operation: http://myapis.org/patientapis.json#callNurse
-states:
- - name: MonitorVitals
- type: event
- exclusive: true
- onEvents:
- - eventRefs:
- - HighBodyTemperature
- actions:
- - functionRef:
- refName: sendTylenolOrder
- arguments:
- patientid: "${ .patientId }"
- - eventRefs:
- - HighBloodPressure
- actions:
- - functionRef:
- refName: callNurse
- arguments:
- patientid: "${ .patientId }"
- - eventRefs:
- - HighRespirationRate
- actions:
- - functionRef:
- refName: callPulmonologist
- arguments:
- patientid: "${ .patientId }"
- end:
- terminate: true
\ No newline at end of file
diff --git a/api/src/test/resources/examples/parallel.json b/api/src/test/resources/examples/parallel.json
deleted file mode 100644
index 1d614f50..00000000
--- a/api/src/test/resources/examples/parallel.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "id": "parallelexec",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Parallel Execution Workflow",
- "description": "Executes two branches in parallel",
- "start": "ParallelExec",
- "states":[
- {
- "name": "ParallelExec",
- "type": "parallel",
- "completionType": "allOf",
- "branches": [
- {
- "name": "ShortDelayBranch"
- },
- {
- "name": "LongDelayBranch"
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/parallel.yml b/api/src/test/resources/examples/parallel.yml
deleted file mode 100644
index 5a586cdf..00000000
--- a/api/src/test/resources/examples/parallel.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-id: parallelexec
-version: '1.0'
-specVersion: '0.8'
-name: Parallel Execution Workflow
-description: Executes two branches in parallel
-start: ParallelExec
-states:
- - name: ParallelExec
- type: parallel
- completionType: allOf
- branches:
- - name: ShortDelayBranch
- - name: LongDelayBranch
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/examples/periodicinboxcheck.json b/api/src/test/resources/examples/periodicinboxcheck.json
deleted file mode 100644
index 6c1ecc96..00000000
--- a/api/src/test/resources/examples/periodicinboxcheck.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "id": "checkInbox",
- "name": "Check Inbox Workflow",
- "description": "Periodically Check Inbox",
- "start": {
- "stateName": "CheckInbox",
- "schedule": {
- "cron": "0 0/15 * * * ?"
- }
- },
- "version": "1.0",
- "specVersion": "0.8",
- "functions": [
- {
- "name": "checkInboxFunction",
- "operation": "http://myapis.org/inboxapi.json#checkNewMessages"
- },
- {
- "name": "sendTextFunction",
- "operation": "http://myapis.org/inboxapi.json#sendText"
- }
- ],
- "states": [
- {
- "name": "CheckInbox",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "checkInboxFunction"
- }
- ],
- "transition": "SendTextForHighPriority"
- },
- {
- "name": "SendTextForHighPriority",
- "type": "foreach",
- "inputCollection": "${ .messages }",
- "iterationParam": "singlemessage",
- "actions": [
- {
- "functionRef": {
- "refName": "sendTextFunction",
- "arguments": {
- "message": "${ .singlemessage }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/periodicinboxcheck.yml b/api/src/test/resources/examples/periodicinboxcheck.yml
deleted file mode 100644
index d04932e6..00000000
--- a/api/src/test/resources/examples/periodicinboxcheck.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-id: checkInbox
-name: Check Inbox Workflow
-description: Periodically Check Inbox
-start:
- stateName: CheckInbox
- schedule:
- cron: 0 0/15 * * * ?
-version: '1.0'
-specVersion: '0.8'
-functions:
- - name: checkInboxFunction
- operation: http://myapis.org/inboxapi.json#checkNewMessages
- - name: sendTextFunction
- operation: http://myapis.org/inboxapi.json#sendText
-states:
- - name: CheckInbox
- type: operation
- actionMode: sequential
- actions:
- - functionRef: checkInboxFunction
- transition: SendTextForHighPriority
- - name: SendTextForHighPriority
- type: foreach
- inputCollection: "${ .messages }"
- iterationParam: singlemessage
- actions:
- - functionRef:
- refName: sendTextFunction
- arguments:
- message: "${ .singlemessage }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/examples/provisionorder.json b/api/src/test/resources/examples/provisionorder.json
deleted file mode 100644
index 57d3b33a..00000000
--- a/api/src/test/resources/examples/provisionorder.json
+++ /dev/null
@@ -1,89 +0,0 @@
-{
- "id": "provisionorders",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Provision Orders",
- "description": "Provision Orders and handle errors thrown",
- "start": "ProvisionOrder",
- "functions": [
- {
- "name": "provisionOrderFunction",
- "operation": "http://myapis.org/provisioningapi.json#doProvision"
- }
- ],
- "states":[
- {
- "name":"ProvisionOrder",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "provisionOrderFunction",
- "arguments": {
- "order": "${ .order }"
- }
- }
- }
- ],
- "stateDataFilter": {
- "output": "${ .exceptions }"
- },
- "transition": "ApplyOrder",
- "onErrors": [
- {
- "errorRef": "Missing order id",
- "transition": "MissingId"
- },
- {
- "errorRef": "Missing order item",
- "transition": "MissingItem"
- },
- {
- "errorRef": "Missing order quantity",
- "transition": "MissingQuantity"
- }
- ]
- },
- {
- "name": "MissingId",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleMissingIdExceptionWorkflow"
- }
- ],
- "end": true
- },
- {
- "name": "MissingItem",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleMissingItemExceptionWorkflow"
- }
- ],
- "end": true
- },
- {
- "name": "MissingQuantity",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleMissingQuantityExceptionWorkflow"
- }
- ],
- "end": true
- },
- {
- "name": "ApplyOrder",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "applyOrderWorkflowId"
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/provisionorder.yml b/api/src/test/resources/examples/provisionorder.yml
deleted file mode 100644
index 7233e5c3..00000000
--- a/api/src/test/resources/examples/provisionorder.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-id: provisionorders
-version: '1.0'
-specVersion: '0.8'
-name: Provision Orders
-description: Provision Orders and handle errors thrown
-start: ProvisionOrder
-functions:
- - name: provisionOrderFunction
- operation: http://myapis.org/provisioningapi.json#doProvision
-states:
- - name: ProvisionOrder
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: provisionOrderFunction
- arguments:
- order: "${ .order }"
- stateDataFilter:
- output: "${ .exceptions }"
- transition: ApplyOrder
- onErrors:
- - errorRef: Missing order id
- transition: MissingId
- - errorRef: Missing order item
- transition: MissingItem
- - errorRef: Missing order quantity
- transition: MissingQuantity
- - name: MissingId
- type: operation
- actions:
- - subFlowRef: handleMissingIdExceptionWorkflow
- end: true
- - name: MissingItem
- type: operation
- actions:
- - subFlowRef: handleMissingItemExceptionWorkflow
- end: true
- - name: MissingQuantity
- type: operation
- actions:
- - subFlowRef: handleMissingQuantityExceptionWorkflow
- end: true
- - name: ApplyOrder
- type: operation
- actions:
- - subFlowRef: applyOrderWorkflowId
- end: true
diff --git a/api/src/test/resources/examples/roomreadings.json b/api/src/test/resources/examples/roomreadings.json
deleted file mode 100644
index 14f58b9b..00000000
--- a/api/src/test/resources/examples/roomreadings.json
+++ /dev/null
@@ -1,85 +0,0 @@
-{
- "id": "roomreadings",
- "name": "Room Temp and Humidity Workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "ConsumeReading",
- "timeouts": {
- "workflowExecTimeout": {
- "duration": "PT1H",
- "runBefore": "GenerateReport"
- }
- },
- "keepActive": true,
- "states": [
- {
- "name": "ConsumeReading",
- "type": "event",
- "onEvents": [
- {
- "eventRefs": ["TemperatureEvent", "HumidityEvent"],
- "actions": [
- {
- "functionRef": {
- "refName": "LogReading"
- }
- }
- ],
- "eventDataFilter": {
- "data": "${ .readings }"
- }
- }
- ],
- "end": true
- },
- {
- "name": "GenerateReport",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "ProduceReport",
- "arguments": {
- "data": "${ .readings }"
- }
- }
- }
- ],
- "end": {
- "terminate": true
- }
- }
- ],
- "events": [
- {
- "name": "TemperatureEvent",
- "type": "my.home.sensors",
- "source": "/home/rooms/+",
- "correlation": [
- {
- "contextAttributeName": "roomId"
- }
- ]
- },
- {
- "name": "HumidityEvent",
- "type": "my.home.sensors",
- "source": "/home/rooms/+",
- "correlation": [
- {
- "contextAttributeName": "roomId"
- }
- ]
- }
- ],
- "functions": [
- {
- "name": "LogReading",
- "operation": "http.myorg.io/ordersservices.json#logreading"
- },
- {
- "name": "ProduceReport",
- "operation": "http.myorg.io/ordersservices.json#produceReport"
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/roomreadings.yml b/api/src/test/resources/examples/roomreadings.yml
deleted file mode 100644
index 948de4a0..00000000
--- a/api/src/test/resources/examples/roomreadings.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-id: roomreadings
-name: Room Temp and Humidity Workflow
-version: '1.0'
-specVersion: '0.8'
-start: ConsumeReading
-timeouts:
- workflowExecTimeout:
- duration: PT1H
- runBefore: GenerateReport
-keepActive: true
-states:
- - name: ConsumeReading
- type: event
- onEvents:
- - eventRefs:
- - TemperatureEvent
- - HumidityEvent
- actions:
- - functionRef:
- refName: LogReading
- eventDataFilter:
- data: "${ .readings }"
- end: true
- - name: GenerateReport
- type: operation
- actions:
- - functionRef:
- refName: ProduceReport
- arguments:
- data: "${ .readings }"
- end:
- terminate: true
-events:
- - name: TemperatureEvent
- type: my.home.sensors
- source: "/home/rooms/+"
- correlation:
- - contextAttributeName: roomId
- - name: HumidityEvent
- type: my.home.sensors
- source: "/home/rooms/+"
- correlation:
- - contextAttributeName: roomId
-functions:
- - name: LogReading
- operation: http.myorg.io/ordersservices.json#logreading
- - name: ProduceReport
- operation: http.myorg.io/ordersservices.json#produceReport
diff --git a/api/src/test/resources/examples/sendcloudevent.json b/api/src/test/resources/examples/sendcloudevent.json
deleted file mode 100644
index 14cd9cad..00000000
--- a/api/src/test/resources/examples/sendcloudevent.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "id": "sendcloudeventonprovision",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Send CloudEvent on provision completion",
- "start": "ProvisionOrdersState",
- "events": [
- {
- "name": "provisioningCompleteEvent",
- "type": "provisionCompleteType",
- "kind": "produced"
- }
- ],
- "functions": [
- {
- "name": "provisionOrderFunction",
- "operation": "http://myapis.org/provisioning.json#doProvision"
- }
- ],
- "states": [
- {
- "name": "ProvisionOrdersState",
- "type": "foreach",
- "inputCollection": "${ .orders }",
- "iterationParam": "singleorder",
- "outputCollection": "${ .provisionedOrders }",
- "actions": [
- {
- "functionRef": {
- "refName": "provisionOrderFunction",
- "arguments": {
- "order": "${ .singleorder }"
- }
- }
- }
- ],
- "end": {
- "produceEvents": [{
- "eventRef": "provisioningCompleteEvent",
- "data": "${ .provisionedOrders }"
- }]
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/sendcloudevent.yml b/api/src/test/resources/examples/sendcloudevent.yml
deleted file mode 100644
index 037b0648..00000000
--- a/api/src/test/resources/examples/sendcloudevent.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-id: sendcloudeventonprovision
-version: '1.0'
-specVersion: '0.8'
-name: Send CloudEvent on provision completion
-start: ProvisionOrdersState
-events:
- - name: provisioningCompleteEvent
- type: provisionCompleteType
- kind: produced
-functions:
- - name: provisionOrderFunction
- operation: http://myapis.org/provisioning.json#doProvision
-states:
- - name: ProvisionOrdersState
- type: foreach
- inputCollection: "${ .orders }"
- iterationParam: singleorder
- outputCollection: "${ .provisionedOrders }"
- actions:
- - functionRef:
- refName: provisionOrderFunction
- arguments:
- order: "${ .singleorder }"
- end:
- produceEvents:
- - eventRef: provisioningCompleteEvent
- data: "${ .provisionedOrders }"
\ No newline at end of file
diff --git a/api/src/test/resources/examples/solvemathproblems.json b/api/src/test/resources/examples/solvemathproblems.json
deleted file mode 100644
index 29c9de38..00000000
--- a/api/src/test/resources/examples/solvemathproblems.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "id": "solvemathproblems",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Solve Math Problems Workflow",
- "description": "Solve math problems",
- "start": "Solve",
- "functions": [
- {
- "name": "solveMathExpressionFunction",
- "operation": "http://myapis.org/mapthapis.json#solveExpression"
- }
- ],
- "states":[
- {
- "name":"Solve",
- "type":"foreach",
- "inputCollection": "${ .expressions }",
- "iterationParam": "singleexpression",
- "outputCollection": "${ .results }",
- "actions":[
- {
- "functionRef": {
- "refName": "solveMathExpressionFunction",
- "arguments": {
- "expression": "${ .singleexpression }"
- }
- }
- }
- ],
- "stateDataFilter": {
- "output": "${ .results }"
- },
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/solvemathproblems.yml b/api/src/test/resources/examples/solvemathproblems.yml
deleted file mode 100644
index 883c3e1b..00000000
--- a/api/src/test/resources/examples/solvemathproblems.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-id: solvemathproblems
-version: '1.0'
-specVersion: '0.8'
-name: Solve Math Problems Workflow
-description: Solve math problems
-start: Solve
-functions:
- - name: solveMathExpressionFunction
- operation: http://myapis.org/mapthapis.json#solveExpression
-states:
- - name: Solve
- type: foreach
- inputCollection: "${ .expressions }"
- iterationParam: singleexpression
- outputCollection: "${ .results }"
- actions:
- - functionRef:
- refName: solveMathExpressionFunction
- arguments:
- expression: "${ .singleexpression }"
- stateDataFilter:
- output: "${ .results }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/examples/vetappointmentservice.json b/api/src/test/resources/examples/vetappointmentservice.json
deleted file mode 100644
index 92db914e..00000000
--- a/api/src/test/resources/examples/vetappointmentservice.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "id": "VetAppointmentWorkflow",
- "name": "Vet Appointment Workflow",
- "description": "Vet service call via events",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "MakeVetAppointmentState",
- "events": [
- {
- "name": "MakeVetAppointment",
- "source": "VetServiceSoure",
- "kind": "produced"
- },
- {
- "name": "VetAppointmentInfo",
- "source": "VetServiceSource",
- "kind": "consumed"
- }
- ],
- "states": [
- {
- "name": "MakeVetAppointmentState",
- "type": "operation",
- "actions": [
- {
- "name": "MakeAppointmentAction",
- "eventRef": {
- "triggerEventRef": "MakeVetAppointment",
- "data": "${ .patientInfo }",
- "resultEventRef": "VetAppointmentInfo"
- },
- "actionDataFilter": {
- "results": "${ .appointmentInfo }"
- }
- }
- ],
- "timeouts": {
- "actionExecTimeout": "PT15M"
- },
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/examples/vetappointmentservice.yml b/api/src/test/resources/examples/vetappointmentservice.yml
deleted file mode 100644
index d102f32b..00000000
--- a/api/src/test/resources/examples/vetappointmentservice.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-id: VetAppointmentWorkflow
-name: Vet Appointment Workflow
-description: Vet service call via events
-version: '1.0'
-specVersion: '0.8'
-start: MakeVetAppointmentState
-events:
- - name: MakeVetAppointment
- source: VetServiceSoure
- kind: produced
- - name: VetAppointmentInfo
- source: VetServiceSource
- kind: consumed
-states:
- - name: MakeVetAppointmentState
- type: operation
- actions:
- - name: MakeAppointmentAction
- eventRef:
- triggerEventRef: MakeVetAppointment
- data: "${ .patientInfo }"
- resultEventRef: VetAppointmentInfo
- actionDataFilter:
- results: "${ .appointmentInfo }"
- timeouts:
- actionExecTimeout: PT15M
- end: true
diff --git a/api/src/test/resources/features/actionssleep.json b/api/src/test/resources/features/actionssleep.json
deleted file mode 100644
index 8f422ef5..00000000
--- a/api/src/test/resources/features/actionssleep.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- "id": "functionrefs",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Customer Credit Check Workflow",
- "description": "Perform Customer Credit Check",
- "start": "TestFunctionRef",
- "functions": [
- {
- "name": "creditCheckFunction",
- "operation": "http://myapis.org/creditcheckapi.json#doCreditCheck"
- },
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/creditcheckapi.json#rejectionEmail"
- }
- ],
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction",
- "sleep": {
- "before": "PT5S",
- "after": "PT10S"
- }
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- },
- "sleep": {
- "before": "PT5S",
- "after": "PT10S"
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/actionssleep.yml b/api/src/test/resources/features/actionssleep.yml
deleted file mode 100644
index 9bfbe9a7..00000000
--- a/api/src/test/resources/features/actionssleep.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-id: functionrefs
-version: '1.0'
-specVersion: '0.8'
-name: Customer Credit Check Workflow
-description: Perform Customer Credit Check
-start: TestFunctionRef
-functions:
- - name: creditCheckFunction
- operation: http://myapis.org/creditcheckapi.json#doCreditCheck
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/creditcheckapi.json#rejectionEmail
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- sleep:
- before: PT5S
- after: PT10S
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- sleep:
- before: PT5S
- after: PT10S
- end: true
diff --git a/api/src/test/resources/features/annotations.json b/api/src/test/resources/features/annotations.json
deleted file mode 100644
index 90ed6dd1..00000000
--- a/api/src/test/resources/features/annotations.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "id" : "test-workflow",
- "name" : "test-workflow-name",
- "version" : "1.0",
- "annotations": ["a", "b", "c", "d"]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/annotations.yml b/api/src/test/resources/features/annotations.yml
deleted file mode 100644
index 54e359ae..00000000
--- a/api/src/test/resources/features/annotations.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-id: test-workflow
-name: test-workflow-name
-version: '1.0'
-annotations:
- - a
- - b
- - c
- - d
diff --git a/api/src/test/resources/features/applicantrequest-with-id-and-key.json b/api/src/test/resources/features/applicantrequest-with-id-and-key.json
deleted file mode 100644
index 405d7c36..00000000
--- a/api/src/test/resources/features/applicantrequest-with-id-and-key.json
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- "id": "applicant-with-key-and-id",
- "key": "applicant-key-request",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Applicant Request Decision Workflow",
- "description": "Determine if applicant request is valid",
- "start": "CheckApplication",
- "functions": [
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/applicationapi.json#emailRejection"
- }
- ],
- "states":[
- {
- "name":"CheckApplication",
- "type":"switch",
- "dataConditions": [
- {
- "condition": "${ .applicants | .age >= 18 }",
- "transition": "StartApplication"
- },
- {
- "condition": "${ .applicants | .age < 18 }",
- "transition": "RejectApplication"
- }
- ],
- "defaultCondition": {
- "transition": "RejectApplication"
- }
- },
- {
- "name": "StartApplication",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "startApplicationWorkflowId"
- }
- ],
- "end": true
- },
- {
- "name":"RejectApplication",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .applicant }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/applicantrequest-with-id-and-key.yml b/api/src/test/resources/features/applicantrequest-with-id-and-key.yml
deleted file mode 100644
index 8a123663..00000000
--- a/api/src/test/resources/features/applicantrequest-with-id-and-key.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-id: applicant-with-key-and-id
-key: applicant-key-request
-version: '1.0'
-specVersion: '0.8'
-name: Applicant Request Decision Workflow
-description: Determine if applicant request is valid
-start: CheckApplication
-functions:
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/applicationapi.json#emailRejection
-states:
- - name: CheckApplication
- type: switch
- dataConditions:
- - condition: "${ .applicants | .age >= 18 }"
- transition: StartApplication
- - condition: "${ .applicants | .age < 18 }"
- transition: RejectApplication
- defaultCondition:
- transition: RejectApplication
- - name: StartApplication
- type: operation
- actions:
- - subFlowRef: startApplicationWorkflowId
- end: true
- - name: RejectApplication
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .applicant }"
- end: true
diff --git a/api/src/test/resources/features/applicantrequest-with-key.json b/api/src/test/resources/features/applicantrequest-with-key.json
deleted file mode 100644
index f0481b00..00000000
--- a/api/src/test/resources/features/applicantrequest-with-key.json
+++ /dev/null
@@ -1,59 +0,0 @@
-{
- "key": "applicant-key-request",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Applicant Request Decision Workflow",
- "description": "Determine if applicant request is valid",
- "start": "CheckApplication",
- "functions": [
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/applicationapi.json#emailRejection"
- }
- ],
- "states":[
- {
- "name":"CheckApplication",
- "type":"switch",
- "dataConditions": [
- {
- "condition": "${ .applicants | .age >= 18 }",
- "transition": "StartApplication"
- },
- {
- "condition": "${ .applicants | .age < 18 }",
- "transition": "RejectApplication"
- }
- ],
- "defaultCondition": {
- "transition": "RejectApplication"
- }
- },
- {
- "name": "StartApplication",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "startApplicationWorkflowId"
- }
- ],
- "end": true
- },
- {
- "name":"RejectApplication",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .applicant }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/applicantrequest-with-key.yml b/api/src/test/resources/features/applicantrequest-with-key.yml
deleted file mode 100644
index 85beed74..00000000
--- a/api/src/test/resources/features/applicantrequest-with-key.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-key: applicant-key-request
-version: '1.0'
-specVersion: '0.8'
-name: Applicant Request Decision Workflow
-description: Determine if applicant request is valid
-start: CheckApplication
-functions:
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/applicationapi.json#emailRejection
-states:
- - name: CheckApplication
- type: switch
- dataConditions:
- - condition: "${ .applicants | .age >= 18 }"
- transition: StartApplication
- - condition: "${ .applicants | .age < 18 }"
- transition: RejectApplication
- defaultCondition:
- transition: RejectApplication
- - name: StartApplication
- type: operation
- actions:
- - subFlowRef: startApplicationWorkflowId
- end: true
- - name: RejectApplication
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .applicant }"
- end: true
diff --git a/api/src/test/resources/features/applicantrequest.json b/api/src/test/resources/features/applicantrequest.json
deleted file mode 100644
index 1621c2bd..00000000
--- a/api/src/test/resources/features/applicantrequest.json
+++ /dev/null
@@ -1,59 +0,0 @@
-{
- "id": "applicantrequest",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Applicant Request Decision Workflow",
- "description": "Determine if applicant request is valid",
- "start": "CheckApplication",
- "functions": [
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/applicationapi.json#emailRejection"
- }
- ],
- "states":[
- {
- "name":"CheckApplication",
- "type":"switch",
- "dataConditions": [
- {
- "condition": "${ .applicants | .age >= 18 }",
- "transition": "StartApplication"
- },
- {
- "condition": "${ .applicants | .age < 18 }",
- "transition": "RejectApplication"
- }
- ],
- "defaultCondition": {
- "transition": "RejectApplication"
- }
- },
- {
- "name": "StartApplication",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "startApplicationWorkflowId"
- }
- ],
- "end": true
- },
- {
- "name":"RejectApplication",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .applicant }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/applicantrequest.yml b/api/src/test/resources/features/applicantrequest.yml
deleted file mode 100644
index ae0db1be..00000000
--- a/api/src/test/resources/features/applicantrequest.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-id: applicantrequest
-version: '1.0'
-specVersion: '0.8'
-name: Applicant Request Decision Workflow
-description: Determine if applicant request is valid
-start: CheckApplication
-functions:
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/applicationapi.json#emailRejection
-states:
- - name: CheckApplication
- type: switch
- dataConditions:
- - condition: "${ .applicants | .age >= 18 }"
- transition: StartApplication
- - condition: "${ .applicants | .age < 18 }"
- transition: RejectApplication
- defaultCondition:
- transition: RejectApplication
- - name: StartApplication
- type: operation
- actions:
- - subFlowRef: startApplicationWorkflowId
- end: true
- - name: RejectApplication
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .applicant }"
- end: true
diff --git a/api/src/test/resources/features/applicantrequestfunctions.json b/api/src/test/resources/features/applicantrequestfunctions.json
deleted file mode 100644
index bafc861b..00000000
--- a/api/src/test/resources/features/applicantrequestfunctions.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "functions": [
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/application.json#emailRejection"
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/applicantrequestfunctions.yml b/api/src/test/resources/features/applicantrequestfunctions.yml
deleted file mode 100644
index a1e90f93..00000000
--- a/api/src/test/resources/features/applicantrequestfunctions.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-functions:
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/application.json#emailRejection
diff --git a/api/src/test/resources/features/applicantrequestretries.json b/api/src/test/resources/features/applicantrequestretries.json
deleted file mode 100644
index 40f83b55..00000000
--- a/api/src/test/resources/features/applicantrequestretries.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "retries": [
- {
- "name": "TimeoutRetryStrategy",
- "delay": "PT1M",
- "maxAttempts": "5"
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/applicantrequestretries.yml b/api/src/test/resources/features/applicantrequestretries.yml
deleted file mode 100644
index fa4c810d..00000000
--- a/api/src/test/resources/features/applicantrequestretries.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-retries:
- - name: TimeoutRetryStrategy
- delay: PT1M
- maxAttempts: '5'
diff --git a/api/src/test/resources/features/authbasic.json b/api/src/test/resources/features/authbasic.json
deleted file mode 100644
index 31e86599..00000000
--- a/api/src/test/resources/features/authbasic.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "test-workflow",
- "name": "test-workflow-name",
- "version": "1.0",
- "auth": [
- {
- "name": "authname",
- "scheme": "basic",
- "properties": {
- "username": "testuser",
- "password": "testpassword"
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/authbasic.yml b/api/src/test/resources/features/authbasic.yml
deleted file mode 100644
index e04d1f7e..00000000
--- a/api/src/test/resources/features/authbasic.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-id: test-workflow
-name: test-workflow-name
-version: '1.0'
-auth:
- - name: authname
- scheme: basic
- properties:
- username: testuser
- password: testpassword
diff --git a/api/src/test/resources/features/authbearer.json b/api/src/test/resources/features/authbearer.json
deleted file mode 100644
index be7c037a..00000000
--- a/api/src/test/resources/features/authbearer.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "id": "test-workflow",
- "name": "test-workflow-name",
- "version": "1.0",
- "auth": [
- {
- "name": "authname",
- "scheme": "bearer",
- "properties": {
- "token": "testtoken"
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/authbearer.yml b/api/src/test/resources/features/authbearer.yml
deleted file mode 100644
index 292fa3c2..00000000
--- a/api/src/test/resources/features/authbearer.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-id: test-workflow
-name: test-workflow-name
-version: '1.0'
-auth:
- - name: authname
- scheme: bearer
- properties:
- token: testtoken
diff --git a/api/src/test/resources/features/authoauth.json b/api/src/test/resources/features/authoauth.json
deleted file mode 100644
index 10b76d70..00000000
--- a/api/src/test/resources/features/authoauth.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id" : "test-workflow",
- "name" : "test-workflow-name",
- "version" : "1.0",
- "auth" : [{
- "name" : "authname",
- "scheme" : "oauth2",
- "properties" : {
- "authority" : "testauthority",
- "grantType" : "clientCredentials",
- "clientId": "${ $SECRETS.clientid }",
- "clientSecret": "${ $SECRETS.clientsecret }"
- }
- }]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/authoauth.yml b/api/src/test/resources/features/authoauth.yml
deleted file mode 100644
index cb2c52ba..00000000
--- a/api/src/test/resources/features/authoauth.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-id: test-workflow
-name: test-workflow-name
-version: '1.0'
-auth:
- - name: authname
- scheme: oauth2
- properties:
- authority: testauthority
- grantType: clientCredentials
- clientId: "${ $SECRETS.clientid }"
- clientSecret: "${ $SECRETS.clientsecret }"
diff --git a/api/src/test/resources/features/callHttp.yaml b/api/src/test/resources/features/callHttp.yaml
new file mode 100644
index 00000000..9b48c783
--- /dev/null
+++ b/api/src/test/resources/features/callHttp.yaml
@@ -0,0 +1,12 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: http-call-with-response-output
+do:
+ - getPet:
+ call: http
+ with:
+ method: get
+ endpoint:
+ uri: https://petstore.swagger.io/v2/pet/{petId}
+ output: response
\ No newline at end of file
diff --git a/api/src/test/resources/features/callOpenAPI.yaml b/api/src/test/resources/features/callOpenAPI.yaml
new file mode 100644
index 00000000..46ecc921
--- /dev/null
+++ b/api/src/test/resources/features/callOpenAPI.yaml
@@ -0,0 +1,15 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: openapi-call-with-content-output
+do:
+ - findPet:
+ call: openapi
+ with:
+ document:
+ uri: "https://petstore.swagger.io/v2/swagger.json"
+ operationId: findPetsByStatus
+ parameters:
+ status: ${ .status }
+ output:
+ as: . | length
\ No newline at end of file
diff --git a/api/src/test/resources/features/checkcarvitals.json b/api/src/test/resources/features/checkcarvitals.json
deleted file mode 100644
index 6a66841a..00000000
--- a/api/src/test/resources/features/checkcarvitals.json
+++ /dev/null
@@ -1,71 +0,0 @@
-{
- "id": "checkcarvitals",
- "name": "Check Car Vitals Workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "WhenCarIsOn",
- "states": [
- {
- "name": "WhenCarIsOn",
- "type": "event",
- "onEvents": [
- {
- "eventRefs": ["CarTurnedOnEvent"]
- }
- ],
- "transition": "DoCarVitalsChecks"
- },
- {
- "name": "DoCarVitalsChecks",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": {
- "workflowId": "vitalscheck"
- }
- }
- ],
- "transition": "WaitForCarStopped"
- },
- {
- "name": "WaitForCarStopped",
- "type": "event",
- "onEvents": [
- {
- "eventRefs": ["CarTurnedOffEvent"],
- "actions": [
- {
- "eventRef": {
- "triggerEventRef": "StopVitalsCheck",
- "resultEventRef": "VitalsCheckingStopped"
- }
- }
- ]
- }
- ],
- "end": true
- }
- ],
- "events": [
- {
- "name": "CarTurnedOnEvent",
- "type": "car.events",
- "source": "my/car"
- },
- {
- "name": "CarTurnedOffEvent",
- "type": "car.events",
- "source": "my/car"
- },
- {
- "name": "StopVitalsCheck",
- "type": "car.events",
- "source": "my/car"
- },
- {
- "name": "VitalsCheckingStopped",
- "type": "car.events",
- "source": "my/car"
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/checkcarvitals.yml b/api/src/test/resources/features/checkcarvitals.yml
deleted file mode 100644
index 86a00d1d..00000000
--- a/api/src/test/resources/features/checkcarvitals.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-id: checkcarvitals
-name: Check Car Vitals Workflow
-version: '1.0'
-specVersion: '0.8'
-start: WhenCarIsOn
-states:
- - name: WhenCarIsOn
- type: event
- onEvents:
- - eventRefs:
- - CarTurnedOnEvent
- transition: DoCarVitalsChecks
- - name: DoCarVitalsChecks
- type: operation
- actions:
- - subFlowRef:
- workflowId: vitalscheck
- transition: WaitForCarStopped
- - name: WaitForCarStopped
- type: event
- onEvents:
- - eventRefs:
- - CarTurnedOffEvent
- actions:
- - eventRef:
- triggerEventRef: StopVitalsCheck
- resultEventRef: VitalsCheckingStopped
- end: true
-events:
- - name: CarTurnedOnEvent
- type: car.events
- source: my/car
- - name: CarTurnedOffEvent
- type: car.events
- source: my/car
- - name: StopVitalsCheck
- type: car.events
- source: my/car
- - name: VitalsCheckingStopped
- type: car.events
- source: my/car
diff --git a/api/src/test/resources/features/compensationworkflow.json b/api/src/test/resources/features/compensationworkflow.json
deleted file mode 100644
index f7771655..00000000
--- a/api/src/test/resources/features/compensationworkflow.json
+++ /dev/null
@@ -1,85 +0,0 @@
-{
- "id": "CompensationWorkflow",
- "name": "Compensation Workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "states": [
- {
- "name": "NewItemPurchase",
- "type": "event",
- "onEvents": [
- {
- "eventRefs": [
- "NewPurchase"
- ],
- "actions": [
- {
- "functionRef": {
- "refName": "DebitCustomerFunction",
- "arguments": {
- "customerid": "${ .purchase.customerid }",
- "amount": "${ .purchase.amount }"
- }
- }
- },
- {
- "functionRef": {
- "refName": "SendPurchaseConfirmationEmailFunction",
- "arguments": {
- "customerid": "${ .purchase.customerid }"
- }
- }
- }
- ]
- }
- ],
- "compensatedBy": "CancelPurchase",
- "transition": "SomeNextWorkflowState"
- },
- {
- "name": "CancelPurchase",
- "type": "operation",
- "usedForCompensation": true,
- "actions": [
- {
- "functionRef": {
- "refName": "CreditCustomerFunction",
- "arguments": {
- "customerid": "${ .purchase.customerid }",
- "amount": "${ .purchase.amount }"
- }
- }
- },
- {
- "functionRef": {
- "refName": "SendPurchaseCancellationEmailFunction",
- "arguments": {
- "customerid": "${ .purchase.customerid }"
- }
- }
- }
- ]
- }
- ],
- "events": [
- {
- "name": "NewItemPurchase",
- "source": "purchasesource",
- "type": "org.purchases"
- }
- ],
- "functions": [
- {
- "name": "DebitCustomerFunction",
- "operation": "http://myapis.org/application.json#debit"
- },
- {
- "name": "SendPurchaseConfirmationEmailFunction",
- "operation": "http://myapis.org/application.json#confirmationemail"
- },
- {
- "name": "SendPurchaseCancellationEmailFunction",
- "operation": "http://myapis.org/application.json#cancellationemail"
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/compensationworkflow.yml b/api/src/test/resources/features/compensationworkflow.yml
deleted file mode 100644
index b8963838..00000000
--- a/api/src/test/resources/features/compensationworkflow.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-id: CompensationWorkflow
-name: Compensation Workflow
-version: '1.0'
-specVersion: '0.8'
-states:
- - name: NewItemPurchase
- type: event
- onEvents:
- - eventRefs:
- - NewPurchase
- actions:
- - functionRef:
- refName: DebitCustomerFunction
- arguments:
- customerid: "${ .purchase.customerid }"
- amount: "${ .purchase.amount }"
- - functionRef:
- refName: SendPurchaseConfirmationEmailFunction
- arguments:
- customerid: "${ .purchase.customerid }"
- compensatedBy: CancelPurchase
- transition: SomeNextWorkflowState
- - name: CancelPurchase
- type: operation
- usedForCompensation: true
- actions:
- - functionRef:
- refName: CreditCustomerFunction
- arguments:
- customerid: "${ .purchase.customerid }"
- amount: "${ .purchase.amount }"
- - functionRef:
- refName: SendPurchaseCancellationEmailFunction
- arguments:
- customerid: "${ .purchase.customerid }"
-events:
- - name: NewItemPurchase
- source: purchasesource
- type: org.purchases
-functions:
- - name: DebitCustomerFunction
- operation: http://myapis.org/application.json#debit
- - name: SendPurchaseConfirmationEmailFunction
- operation: http://myapis.org/application.json#confirmationemail
- - name: SendPurchaseCancellationEmailFunction
- operation: http://myapis.org/application.json#cancellationemail
diff --git a/api/src/test/resources/features/composite.yaml b/api/src/test/resources/features/composite.yaml
new file mode 100644
index 00000000..71b0dea4
--- /dev/null
+++ b/api/src/test/resources/features/composite.yaml
@@ -0,0 +1,16 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: do
+do:
+ - compositeExample:
+ do:
+ - setRed:
+ set:
+ colors: ${ .colors + ["red"] }
+ - setGreen:
+ set:
+ colors: ${ .colors + ["green"] }
+ - setBlue:
+ set:
+ colors: ${ .colors + ["blue"] }
\ No newline at end of file
diff --git a/api/src/test/resources/features/constants.json b/api/src/test/resources/features/constants.json
deleted file mode 100644
index 93dd9452..00000000
--- a/api/src/test/resources/features/constants.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
- "id": "secrets",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Custom secrets flow",
- "expressionLang": "abc",
- "start": "TestFunctionRefs",
- "constants": {
- "Translations": {
- "Dog": {
- "Serbian": "pas",
- "Spanish": "perro",
- "French": "chien"
- }
- }
- },
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/constants.yml b/api/src/test/resources/features/constants.yml
deleted file mode 100644
index 083f0433..00000000
--- a/api/src/test/resources/features/constants.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-id: secrets
-version: '1.0'
-specVersion: '0.8'
-name: Custom secrets flow
-expressionLang: abc
-start: TestFunctionRefs
-constants:
- Translations:
- Dog:
- Serbian: pas
- Spanish: perro
- French: chien
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
diff --git a/api/src/test/resources/features/constantsRef.json b/api/src/test/resources/features/constantsRef.json
deleted file mode 100644
index cd0fcb60..00000000
--- a/api/src/test/resources/features/constantsRef.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "id": "secrets",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Custom secrets flow",
- "expressionLang": "abc",
- "start": "TestFunctionRefs",
- "constants": "constantValues.json",
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actions": [],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/constantsRef.yml b/api/src/test/resources/features/constantsRef.yml
deleted file mode 100644
index cdc48332..00000000
--- a/api/src/test/resources/features/constantsRef.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-id: secrets
-version: '1.0'
-specVersion: '0.8'
-name: Custom secrets flow
-expressionLang: abc
-start: TestFunctionRefs
-constants:
- constantValues.json
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- end: true
diff --git a/api/src/test/resources/features/continueasobject.json b/api/src/test/resources/features/continueasobject.json
deleted file mode 100644
index a2c6462e..00000000
--- a/api/src/test/resources/features/continueasobject.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "id": "functionrefs",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Customer Credit Check Workflow",
- "description": "Perform Customer Credit Check",
- "start": "TestFunctionRef",
- "functions": [
- {
- "name": "creditCheckFunction",
- "operation": "http://myapis.org/creditcheckapi.json#doCreditCheck"
- },
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/creditcheckapi.json#rejectionEmail"
- }
- ],
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": {
- "continueAs": {
- "workflowId": "myworkflowid",
- "version": "1.0",
- "data": "${ .data }",
- "workflowExecTimeout": {
- "duration": "PT1M"
- }
- }
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/continueasobject.yml b/api/src/test/resources/features/continueasobject.yml
deleted file mode 100644
index 8bc9dc2c..00000000
--- a/api/src/test/resources/features/continueasobject.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-id: functionrefs
-version: '1.0'
-specVersion: '0.8'
-name: Customer Credit Check Workflow
-description: Perform Customer Credit Check
-start: TestFunctionRef
-functions:
- - name: creditCheckFunction
- operation: http://myapis.org/creditcheckapi.json#doCreditCheck
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/creditcheckapi.json#rejectionEmail
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end:
- continueAs:
- workflowId: myworkflowid
- version: '1.0'
- data: "${ .data }"
- workflowExecTimeout:
- duration: PT1M
diff --git a/api/src/test/resources/features/continueasstring.json b/api/src/test/resources/features/continueasstring.json
deleted file mode 100644
index 0e4b2b89..00000000
--- a/api/src/test/resources/features/continueasstring.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "id": "functionrefs",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Customer Credit Check Workflow",
- "description": "Perform Customer Credit Check",
- "start": "TestFunctionRef",
- "functions": [
- {
- "name": "creditCheckFunction",
- "operation": "http://myapis.org/creditcheckapi.json#doCreditCheck"
- },
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/creditcheckapi.json#rejectionEmail"
- }
- ],
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": {
- "continueAs": "myworkflowid"
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/continueasstring.yml b/api/src/test/resources/features/continueasstring.yml
deleted file mode 100644
index a6175e20..00000000
--- a/api/src/test/resources/features/continueasstring.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-id: functionrefs
-version: '1.0'
-specVersion: '0.8'
-name: Customer Credit Check Workflow
-description: Perform Customer Credit Check
-start: TestFunctionRef
-functions:
- - name: creditCheckFunction
- operation: http://myapis.org/creditcheckapi.json#doCreditCheck
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/creditcheckapi.json#rejectionEmail
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end:
- continueAs: myworkflowid
diff --git a/api/src/test/resources/features/data-flow.yaml b/api/src/test/resources/features/data-flow.yaml
new file mode 100644
index 00000000..d66d7848
--- /dev/null
+++ b/api/src/test/resources/features/data-flow.yaml
@@ -0,0 +1,13 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: output-filtering
+do:
+ - getPet:
+ call: http
+ with:
+ method: get
+ endpoint:
+ uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
+ output:
+ as: .id #filters the output of the http call, using only the id of the returned object
diff --git a/api/src/test/resources/features/datainputschemaobj.json b/api/src/test/resources/features/datainputschemaobj.json
deleted file mode 100644
index 79b183c3..00000000
--- a/api/src/test/resources/features/datainputschemaobj.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "id": "datainputschemaobj",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Data Input Schema test",
- "dataInputSchema": {
- "schema":{
- "title": "MyJSONSchema",
- "properties":{
- "firstName":{
- "type": "string"
- },
- "lastName":{
- "type": "string"
- }
- }
- },
- "failOnValidationErrors": false
- },
- "start": "TestFunctionRefs",
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/datainputschemaobj.yml b/api/src/test/resources/features/datainputschemaobj.yml
deleted file mode 100644
index b2073b46..00000000
--- a/api/src/test/resources/features/datainputschemaobj.yml
+++ /dev/null
@@ -1,26 +0,0 @@
----
-id: datainputschemaobj
-version: '1.0'
-specVersion: '0.8'
-name: Data Input Schema test
-dataInputSchema:
- schema:
- title: MyJSONSchema
- properties:
- firstName:
- type: string
- lastName:
- type: string
- failOnValidationErrors: false
-start: TestFunctionRefs
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
diff --git a/api/src/test/resources/features/datainputschemaobjstring.json b/api/src/test/resources/features/datainputschemaobjstring.json
deleted file mode 100644
index b61bdd5c..00000000
--- a/api/src/test/resources/features/datainputschemaobjstring.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "id": "datainputschemaobj",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Data Input Schema test",
- "dataInputSchema": "features/somejsonschema.json",
- "start": "TestFunctionRefs",
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/datainputschemaobjstring.yml b/api/src/test/resources/features/datainputschemaobjstring.yml
deleted file mode 100644
index fcf7c60c..00000000
--- a/api/src/test/resources/features/datainputschemaobjstring.yml
+++ /dev/null
@@ -1,18 +0,0 @@
----
-id: datainputschemaobj
-version: '1.0'
-specVersion: '0.8'
-name: Data Input Schema test
-dataInputSchema: features/somejsonschema.json
-start: TestFunctionRefs
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
diff --git a/api/src/test/resources/features/datainputschemastring.json b/api/src/test/resources/features/datainputschemastring.json
deleted file mode 100644
index 822ed865..00000000
--- a/api/src/test/resources/features/datainputschemastring.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "id": "datainputschemaobj",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Data Input Schema test",
- "dataInputSchema": {
- "schema": "features/somejsonschema.json",
- "failOnValidationErrors": true
- },
- "start": "TestFunctionRefs",
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/datainputschemastring.yml b/api/src/test/resources/features/datainputschemastring.yml
deleted file mode 100644
index 326622e8..00000000
--- a/api/src/test/resources/features/datainputschemastring.yml
+++ /dev/null
@@ -1,20 +0,0 @@
----
-id: datainputschemaobj
-version: '1.0'
-specVersion: '0.8'
-name: Data Input Schema test
-dataInputSchema:
- schema: features/somejsonschema.json
- failOnValidationErrors: true
-start: TestFunctionRefs
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
diff --git a/api/src/test/resources/features/datainputschemawithnullschema.json b/api/src/test/resources/features/datainputschemawithnullschema.json
deleted file mode 100644
index 54d01468..00000000
--- a/api/src/test/resources/features/datainputschemawithnullschema.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "id": "datainputschemaobj",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Data Input Schema test",
- "dataInputSchema": {
- "schema": null,
- "failOnValidationErrors": true
- },
- "start": "TestFunctionRefs",
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/emit.yaml b/api/src/test/resources/features/emit.yaml
new file mode 100644
index 00000000..488feedc
--- /dev/null
+++ b/api/src/test/resources/features/emit.yaml
@@ -0,0 +1,13 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: emit
+do:
+ - emitEvent:
+ emit:
+ event:
+ with:
+ source: https://fake-source.com
+ type: com.fake-source.user.greeted.v1
+ data:
+ greetings: ${ "Hello \(.user.firstName) \(.user.lastName)!" }
\ No newline at end of file
diff --git a/api/src/test/resources/features/errors.json b/api/src/test/resources/features/errors.json
deleted file mode 100644
index 3d57b47e..00000000
--- a/api/src/test/resources/features/errors.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "id": "functionrefparams",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Function Ref Params Test",
- "start": "AddPluto",
- "autoRetries": true,
- "errors": [
- {
- "name": "ErrorA",
- "code": "400"
- },
- {
- "name": "ErrorB",
- "code": "500"
- }
- ],
- "states": [
- {
- "name": "AddPluto",
- "type": "operation",
- "actions": [
- {
- "functionRef": "addPet",
- "retryRef": "testRetry",
- "nonRetryableErrors": ["A", "B"],
- "condition": "${ .data }"
- }
- ],
- "onErrors": [
- {
- "errorRefs": ["A", "B"],
- "end": true
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/errors.yml b/api/src/test/resources/features/errors.yml
deleted file mode 100644
index 51327435..00000000
--- a/api/src/test/resources/features/errors.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-id: functionrefparams
-version: '1.0'
-specVersion: '0.8'
-name: Function Ref Params Test
-start: AddPluto
-autoRetries: true
-errors:
- - name: ErrorA
- code: '400'
- - name: ErrorB
- code: '500'
-states:
- - name: AddPluto
- type: operation
- actions:
- - functionRef: addPet
- retryRef: testRetry
- nonRetryableErrors:
- - A
- - B
- condition: "${ .data }"
- onErrors:
- - errorRefs:
- - A
- - B
- end: true
- end: true
diff --git a/api/src/test/resources/features/eventdefdataonly.json b/api/src/test/resources/features/eventdefdataonly.json
deleted file mode 100644
index a181b864..00000000
--- a/api/src/test/resources/features/eventdefdataonly.json
+++ /dev/null
@@ -1,73 +0,0 @@
-{
- "id": "eventdefdataonly",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Event Definition Data Only Test",
- "description": "Event Definition Data Only Test",
- "start": "CheckVisaStatus",
- "events": [
- {
- "name": "visaApprovedEvent",
- "type": "VisaApproved",
- "source": "visaCheckSource",
- "dataOnly": false
- },
- {
- "name": "visaRejectedEvent",
- "type": "VisaRejected",
- "source": "visaCheckSource"
- }
- ],
- "states":[
- {
- "name":"CheckVisaStatus",
- "type":"switch",
- "eventConditions": [
- {
- "eventRef": "visaApprovedEvent",
- "transition": "HandleApprovedVisa"
- },
- {
- "eventRef": "visaRejectedEvent",
- "transition": "HandleRejectedVisa"
- }
- ],
- "timeouts": {
- "eventTimeout": "PT1H"
- },
- "defaultCondition": {
- "transition": "HandleNoVisaDecision"
- }
- },
- {
- "name": "HandleApprovedVisa",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleApprovedVisaWorkflowID"
- }
- ],
- "end": true
- },
- {
- "name": "HandleRejectedVisa",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleRejectedVisaWorkflowID"
- }
- ],
- "end": true
- },
- {
- "name": "HandleNoVisaDecision",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleNoVisaDecisionWorkflowId"
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/eventdefdataonly.yml b/api/src/test/resources/features/eventdefdataonly.yml
deleted file mode 100644
index e67a9ede..00000000
--- a/api/src/test/resources/features/eventdefdataonly.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-id: eventdefdataonly
-version: '1.0'
-specVersion: '0.8'
-name: Event Definition Data Only Test
-description: Event Definition Data Only Test
-start: CheckVisaStatus
-events:
- - name: visaApprovedEvent
- type: VisaApproved
- source: visaCheckSource
- dataOnly: false
- - name: visaRejectedEvent
- type: VisaRejected
- source: visaCheckSource
-states:
- - name: CheckVisaStatus
- type: switch
- eventConditions:
- - eventRef: visaApprovedEvent
- transition: HandleApprovedVisa
- - eventRef: visaRejectedEvent
- transition: HandleRejectedVisa
- timeouts:
- eventTimeout: PT1H
- defaultCondition:
- transition: HandleNoVisaDecision
- - name: HandleApprovedVisa
- type: operation
- actions:
- - subFlowRef: handleApprovedVisaWorkflowID
- end: true
- - name: HandleRejectedVisa
- type: operation
- actions:
- - subFlowRef: handleRejectedVisaWorkflowID
- end: true
- - name: HandleNoVisaDecision
- type: operation
- actions:
- - subFlowRef: handleNoVisaDecisionWorkflowId
- end: true
diff --git a/api/src/test/resources/features/expressionlang.json b/api/src/test/resources/features/expressionlang.json
deleted file mode 100644
index bf77ada8..00000000
--- a/api/src/test/resources/features/expressionlang.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "id": "expressionlang",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Custom expression lang",
- "expressionLang": "abc",
- "start": "TestFunctionRefs",
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/expressionlang.yml b/api/src/test/resources/features/expressionlang.yml
deleted file mode 100644
index 9ae3ed1a..00000000
--- a/api/src/test/resources/features/expressionlang.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-id: expressionlang
-version: '1.0'
-specVersion: '0.8'
-name: Custom expression lang
-expressionLang: abc
-start: TestFunctionRefs
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/features/flow.yaml b/api/src/test/resources/features/flow.yaml
new file mode 100644
index 00000000..83baf04c
--- /dev/null
+++ b/api/src/test/resources/features/flow.yaml
@@ -0,0 +1,14 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: implicit-sequence
+do:
+ - setRed:
+ set:
+ colors: '${ .colors + [ "red" ] }'
+ - setGreen:
+ set:
+ colors: '${ .colors + [ "green" ] }'
+ - setBlue:
+ set:
+ colors: '${ .colors + [ "blue" ] }'
diff --git a/api/src/test/resources/features/for.yaml b/api/src/test/resources/features/for.yaml
new file mode 100644
index 00000000..f8ae826d
--- /dev/null
+++ b/api/src/test/resources/features/for.yaml
@@ -0,0 +1,13 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: for
+do:
+ - loopColors:
+ for:
+ each: color
+ in: '.colors'
+ do:
+ - markProcessed:
+ set:
+ processed: '${ { colors: (.processed.colors + [ $color ]), indexes: (.processed.indexes + [ $index ])} }'
\ No newline at end of file
diff --git a/api/src/test/resources/features/functionrefjsonparams.json b/api/src/test/resources/features/functionrefjsonparams.json
deleted file mode 100644
index ae7fd713..00000000
--- a/api/src/test/resources/features/functionrefjsonparams.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "id": "functionrefparams",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Function Ref Params Test",
- "start": "AddPluto",
- "states": [
- {
- "name": "AddPluto",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "addPet",
- "arguments": {
- "body": {
- "name": "Pluto",
- "tag": "${ .pet.tagnumber }"
- },
- "id": 123,
- "address": "My Address, 123 MyCity, MyCountry",
- "owner": "${ .owner.name }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/functionrefjsonparams.yml b/api/src/test/resources/features/functionrefjsonparams.yml
deleted file mode 100644
index 23b3cae5..00000000
--- a/api/src/test/resources/features/functionrefjsonparams.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-id: functionrefparams
-version: '1.0'
-specVersion: '0.8'
-name: Function Ref Params Test
-start: AddPluto
-states:
- - name: AddPluto
- type: operation
- actions:
- - functionRef:
- refName: addPet
- arguments:
- body:
- name: Pluto
- tag: "${ .pet.tagnumber }"
- id: 123
- address: My Address, 123 MyCity, MyCountry
- owner: "${ .owner.name }"
- end: true
diff --git a/api/src/test/resources/features/functionrefnoparams.json b/api/src/test/resources/features/functionrefnoparams.json
deleted file mode 100644
index c150f1c5..00000000
--- a/api/src/test/resources/features/functionrefnoparams.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "id": "functionrefparams",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Function Ref Params Test",
- "start": "AddPluto",
- "states": [
- {
- "name": "AddPluto",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "addPet"
- }
- },
- {
- "functionRef": "addPet"
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/functionrefnoparams.yml b/api/src/test/resources/features/functionrefnoparams.yml
deleted file mode 100644
index bc2bf078..00000000
--- a/api/src/test/resources/features/functionrefnoparams.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-id: functionrefparams
-version: '1.0'
-specVersion: '0.8'
-name: Function Ref Params Test
-start: AddPluto
-states:
- - name: AddPluto
- type: operation
- actions:
- - functionRef:
- refName: addPet
- - functionRef: addPet
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/features/functionrefs.json b/api/src/test/resources/features/functionrefs.json
deleted file mode 100644
index e3333b28..00000000
--- a/api/src/test/resources/features/functionrefs.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "id": "functionrefs",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Customer Credit Check Workflow",
- "description": "Perform Customer Credit Check",
- "start": "TestFunctionRef",
- "functions": [
- {
- "name": "creditCheckFunction",
- "operation": "http://myapis.org/creditcheckapi.json#doCreditCheck"
- },
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/creditcheckapi.json#rejectionEmail"
- }
- ],
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/functionrefs.yml b/api/src/test/resources/features/functionrefs.yml
deleted file mode 100644
index 289a6e7f..00000000
--- a/api/src/test/resources/features/functionrefs.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-id: functionrefs
-version: '1.0'
-specVersion: '0.8'
-name: Customer Credit Check Workflow
-description: Perform Customer Credit Check
-start: TestFunctionRefs
-functions:
- - name: creditCheckFunction
- operation: http://myapis.org/creditcheckapi.json#doCreditCheck
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/creditcheckapi.json#rejectionEmail
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/features/functiontypes.json b/api/src/test/resources/features/functiontypes.json
deleted file mode 100644
index 6452e359..00000000
--- a/api/src/test/resources/features/functiontypes.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "id": "functiontypes",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Function Types Workflow",
- "description": "Determine if applicant request is valid",
- "start": "CheckFunctions",
- "functions": [
- {
- "name": "restFunction",
- "operation": "http://myapis.org/applicationapi.json#emailRejection"
- },
- {
- "name": "expressionFunction",
- "operation": ".my.data",
- "type" : "expression"
- }
- ],
- "states":[
- {
- "name":"CheckFunctions",
- "type":"operation",
- "actions":[
- {
- "functionRef": {
- "refName": "restFunction",
- "arguments": {
- "data": "${ fn(expressionFunction) }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/functiontypes.yml b/api/src/test/resources/features/functiontypes.yml
deleted file mode 100644
index 2e4ec926..00000000
--- a/api/src/test/resources/features/functiontypes.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-id: functiontypes
-version: '1.0'
-specVersion: '0.8'
-name: Function Types Workflow
-description: Determine if applicant request is valid
-start: CheckFunctions
-functions:
- - name: restFunction
- operation: http://myapis.org/applicationapi.json#emailRejection
- - name: expressionFunction
- operation: ".my.data"
- type: expression
-states:
- - name: CheckFunctions
- type: operation
- actions:
- - functionRef:
- refName: restFunction
- arguments:
- data: "${ fn(expressionFunction) }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/features/invoke.json b/api/src/test/resources/features/invoke.json
deleted file mode 100644
index bf69f433..00000000
--- a/api/src/test/resources/features/invoke.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "id": "invoketest",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Invoke Test",
- "description": "Invoke Test",
- "start": "TestInvoke",
- "states": [
- {
- "name": "TestInvoke",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "invoke": "async"
- }
- },
- {
- "subFlowRef": {
- "workflowId": "subflowrefworkflowid",
- "version": "1.0",
- "invoke": "async",
- "onParentComplete": "continue"
- }
- },
- {
- "eventRef": {
- "triggerEventRef": "abc",
- "resultEventRef": "123",
- "invoke": "async"
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/invoke.yml b/api/src/test/resources/features/invoke.yml
deleted file mode 100644
index 88e25073..00000000
--- a/api/src/test/resources/features/invoke.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-id: invoketest
-version: '1.0'
-specVersion: '0.8'
-name: Invoke Test
-description: Invoke Test
-start: TestInvoke
-states:
- - name: TestInvoke
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: sendRejectionEmailFunction
- invoke: async
- - subFlowRef:
- workflowId: subflowrefworkflowid
- version: '1.0'
- invoke: async
- onParentComplete: continue
- - eventRef:
- triggerEventRef: abc
- resultEventRef: '123'
- invoke: async
- end: true
diff --git a/api/src/test/resources/features/keepactiveexectimeout.json b/api/src/test/resources/features/keepactiveexectimeout.json
deleted file mode 100644
index fe613bab..00000000
--- a/api/src/test/resources/features/keepactiveexectimeout.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "keepactiveexectimeout",
- "name": "Keep Active and Exec Timeout Test Workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "timeouts": {
- "workflowExecTimeout": {
- "duration": "PT1H",
- "runBefore": "GenerateReport"
- }
- },
- "keepActive": true,
- "states": [
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/keepactiveexectimeout.yml b/api/src/test/resources/features/keepactiveexectimeout.yml
deleted file mode 100644
index 22e4b439..00000000
--- a/api/src/test/resources/features/keepactiveexectimeout.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-id: keepactiveexectimeout
-name: Keep Active and Exec Timeout Test Workflow
-version: '1.0'
-specVersion: '0.8'
-timeouts:
- workflowExecTimeout:
- duration: PT1H
- runBefore: GenerateReport
-keepActive: true
-states: []
diff --git a/api/src/test/resources/features/longstart.json b/api/src/test/resources/features/longstart.json
deleted file mode 100644
index f2ea4ae1..00000000
--- a/api/src/test/resources/features/longstart.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "id": "longstart",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Long start",
- "start": {
- "stateName": "TestFunctionRefs",
- "schedule": {
- "cron": "0 0/15 * * * ?"
- }
- },
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/longstart.yml b/api/src/test/resources/features/longstart.yml
deleted file mode 100644
index 6151632b..00000000
--- a/api/src/test/resources/features/longstart.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-id: longstart
-version: '1.0'
-specVersion: '0.8'
-name: Long start
-start:
- stateName: TestFunctionRefs
- schedule:
- cron: 0 0/15 * * * ?
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/features/raise.yaml b/api/src/test/resources/features/raise.yaml
new file mode 100644
index 00000000..9dd6b4f3
--- /dev/null
+++ b/api/src/test/resources/features/raise.yaml
@@ -0,0 +1,11 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: raise-custom-error
+do:
+ - raiseError:
+ raise:
+ error:
+ status: 400
+ type: https://serverlessworkflow.io/errors/types/compliance
+ title: Compliance Error
\ No newline at end of file
diff --git a/api/src/test/resources/features/retriesprops.json b/api/src/test/resources/features/retriesprops.json
deleted file mode 100644
index 397a8672..00000000
--- a/api/src/test/resources/features/retriesprops.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "id": "TestRetriesProps",
- "name": "Retries props test",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "Test State",
- "retries": [
- {
- "name": "Test Retries",
- "delay": "PT1M",
- "maxDelay": "PT2M",
- "increment": "PT2S",
- "multiplier": "1.2",
- "maxAttempts": "20",
- "jitter": "0.4"
- }
- ],
- "states": [
- {
- "name": "Test States",
- "type": "operation",
- "actions": [
- ],
- "onErrors": [
- {
- "errorRef": "TimeoutError",
- "end": true
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/retriesprops.yml b/api/src/test/resources/features/retriesprops.yml
deleted file mode 100644
index 01d3d04a..00000000
--- a/api/src/test/resources/features/retriesprops.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-id: TestRetriesProps
-name: Retries props test
-version: '1.0'
-specVersion: '0.8'
-start: Test State
-retries:
- - name: Test Retries
- delay: PT1M
- maxDelay: PT2M
- increment: PT2S
- multiplier: '1.2'
- maxAttempts: '20'
- jitter: '0.4'
-states:
- - name: Test States
- type: operation
- actions: []
- onErrors:
- - errorRef: TimeoutError
- end: true
- end: true
diff --git a/api/src/test/resources/features/secrets.json b/api/src/test/resources/features/secrets.json
deleted file mode 100644
index 06939379..00000000
--- a/api/src/test/resources/features/secrets.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "id": "secrets",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Custom secrets flow",
- "expressionLang": "abc",
- "start": "TestFunctionRefs",
- "secrets": ["secret1", "secret2", "secret3"],
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/secrets.yml b/api/src/test/resources/features/secrets.yml
deleted file mode 100644
index 6ca947af..00000000
--- a/api/src/test/resources/features/secrets.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-id: secrets
-version: '1.0'
-specVersion: '0.8'
-name: Custom secrets flow
-expressionLang: abc
-start: TestFunctionRefs
-secrets:
- - secret1
- - secret2
- - secret3
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
diff --git a/api/src/test/resources/features/set.yaml b/api/src/test/resources/features/set.yaml
new file mode 100644
index 00000000..1589792f
--- /dev/null
+++ b/api/src/test/resources/features/set.yaml
@@ -0,0 +1,10 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: set
+do:
+ - setShape:
+ set:
+ shape: circle
+ size: ${ .configuration.size }
+ fill: ${ .configuration.fill }
diff --git a/api/src/test/resources/features/shortstart.json b/api/src/test/resources/features/shortstart.json
deleted file mode 100644
index b1b75926..00000000
--- a/api/src/test/resources/features/shortstart.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "id": "shortstart",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Short start",
- "start": "TestFunctionRefs",
- "states": [
- {
- "name": "TestFunctionRefs",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "creditCheckFunction"
- },
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/shortstart.yml b/api/src/test/resources/features/shortstart.yml
deleted file mode 100644
index 302ff182..00000000
--- a/api/src/test/resources/features/shortstart.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-id: shortstart
-version: '1.0'
-specVersion: '0.8'
-name: Short start
-start: TestFunctionRefs
-states:
- - name: TestFunctionRefs
- type: operation
- actionMode: sequential
- actions:
- - functionRef: creditCheckFunction
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/features/simplecron.json b/api/src/test/resources/features/simplecron.json
deleted file mode 100644
index bbe25672..00000000
--- a/api/src/test/resources/features/simplecron.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "id": "checkInbox",
- "name": "Check Inbox Workflow",
- "description": "Periodically Check Inbox",
- "version": "1.0",
- "specVersion": "0.8",
- "start": {
- "stateName": "CheckInbox",
- "schedule": {
- "cron": "0 0/15 * * * ?"
- }
- },
- "functions": [
- {
- "name": "checkInboxFunction",
- "operation": "http://myapis.org/inboxapi.json#checkNewMessages"
- },
- {
- "name": "sendTextFunction",
- "operation": "http://myapis.org/inboxapi.json#sendText"
- }
- ],
- "states": [
- {
- "name": "CheckInbox",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "checkInboxFunction"
- }
- ],
- "transition": "SendTextForHighPrioriry"
- },
- {
- "name": "SendTextForHighPrioriry",
- "type": "foreach",
- "inputCollection": "${ .messages }",
- "iterationParam": "singlemessage",
- "actions": [
- {
- "functionRef": {
- "refName": "sendTextFunction",
- "arguments": {
- "message": "${ .singlemessage }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/simplecron.yml b/api/src/test/resources/features/simplecron.yml
deleted file mode 100644
index ed443de1..00000000
--- a/api/src/test/resources/features/simplecron.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-id: checkInbox
-name: Check Inbox Workflow
-description: Periodically Check Inbox
-version: '1.0'
-specVersion: '0.8'
-start:
- stateName: CheckInbox
- schedule:
- cron: 0 0/15 * * * ?
-functions:
- - name: checkInboxFunction
- operation: http://myapis.org/inboxapi.json#checkNewMessages
- - name: sendTextFunction
- operation: http://myapis.org/inboxapi.json#sendText
-states:
- - name: CheckInbox
- type: operation
- actionMode: sequential
- actions:
- - functionRef: checkInboxFunction
- transition: SendTextForHighPrioriry
- - name: SendTextForHighPrioriry
- type: foreach
- inputCollection: "${ .messages }"
- iterationParam: singlemessage
- actions:
- - functionRef:
- refName: sendTextFunction
- arguments:
- message: "${ .singlemessage }"
- end: true
\ No newline at end of file
diff --git a/api/src/test/resources/features/simpleschedule.json b/api/src/test/resources/features/simpleschedule.json
deleted file mode 100644
index f1dd9f95..00000000
--- a/api/src/test/resources/features/simpleschedule.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "id": "handleCarAuctionBid",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Car Auction Bidding Workflow",
- "description": "Store a single bid whole the car auction is active",
- "start": {
- "stateName": "StoreCarAuctionBid",
- "schedule": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z"
- },
- "functions": [
- {
- "name": "StoreBidFunction",
- "operation": "http://myapis.org/carauctionapi.json#storeBid"
- }
- ],
- "events": [
- {
- "name": "CarBidEvent",
- "type": "carBidMadeType",
- "source": "carBidEventSource"
- }
- ],
- "states": [
- {
- "name": "StoreCarAuctionBid",
- "type": "event",
- "exclusive": true,
- "onEvents": [
- {
- "eventRefs": [
- "CarBidEvent"
- ],
- "actions": [
- {
- "functionRef": {
- "refName": "StoreBidFunction",
- "arguments": {
- "bid": "${ .bid }"
- }
- }
- }
- ]
- }
- ],
- "end": {
- "terminate": true
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/simpleschedule.yml b/api/src/test/resources/features/simpleschedule.yml
deleted file mode 100644
index c38bce8d..00000000
--- a/api/src/test/resources/features/simpleschedule.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-id: handleCarAuctionBid
-version: '1.0'
-specVersion: '0.8'
-name: Car Auction Bidding Workflow
-description: Store a single bid whole the car auction is active
-start:
- stateName: StoreCarAuctionBid
- schedule: 2020-03-20T09:00:00Z/2020-03-20T15:00:00Z
-functions:
- - name: StoreBidFunction
- operation: http://myapis.org/carauctionapi.json#storeBid
-events:
- - name: CarBidEvent
- type: carBidMadeType
- source: carBidEventSource
-states:
- - name: StoreCarAuctionBid
- type: event
- exclusive: true
- onEvents:
- - eventRefs:
- - CarBidEvent
- actions:
- - functionRef:
- refName: StoreBidFunction
- arguments:
- bid: "${ .bid }"
- end:
- terminate: true
\ No newline at end of file
diff --git a/api/src/test/resources/features/somejsonschema.json b/api/src/test/resources/features/somejsonschema.json
deleted file mode 100644
index a8710e0b..00000000
--- a/api/src/test/resources/features/somejsonschema.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "schema": {
- "title": "MyJSONSchema",
- "properties":{
- "firstName":{
- "type": "string"
- },
- "lastName":{
- "type": "string"
- }
- }
- }
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/subflowref.json b/api/src/test/resources/features/subflowref.json
deleted file mode 100644
index a9e2bf0b..00000000
--- a/api/src/test/resources/features/subflowref.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "id": "subflowrefworkflow",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "SubflowRef Workflow",
- "start": "SubflowRef",
- "states":[
- {
- "name": "SubflowRef",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "subflowRefReference"
- },
- {
- "subFlowRef": {
- "workflowId": "subflowrefworkflowid",
- "version": "1.0"
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/subflowref.yml b/api/src/test/resources/features/subflowref.yml
deleted file mode 100644
index a95f8dfd..00000000
--- a/api/src/test/resources/features/subflowref.yml
+++ /dev/null
@@ -1,15 +0,0 @@
----
-id: subflowrefworkflow
-version: '1.0'
-specVersion: '0.8'
-name: SubflowRef Workflow
-start: SubflowRef
-states:
- - name: SubflowRef
- type: operation
- actions:
- - subFlowRef: subflowRefReference
- - subFlowRef:
- workflowId: subflowrefworkflowid
- version: '1.0'
- end: true
diff --git a/api/src/test/resources/features/switch.yaml b/api/src/test/resources/features/switch.yaml
new file mode 100644
index 00000000..74d046cb
--- /dev/null
+++ b/api/src/test/resources/features/switch.yaml
@@ -0,0 +1,28 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: switch-match
+do:
+ - switchColor:
+ switch:
+ - red:
+ when: '.color == "red"'
+ then: setRed
+ - green:
+ when: '.color == "green"'
+ then: setGreen
+ - blue:
+ when: '.color == "blue"'
+ then: setBlue
+ - setRed:
+ set:
+ colors: '${ .colors + [ "red" ] }'
+ then: end
+ - setGreen:
+ set:
+ colors: '${ .colors + [ "green" ] }'
+ then: end
+ - setBlue:
+ set:
+ colors: '${ .colors + [ "blue" ] }'
+ then: end
diff --git a/api/src/test/resources/features/timeouts.json b/api/src/test/resources/features/timeouts.json
deleted file mode 100644
index 217da047..00000000
--- a/api/src/test/resources/features/timeouts.json
+++ /dev/null
@@ -1,52 +0,0 @@
-{
- "id": "timeouts",
- "name": "Timeouts Workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "timeouts": {
- "workflowExecTimeout": {
- "duration": "PT1H",
- "runBefore": "GenerateReport"
- }
- },
- "start": "FirstState",
- "states": [
- {
- "name": "FirstState",
- "type": "event",
- "onEvents": [
- {
- "eventRefs": ["someEventRef"]
- }
- ],
- "timeouts": {
- "stateExecTimeout": "PT5M",
- "eventTimeout": "PT2M"
- },
- "transition": "SecondState"
- },
- {
- "name": "SecondState",
- "type": "parallel",
- "completionType": "allOf",
- "branches": [
- {
- "name": "ShortDelayBranch",
- "timeouts": {
- "branchExecTimeout": "PT3S"
- }
- },
- {
- "name": "LongDelayBranch",
- "timeouts": {
- "branchExecTimeout": "PT4S"
- }
- }
- ],
- "timeouts": {
- "stateExecTimeout": "PT5M"
- },
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/timeouts.yml b/api/src/test/resources/features/timeouts.yml
deleted file mode 100644
index 94280b61..00000000
--- a/api/src/test/resources/features/timeouts.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-id: timeouts
-name: Timeouts Workflow
-version: '1.0'
-specVersion: '0.8'
-timeouts:
- workflowExecTimeout:
- duration: PT1H
- runBefore: GenerateReport
-start: FirstState
-states:
- - name: FirstState
- type: event
- onEvents:
- - eventRefs:
- - someEventRef
- timeouts:
- stateExecTimeout: PT5M
- eventTimeout: PT2M
- transition: SecondState
- - name: SecondState
- type: parallel
- completionType: allOf
- branches:
- - name: ShortDelayBranch
- timeouts:
- branchExecTimeout: PT3S
- - name: LongDelayBranch
- timeouts:
- branchExecTimeout: PT4S
- timeouts:
- stateExecTimeout: PT5M
- end: true
diff --git a/api/src/test/resources/features/transitions.json b/api/src/test/resources/features/transitions.json
deleted file mode 100644
index ed7b7626..00000000
--- a/api/src/test/resources/features/transitions.json
+++ /dev/null
@@ -1,44 +0,0 @@
-{
- "id": "transitions",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Transitions Workflow",
- "start": "DifferentTransitionsTestState",
- "description": "Transitions Workflow",
- "functions": "features/applicantrequestfunctions.json",
- "retries": "features/applicantrequestretries.json",
- "states":[
- {
- "name":"DifferentTransitionsTestState",
- "type":"switch",
- "dataConditions": [
- {
- "condition": "${ .applicants[?(@.age >= 18)] }",
- "transition": "StartApplication"
- },
- {
- "condition": "${ .applicants[?(@.age < 18)] }",
- "transition": {
- "nextState": "RejectApplication",
- "produceEvents": [
- {
- "eventRef": "provisioningCompleteEvent",
- "data": "${ .provisionedOrders }",
- "contextAttributes": {
- "order_location": "IN",
- "order_type": "online"
- }
- }
- ]
- }
- }
- ],
- "defaultCondition": {
- "transition": {
- "nextState": "RejectApplication",
- "compensate": true
- }
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/transitions.yml b/api/src/test/resources/features/transitions.yml
deleted file mode 100644
index 3ec34ae4..00000000
--- a/api/src/test/resources/features/transitions.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-id: transitions
-version: '1.0'
-specVersion: '0.8'
-name: Transitions Workflow
-description: Transitions Workflow
-start: DifferentTransitionsTestState
-functions: features/applicantrequestfunctions.json
-retries: features/applicantrequestretries.json
-states:
- - name: DifferentTransitionsTestState
- type: switch
- dataConditions:
- - condition: "${ .applicants[?(@.age >= 18)] }"
- transition: StartApplication
- - condition: "${ .applicants[?(@.age < 18)] }"
- transition:
- nextState: RejectApplication
- produceEvents:
- - eventRef: provisioningCompleteEvent
- data: "${ .provisionedOrders }"
- contextAttributes:
- "order_location": "IN"
- "order_type": "online"
- defaultCondition:
- transition:
- nextState: RejectApplication
- compensate: true
\ No newline at end of file
diff --git a/api/src/test/resources/features/try.yaml b/api/src/test/resources/features/try.yaml
new file mode 100644
index 00000000..7f9ba599
--- /dev/null
+++ b/api/src/test/resources/features/try.yaml
@@ -0,0 +1,23 @@
+document:
+ dsl: 1.0.0-alpha1
+ namespace: default
+ name: try-catch-404
+do:
+ - tryGetPet:
+ try:
+ - getPet:
+ call: http
+ with:
+ method: get
+ endpoint:
+ uri: https://petstore.swagger.io/v2/pet/getPetByName/{petName}
+ catch:
+ errors:
+ with:
+ type: https://serverlessworkflow.io/dsl/errors/types/communication
+ status: 404
+ as: err
+ do:
+ - setError:
+ set:
+ error: ${ $err }
diff --git a/api/src/test/resources/features/vetappointment.json b/api/src/test/resources/features/vetappointment.json
deleted file mode 100644
index 944fad06..00000000
--- a/api/src/test/resources/features/vetappointment.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "id": "VetAppointmentWorkflow",
- "name": "Vet Appointment Workflow",
- "description": "Vet service call via events",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "MakeVetAppointmentState",
- "events": "features/vetappointmenteventrefs.json",
- "retries": "features/vetappointmentretries.json",
- "states": [
- {
- "name": "MakeVetAppointmentState",
- "type": "operation",
- "actions": [
- {
- "name": "MakeAppointmentAction",
- "eventRef": {
- "triggerEventRef": "MakeVetAppointment",
- "data": "${ .patientInfo }",
- "resultEventRef": "VetAppointmentInfo"
- },
- "actionDataFilter": {
- "results": "${ .appointmentInfo }"
- }
- }
- ],
- "timeouts": {
- "actionExecTimeout": "PT15M"
- },
- "onErrors": [
- {
- "errorRef": "TimeoutError",
- "end": true
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/vetappointment.yml b/api/src/test/resources/features/vetappointment.yml
deleted file mode 100644
index e47baf8f..00000000
--- a/api/src/test/resources/features/vetappointment.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-id: VetAppointmentWorkflow
-name: Vet Appointment Workflow
-description: Vet service call via events
-version: '1.0'
-specVersion: '0.8'
-start: MakeVetAppointmentState
-events: features/vetappointmenteventrefs.json
-retries: features/vetappointmentretries.json
-states:
- - name: MakeVetAppointmentState
- type: operation
- actions:
- - name: MakeAppointmentAction
- eventRef:
- triggerEventRef: MakeVetAppointment
- data: "${ .patientInfo }"
- resultEventRef: VetAppointmentInfo
- actionDataFilter:
- results: "${ .appointmentInfo }"
- timeouts:
- actionExecTimeout: PT15M
- onErrors:
- - errorRef: TimeoutError
- end: true
- end: true
diff --git a/api/src/test/resources/features/vetappointmenteventrefs.json b/api/src/test/resources/features/vetappointmenteventrefs.json
deleted file mode 100644
index 6d021888..00000000
--- a/api/src/test/resources/features/vetappointmenteventrefs.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "events": [
- {
- "name": "MakeVetAppointment",
- "source": "VetServiceSoure",
- "kind": "produced"
- },
- {
- "name": "VetAppointmentInfo",
- "source": "VetServiceSource",
- "kind": "consumed"
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/vetappointmenteventrefs.yml b/api/src/test/resources/features/vetappointmenteventrefs.yml
deleted file mode 100644
index 922e6bd7..00000000
--- a/api/src/test/resources/features/vetappointmenteventrefs.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-events:
- - name: MakeVetAppointment
- source: VetServiceSoure
- kind: produced
- - name: VetAppointmentInfo
- source: VetServiceSource
- kind: consumed
diff --git a/api/src/test/resources/features/vetappointmentretries.json b/api/src/test/resources/features/vetappointmentretries.json
deleted file mode 100644
index 40f83b55..00000000
--- a/api/src/test/resources/features/vetappointmentretries.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "retries": [
- {
- "name": "TimeoutRetryStrategy",
- "delay": "PT1M",
- "maxAttempts": "5"
- }
- ]
-}
\ No newline at end of file
diff --git a/api/src/test/resources/features/vetappointmentretries.yml b/api/src/test/resources/features/vetappointmentretries.yml
deleted file mode 100644
index fa4c810d..00000000
--- a/api/src/test/resources/features/vetappointmentretries.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-retries:
- - name: TimeoutRetryStrategy
- delay: PT1M
- maxAttempts: '5'
diff --git a/custom-generator/pom.xml b/custom-generator/pom.xml
new file mode 100644
index 00000000..7aaedbda
--- /dev/null
+++ b/custom-generator/pom.xml
@@ -0,0 +1,39 @@
+
+ 4.0.0
+
+ io.serverlessworkflow
+ serverlessworkflow-parent
+ 7.0.0-SNAPSHOT
+
+ custom-generator
+
+
+ org.jsonschema2pojo
+ jsonschema2pojo-core
+
+
+
+
+
+ com.spotify.fmt
+ fmt-maven-plugin
+
+ src/main/java
+ src/test/java
+ false
+ .*\.java
+ false
+ false
+
+
+
+
+
+ format
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/custom-generator/src/main/java/io/serverlessworkflow/generator/AllAnyOneOfSchemaRule.java b/custom-generator/src/main/java/io/serverlessworkflow/generator/AllAnyOneOfSchemaRule.java
new file mode 100644
index 00000000..e16e07bc
--- /dev/null
+++ b/custom-generator/src/main/java/io/serverlessworkflow/generator/AllAnyOneOfSchemaRule.java
@@ -0,0 +1,220 @@
+/*
+ * 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.generator;
+
+import static org.apache.commons.lang3.StringUtils.*;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.sun.codemodel.JClass;
+import com.sun.codemodel.JClassAlreadyExistsException;
+import com.sun.codemodel.JClassContainer;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JFieldVar;
+import com.sun.codemodel.JMethod;
+import com.sun.codemodel.JMod;
+import com.sun.codemodel.JPackage;
+import com.sun.codemodel.JType;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLDecoder;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Optional;
+import org.jsonschema2pojo.Jsonschema2Pojo;
+import org.jsonschema2pojo.Schema;
+import org.jsonschema2pojo.exception.GenerationException;
+import org.jsonschema2pojo.rules.RuleFactory;
+import org.jsonschema2pojo.rules.SchemaRule;
+
+class AllAnyOneOfSchemaRule extends SchemaRule {
+
+ private RuleFactory ruleFactory;
+
+ AllAnyOneOfSchemaRule(RuleFactory ruleFactory) {
+ super(ruleFactory);
+ this.ruleFactory = ruleFactory;
+ }
+
+ @Override
+ public JType apply(
+ String nodeName,
+ JsonNode schemaNode,
+ JsonNode parent,
+ JClassContainer generatableType,
+ Schema schema) {
+
+ Optional refType = refType(nodeName, schemaNode, parent, generatableType, schema);
+ Collection unionTypes = new HashSet<>();
+
+ unionType("oneOf", nodeName, schemaNode, parent, generatableType, schema, unionTypes);
+ unionType("anyOf", nodeName, schemaNode, parent, generatableType, schema, unionTypes);
+ unionType("allOf", nodeName, schemaNode, parent, generatableType, schema, unionTypes);
+
+ JType javaType;
+ if (schemaNode.has("enum")) {
+ javaType =
+ ruleFactory.getEnumRule().apply(nodeName, schemaNode, parent, generatableType, schema);
+ } else if (!schemaNode.has("properties") && unionTypes.isEmpty() && refType.isPresent()) {
+ javaType = refType.get();
+
+ } else {
+ javaType =
+ ruleFactory
+ .getTypeRule()
+ .apply(nodeName, schemaNode, parent, generatableType.getPackage(), schema);
+ if (javaType instanceof JDefinedClass) {
+ populateClass((JDefinedClass) javaType, refType, unionTypes);
+ } else if (isCandidateForCreation(unionTypes)) {
+ javaType = createUnionClass(nodeName, generatableType.getPackage(), refType, unionTypes);
+ }
+ schema.setJavaTypeIfEmpty(javaType);
+ }
+ return javaType;
+ }
+
+ private boolean isCandidateForCreation(Collection unionTypes) {
+ return !unionTypes.isEmpty()
+ && unionTypes.stream()
+ .allMatch(
+ o ->
+ o instanceof JClass
+ && !((JClass) o).isPrimitive()
+ && !o.name().equals("String"));
+ }
+
+ private JDefinedClass populateClass(
+ JDefinedClass definedClass, Optional refType, Collection unionTypes) {
+ unionTypes.forEach(unionType -> wrapIt(definedClass, unionType));
+ refType.ifPresent(
+ type -> {
+ if (type instanceof JClass) {
+ definedClass._extends((JClass) type);
+ } else {
+ wrapIt(definedClass, type);
+ }
+ });
+ if (definedClass.constructors().hasNext()
+ && definedClass.getConstructor(new JType[0]) == null) {
+ definedClass.constructor(JMod.PUBLIC);
+ }
+ return definedClass;
+ }
+
+ private JDefinedClass createUnionClass(
+ String nodeName, JPackage container, Optional refType, Collection unionTypes) {
+ String className = ruleFactory.getNameHelper().getUniqueClassName(nodeName, null, container);
+ try {
+ return populateClass(container._class(className), refType, unionTypes);
+ } catch (JClassAlreadyExistsException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ private void wrapIt(JDefinedClass definedClass, JType unionType) {
+ JFieldVar instanceField =
+ definedClass.field(
+ JMod.PRIVATE,
+ unionType,
+ ruleFactory.getNameHelper().getPropertyName(unionType.name(), null));
+ JMethod method =
+ definedClass.method(
+ JMod.PUBLIC,
+ unionType,
+ ruleFactory.getNameHelper().getGetterName(unionType.name(), unionType, null));
+ method.body()._return(instanceField);
+ JMethod constructor = definedClass.constructor(JMod.PUBLIC);
+ constructor
+ .body()
+ .assign(
+ JExpr._this().ref(instanceField), constructor.param(unionType, instanceField.name()));
+ }
+
+ private void unionType(
+ String prefix,
+ String nodeName,
+ JsonNode schemaNode,
+ JsonNode parent,
+ JClassContainer generatableType,
+ Schema parentSchema,
+ Collection types) {
+ if (schemaNode.has(prefix)) {
+ int i = 0;
+ for (JsonNode oneOf : (ArrayNode) schemaNode.get(prefix)) {
+ String ref = parentSchema.getId().toString() + '/' + prefix + '/' + i++;
+ Schema schema =
+ ruleFactory
+ .getSchemaStore()
+ .create(
+ URI.create(ref),
+ ruleFactory.getGenerationConfig().getRefFragmentPathDelimiters());
+ types.add(
+ schema.isGenerated()
+ ? schema.getJavaType()
+ : apply(nodeName, oneOf, parent, generatableType.getPackage(), schema));
+ }
+ }
+ }
+
+ private Optional refType(
+ String nodeName,
+ JsonNode schemaNode,
+ JsonNode parent,
+ JClassContainer generatableType,
+ Schema parentSchema) {
+ if (schemaNode.has("$ref")) {
+ String ref = schemaNode.get("$ref").asText();
+ Schema schema =
+ ruleFactory
+ .getSchemaStore()
+ .create(
+ parentSchema,
+ ref,
+ ruleFactory.getGenerationConfig().getRefFragmentPathDelimiters());
+
+ return Optional.of(
+ schema.isGenerated()
+ ? schema.getJavaType()
+ : apply(
+ nameFromRef(ref, nodeName),
+ schema.getContent(),
+ parent,
+ generatableType,
+ schema));
+ }
+ return Optional.empty();
+ }
+
+ private String nameFromRef(String ref, String nodeName) {
+ if ("#".equals(ref)) {
+ return nodeName;
+ }
+ String nameFromRef;
+ if (!ref.contains("#")) {
+ nameFromRef = Jsonschema2Pojo.getNodeName(ref, ruleFactory.getGenerationConfig());
+ } else {
+ String[] nameParts = ref.split("[/\\#]");
+ nameFromRef = nameParts[nameParts.length - 1];
+ }
+
+ try {
+ return URLDecoder.decode(nameFromRef, "utf-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new GenerationException("Failed to decode ref: " + ref, e);
+ }
+ }
+}
diff --git a/custom-generator/src/main/java/io/serverlessworkflow/generator/UnevaluatedPropertiesRule.java b/custom-generator/src/main/java/io/serverlessworkflow/generator/UnevaluatedPropertiesRule.java
new file mode 100644
index 00000000..b523967b
--- /dev/null
+++ b/custom-generator/src/main/java/io/serverlessworkflow/generator/UnevaluatedPropertiesRule.java
@@ -0,0 +1,42 @@
+/*
+ * 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.generator;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.codemodel.JDefinedClass;
+import org.jsonschema2pojo.Schema;
+import org.jsonschema2pojo.rules.AdditionalPropertiesRule;
+import org.jsonschema2pojo.rules.Rule;
+
+public class UnevaluatedPropertiesRule extends AdditionalPropertiesRule
+ implements Rule {
+
+ public UnevaluatedPropertiesRule(UnreferencedFactory unreferencedFactory) {
+ super(unreferencedFactory);
+ }
+
+ public JDefinedClass apply(
+ String nodeName, JsonNode node, JsonNode parent, JDefinedClass jclass, Schema schema) {
+ JsonNode unevalutedNode = parent.get("unevaluatedProperties");
+ if (unevalutedNode != null && unevalutedNode.isBoolean() && unevalutedNode.asBoolean() == false
+ || (node == null && parent.has("properties"))) {
+ // no additional properties allowed
+ return jclass;
+ } else {
+ return super.apply(nodeName, node, parent, jclass, schema);
+ }
+ }
+}
diff --git a/api/src/main/java/io/serverlessworkflow/api/mapper/YamlObjectMapper.java b/custom-generator/src/main/java/io/serverlessworkflow/generator/UnreferencedFactory.java
similarity index 54%
rename from api/src/main/java/io/serverlessworkflow/api/mapper/YamlObjectMapper.java
rename to custom-generator/src/main/java/io/serverlessworkflow/generator/UnreferencedFactory.java
index 8e76d217..4726972d 100644
--- a/api/src/main/java/io/serverlessworkflow/api/mapper/YamlObjectMapper.java
+++ b/custom-generator/src/main/java/io/serverlessworkflow/generator/UnreferencedFactory.java
@@ -13,18 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.serverlessworkflow.api.mapper;
+package io.serverlessworkflow.generator;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
+import com.sun.codemodel.JClassContainer;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JType;
+import org.jsonschema2pojo.rules.Rule;
+import org.jsonschema2pojo.rules.RuleFactory;
-public class YamlObjectMapper extends BaseObjectMapper {
- public YamlObjectMapper() {
- this(null);
+public class UnreferencedFactory extends RuleFactory {
+ @Override
+ public Rule getSchemaRule() {
+ return new AllAnyOneOfSchemaRule(this);
}
- public YamlObjectMapper(WorkflowPropertySource context) {
- super(new YAMLFactory().enable(Feature.MINIMIZE_QUOTES), context);
+ @Override
+ public Rule getAdditionalPropertiesRule() {
+ return new UnevaluatedPropertiesRule(this);
}
}
diff --git a/diagram-rest/.gitignore b/diagram-rest/.gitignore
deleted file mode 100644
index 0d809f8c..00000000
--- a/diagram-rest/.gitignore
+++ /dev/null
@@ -1,31 +0,0 @@
-HELP.md
-target/
-!.mvn/wrapper/maven-wrapper.jar
-!**/src/main/**
-!**/src/test/**
-
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-build/
-
-### VS Code ###
-.vscode/
\ No newline at end of file
diff --git a/diagram-rest/pom.xml b/diagram-rest/pom.xml
deleted file mode 100644
index cbaafe2b..00000000
--- a/diagram-rest/pom.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.7.6
-
-
- io.serverless
- serverlessworkflow-diagram-rest
- 5.0.0-SNAPSHOT
- Serverless Workflow :: Diagram :: Rest API
- Rest Api Module for Diagram Generation
-
- 1.6.13
- 5.0.0-SNAPSHOT
-
-
-
- org.springframework.boot
- spring-boot-starter-webflux
-
-
- io.serverlessworkflow
- serverlessworkflow-diagram
- ${version.sw}
-
-
- org.springdoc
- springdoc-openapi-webflux-core
- ${version.webflux.core}
-
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- io.projectreactor
- reactor-test
- test
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-
diff --git a/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/Application.java b/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/Application.java
deleted file mode 100644
index 8965208c..00000000
--- a/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/Application.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.diagramrest;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application {
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-}
diff --git a/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/DiagramRequest.java b/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/DiagramRequest.java
deleted file mode 100644
index 09fa34b9..00000000
--- a/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/DiagramRequest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.diagramrest;
-
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Component;
-import org.springframework.web.reactive.function.server.ServerRequest;
-import org.springframework.web.reactive.function.server.ServerResponse;
-import reactor.core.publisher.Mono;
-
-@Component
-public class DiagramRequest {
-
- /**
- * Get the SVG diagram of a workflow from API Request
- *
- * @param sRequest workFlow (yml or json)
- * @return String SVG
- */
- public Mono getDiagramSVGFromWorkFlow(ServerRequest sRequest) {
- return ServerResponse.ok()
- .contentType(MediaType.APPLICATION_XML)
- .body(
- sRequest
- .bodyToMono(String.class)
- .flatMap(DiagramRequestHelper::getSvg)
- .onErrorMap(e -> new IllegalArgumentException(e.getMessage())),
- String.class);
- }
-}
diff --git a/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/DiagramRequestHelper.java b/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/DiagramRequestHelper.java
deleted file mode 100644
index 8ae6a77d..00000000
--- a/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/DiagramRequestHelper.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.diagramrest;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.interfaces.WorkflowDiagram;
-import io.serverlessworkflow.diagram.WorkflowDiagramImpl;
-import org.springframework.stereotype.Component;
-import reactor.core.publisher.Mono;
-
-@Component
-public class DiagramRequestHelper {
-
- public static Mono getSvg(String workFlow) {
- String diagramSVG;
- Workflow workflow = Workflow.fromSource(workFlow);
-
- WorkflowDiagram workflowDiagram =
- new WorkflowDiagramImpl()
- .showLegend(true)
- .setWorkflow(workflow)
- .setTemplate("custom-template");
-
- try {
- diagramSVG = workflowDiagram.getSvgDiagram();
- } catch (Exception e) {
- return Mono.just(e.getMessage());
- }
- return Mono.just(diagramSVG);
- }
-}
diff --git a/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/RouterRest.java b/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/RouterRest.java
deleted file mode 100644
index e5e6e462..00000000
--- a/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/RouterRest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.diagramrest;
-
-import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
-import static org.springframework.web.reactive.function.server.RouterFunctions.route;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.reactive.function.server.RouterFunction;
-import org.springframework.web.reactive.function.server.ServerResponse;
-
-@Configuration
-public class RouterRest implements RouterRestInterface {
- @Bean
- public RouterFunction diagramRouterFunction(DiagramRequest serverlessRequest) {
- return route(POST("/diagram"),
- serverlessRequest::getDiagramSVGFromWorkFlow);
- }
-
-}
diff --git a/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/RouterRestInterface.java b/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/RouterRestInterface.java
deleted file mode 100644
index 62ee3976..00000000
--- a/diagram-rest/src/main/java/io/serverlessworkflow/diagramrest/RouterRestInterface.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.diagramrest;
-
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.media.Content;
-import io.swagger.v3.oas.annotations.media.Schema;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import org.springdoc.core.annotations.RouterOperation;
-import org.springdoc.core.annotations.RouterOperations;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.reactive.function.server.RouterFunction;
-import org.springframework.web.reactive.function.server.ServerResponse;
-
-public interface RouterRestInterface {
-
- @RouterOperations(
- value = {
- @RouterOperation(
- path = "/diagram",
- produces = {"application/xml"},
- method = RequestMethod.POST,
- beanClass = DiagramRequest.class,
- beanMethod = "getDiagramSVGFromWorkFlow",
- operation =
- @Operation(
- operationId = "Get-Diagram-SVG-From-WorkFlow",
- responses = {
- @ApiResponse(
- responseCode = "200",
- description = "Get diagram SVG from workFlow",
- content =
- @Content(
- schema =
- @Schema(implementation = String.class)))
- }
- ))
- })
- RouterFunction diagramRouterFunction(DiagramRequest serverlessRequest);
-
-
-}
diff --git a/diagram-rest/src/main/resources/application.yml b/diagram-rest/src/main/resources/application.yml
deleted file mode 100644
index 8f13a949..00000000
--- a/diagram-rest/src/main/resources/application.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-springdoc:
- api-docs:
- groups:
- enable: true
- path: "/api/serverless/v3/api-docs"
- swagger-ui:
- path: "/api/serverless/swagger-ui.html"
-server:
- port: 8090
-spring:
- application:
- name: "Serverless Workflow Diagram Rest API"
\ No newline at end of file
diff --git a/diagram-rest/src/main/resources/templates/plantuml/custom-template.txt b/diagram-rest/src/main/resources/templates/plantuml/custom-template.txt
deleted file mode 100644
index e162afc5..00000000
--- a/diagram-rest/src/main/resources/templates/plantuml/custom-template.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-@startuml
-skinparam backgroundColor White
-skinparam legendBackgroundColor White
-skinparam legendBorderColor White
-skinparam state {
- StartColor Green
- EndColor Orange
- BackgroundColor GhostWhite
- BackgroundColor<< workflow >> White
- BorderColor Black
- ArrowColor Black
-
- BorderColor<< event >> #7fe5f0
- BorderColor<< operation >> #bada55
- BorderColor<< switch >> #92a0f2
- BorderColor<< sleep >> #b83b5e
- BorderColor<< parallel >> #6a2c70
- BorderColor<< inject >> #1e5f74
- BorderColor<< foreach >> #931a25
- BorderColor<< callback >> #ffcb8e
-}
-state "[(${diagram.title})]" as workflow << workflow >> {
-
-[# th:each="stateDef : ${diagram.modelStateDefs}" ]
-[(${stateDef.toString()})]
-[/]
-
-[# th:each="state : ${diagram.modelStates}" ]
-[(${state.toString()})]
-[/]
-
-[# th:each="connection : ${diagram.modelConnections}" ]
-[(${connection.toString()})]
-[/]
-
-}
-
-[# th:if="${diagram.showLegend}" ]
-legend center
-State Types and Border Colors:
-| Event | Operation | Switch | Sleep | Parallel | Inject | ForEach | CallBack |
-|<#7fe5f0>|<#bada55>|<#92a0f2>|<#b83b5e>|<#6a2c70>|<#1e5f74>|<#931a25>||
-endlegend
-[/]
-
-@enduml
\ No newline at end of file
diff --git a/diagram-rest/src/test/java/io/serverlessworkflow/diagramrest/DiagramGenerationTest.java b/diagram-rest/src/test/java/io/serverlessworkflow/diagramrest/DiagramGenerationTest.java
deleted file mode 100644
index 17041785..00000000
--- a/diagram-rest/src/test/java/io/serverlessworkflow/diagramrest/DiagramGenerationTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.diagramrest;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-@ExtendWith(SpringExtension.class)
-@ContextConfiguration(classes = {
- RouterRest.class,
- DiagramRequest.class,
- DiagramRequestHelper.class
-})
-@WebFluxTest
-class DiagramGenerationTest {
-
- private DiagramRequestHelper serverlesRequestHelper;
-
- public static final String input = "id: greeting\n" +
- "version: '1.0'\n" +
- "specVersion: '0.8'\n" +
- "name: Greeting Workflow\n" +
- "description: Greet Someone\n" +
- "start: Greet\n" +
- "functions:\n" +
- " - name: greetingFunction\n" +
- " operation: file://myapis/greetingapis.json#greeting\n" +
- "states:\n" +
- " - name: Greet\n" +
- " type: operation\n" +
- " actions:\n" +
- " - functionRef:\n" +
- " refName: greetingFunction\n" +
- " arguments:\n" +
- " name: \"${ .person.name }\"\n" +
- " actionDataFilter:\n" +
- " results: \"${ .greeting }\"\n" +
- " end: true";
-
- @BeforeEach
- void setUp() {
- serverlesRequestHelper = new DiagramRequestHelper();
- }
-
- @Test
- void getSvg() {
- Mono monoSvg = serverlesRequestHelper.getSvg(input);
- monoSvg.subscribe(result -> { assertNotNull(result); assertNotNull(result);});
- StepVerifier.create(monoSvg)
- .expectNextMatches(serverlessWorkFlowResponse -> serverlessWorkFlowResponse
- .contains("svg"))
- .verifyComplete();
- }
-}
\ No newline at end of file
diff --git a/diagram/.gitignore b/diagram/.gitignore
deleted file mode 100644
index d4dfde66..00000000
--- a/diagram/.gitignore
+++ /dev/null
@@ -1,31 +0,0 @@
-HELP.md
-target/
-!.mvn/wrapper/maven-wrapper.jar
-!**/src/main/**
-!**/src/test/**
-
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-build/
-
-### VS Code ###
-.vscode/
\ No newline at end of file
diff --git a/diagram/pom.xml b/diagram/pom.xml
deleted file mode 100644
index 1b02de7e..00000000
--- a/diagram/pom.xml
+++ /dev/null
@@ -1,152 +0,0 @@
-
- 4.0.0
-
-
- io.serverlessworkflow
- serverlessworkflow-parent
- 7.0.0-SNAPSHOT
-
-
- serverlessworkflow-diagram
- Serverless Workflow :: Diagram
- jar
- Diagram Generation
-
-
-
- org.slf4j
- slf4j-api
-
-
-
- io.serverlessworkflow
- serverlessworkflow-api
- ${project.version}
-
-
-
- org.apache.commons
- commons-lang3
-
-
-
- org.thymeleaf
- thymeleaf
-
-
- net.sourceforge.plantuml
- plantuml
-
-
- guru.nidi
- graphviz-java
-
-
-
-
- org.junit.jupiter
- junit-jupiter-api
- test
-
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.junit.jupiter
- junit-jupiter-params
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- ch.qos.logback
- logback-classic
- test
-
-
- org.assertj
- assertj-core
- test
-
-
- org.hamcrest
- hamcrest-library
- test
-
-
- org.skyscreamer
- jsonassert
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${project.build.directory}/checkstyle.log
- true
- true
- true
- false
- false
- ${checkstyle.logViolationsToConsole}
- ${checkstyle.failOnViolation}
-
- ${project.build.sourceDirectory}
- ${project.build.testSourceDirectory}
-
-
-
-
- compile
-
- check
-
-
-
-
-
- com.spotify.fmt
- fmt-maven-plugin
-
- src/main/java
- src/test/java
- false
- .*\.java
- false
- false
-
-
-
-
-
- format
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/diagram/src/main/java/io/serverlessworkflow/diagram/WorkflowDiagramImpl.java b/diagram/src/main/java/io/serverlessworkflow/diagram/WorkflowDiagramImpl.java
deleted file mode 100644
index 1fb5e656..00000000
--- a/diagram/src/main/java/io/serverlessworkflow/diagram/WorkflowDiagramImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.diagram;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.interfaces.WorkflowDiagram;
-import io.serverlessworkflow.diagram.utils.WorkflowToPlantuml;
-import java.io.ByteArrayOutputStream;
-import java.nio.charset.Charset;
-import net.sourceforge.plantuml.FileFormat;
-import net.sourceforge.plantuml.FileFormatOption;
-import net.sourceforge.plantuml.SourceStringReader;
-
-public class WorkflowDiagramImpl implements WorkflowDiagram {
-
- public static final String DEFAULT_TEMPLATE = "workflow-template";
-
- @SuppressWarnings("unused")
- private String source;
-
- @SuppressWarnings("unused")
- private String template = DEFAULT_TEMPLATE;
-
- private Workflow workflow;
- private boolean showLegend = false;
-
- @Override
- public WorkflowDiagram setWorkflow(Workflow workflow) {
- this.workflow = workflow;
- this.source = Workflow.toJson(workflow);
- return this;
- }
-
- @Override
- public WorkflowDiagram setSource(String source) {
- this.source = source;
- this.workflow = Workflow.fromSource(source);
- return this;
- }
-
- @Override
- public WorkflowDiagram setTemplate(String template) {
- this.template = template;
- return this;
- }
-
- @Override
- public String getSvgDiagram() throws Exception {
- if (workflow == null) {
- throw new IllegalAccessException("Unable to get diagram - no workflow set.");
- }
- String diagramSource = WorkflowToPlantuml.convert(template, workflow, showLegend);
- SourceStringReader reader = new SourceStringReader(diagramSource);
- final ByteArrayOutputStream os = new ByteArrayOutputStream();
- reader.generateImage(os, new FileFormatOption(FileFormat.SVG));
- os.close();
- return new String(os.toByteArray(), Charset.forName("UTF-8"));
- }
-
- @Override
- public WorkflowDiagram showLegend(boolean showLegend) {
- this.showLegend = showLegend;
- return this;
- }
-}
diff --git a/diagram/src/main/java/io/serverlessworkflow/diagram/config/ThymeleafConfig.java b/diagram/src/main/java/io/serverlessworkflow/diagram/config/ThymeleafConfig.java
deleted file mode 100644
index 56c6b042..00000000
--- a/diagram/src/main/java/io/serverlessworkflow/diagram/config/ThymeleafConfig.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.diagram.config;
-
-import org.thymeleaf.TemplateEngine;
-import org.thymeleaf.templatemode.TemplateMode;
-import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
-import org.thymeleaf.templateresolver.ITemplateResolver;
-
-public class ThymeleafConfig {
- public static TemplateEngine templateEngine;
-
- static {
- templateEngine = new TemplateEngine();
- templateEngine.addTemplateResolver(plantUmlTemplateResolver());
- }
-
- private static ITemplateResolver plantUmlTemplateResolver() {
- ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
- templateResolver.setPrefix("/templates/plantuml/");
- templateResolver.setSuffix(".txt");
- templateResolver.setTemplateMode(TemplateMode.TEXT);
- templateResolver.setCharacterEncoding("UTF8");
- templateResolver.setCheckExistence(true);
- templateResolver.setCacheable(false);
- return templateResolver;
- }
-}
diff --git a/diagram/src/main/java/io/serverlessworkflow/diagram/model/ModelConnection.java b/diagram/src/main/java/io/serverlessworkflow/diagram/model/ModelConnection.java
deleted file mode 100644
index 041e5521..00000000
--- a/diagram/src/main/java/io/serverlessworkflow/diagram/model/ModelConnection.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.diagram.model;
-
-import io.serverlessworkflow.diagram.utils.WorkflowDiagramUtils;
-
-public class ModelConnection {
- private String left;
- private String right;
- private String desc;
-
- public ModelConnection(String left, String right, String desc) {
- this.left = left.replaceAll("\\s", "");
- this.right = right.replaceAll("\\s", "");
- this.desc = desc;
- }
-
- @Override
- public String toString() {
- StringBuilder retBuff = new StringBuilder();
- retBuff.append(System.lineSeparator());
- retBuff.append(
- left.equals(WorkflowDiagramUtils.wfStart) ? WorkflowDiagramUtils.startEnd : left);
- retBuff.append(WorkflowDiagramUtils.connection);
- retBuff.append(
- right.equals(WorkflowDiagramUtils.wfEnd) ? WorkflowDiagramUtils.startEnd : right);
- if (desc != null && desc.trim().length() > 0) {
- retBuff.append(WorkflowDiagramUtils.description).append(desc);
- }
- retBuff.append(System.lineSeparator());
-
- return retBuff.toString();
- }
-
- public String getLeft() {
- return left;
- }
-
- public void setLeft(String left) {
- this.left = left;
- }
-
- public String getRight() {
- return right;
- }
-
- public void setRight(String right) {
- this.right = right;
- }
-
- public String getDesc() {
- return desc;
- }
-
- public void setDesc(String desc) {
- this.desc = desc;
- }
-}
diff --git a/diagram/src/main/java/io/serverlessworkflow/diagram/model/ModelState.java b/diagram/src/main/java/io/serverlessworkflow/diagram/model/ModelState.java
deleted file mode 100644
index 73c3cd0a..00000000
--- a/diagram/src/main/java/io/serverlessworkflow/diagram/model/ModelState.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.diagram.model;
-
-import io.serverlessworkflow.diagram.utils.WorkflowDiagramUtils;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ModelState {
-
- @SuppressWarnings("unused")
- private String name;
-
- private String noSpaceName;
- private List stateInfo = new ArrayList<>();
-
- public ModelState(String name) {
- this.name = name;
- this.noSpaceName = name.replaceAll("\\s", "");
- }
-
- public void addInfo(String info) {
- stateInfo.add(info);
- }
-
- @Override
- public String toString() {
- StringBuilder retBuff = new StringBuilder();
- retBuff.append(System.lineSeparator());
- for (String info : stateInfo) {
- retBuff
- .append(noSpaceName)
- .append(WorkflowDiagramUtils.description)
- .append(info)
- .append(System.lineSeparator());
- }
- retBuff.append(System.lineSeparator());
-
- return retBuff.toString();
- }
-}
diff --git a/diagram/src/main/java/io/serverlessworkflow/diagram/model/ModelStateDef.java b/diagram/src/main/java/io/serverlessworkflow/diagram/model/ModelStateDef.java
deleted file mode 100644
index de258316..00000000
--- a/diagram/src/main/java/io/serverlessworkflow/diagram/model/ModelStateDef.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.diagram.model;
-
-import io.serverlessworkflow.diagram.utils.WorkflowDiagramUtils;
-
-public class ModelStateDef {
- private String name;
- private String type;
- private String noSpaceName;
-
- public ModelStateDef(String name, String type) {
- this.name = name;
- this.type = type;
- this.noSpaceName = name.replaceAll("\\s", "");
- }
-
- @Override
- public String toString() {
- StringBuilder retBuff = new StringBuilder();
- retBuff
- .append(WorkflowDiagramUtils.stateDef)
- .append(noSpaceName)
- .append(WorkflowDiagramUtils.stateAsName)
- .append("\"" + name + "\"")
- .append(WorkflowDiagramUtils.typeDefStart)
- .append(type)
- .append(WorkflowDiagramUtils.typeDefEnd);
- return retBuff.toString();
- }
-}
diff --git a/diagram/src/main/java/io/serverlessworkflow/diagram/model/WorkflowDiagramModel.java b/diagram/src/main/java/io/serverlessworkflow/diagram/model/WorkflowDiagramModel.java
deleted file mode 100644
index f4050799..00000000
--- a/diagram/src/main/java/io/serverlessworkflow/diagram/model/WorkflowDiagramModel.java
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * 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.diagram.model;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.api.states.*;
-import io.serverlessworkflow.api.switchconditions.DataCondition;
-import io.serverlessworkflow.api.switchconditions.EventCondition;
-import io.serverlessworkflow.diagram.utils.WorkflowDiagramUtils;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-public class WorkflowDiagramModel {
- private Workflow workflow;
-
- private String title;
- private String legend;
- private String footer;
- private List modelStateDefs = new ArrayList<>();
- private List modelStates = new ArrayList<>();
- private List modelConnections = new ArrayList<>();
- private boolean showLegend;
-
- public WorkflowDiagramModel(Workflow workflow, boolean showLegend) {
- this.workflow = workflow;
- this.showLegend = showLegend;
- inspect(workflow);
- }
-
- private void inspect(Workflow workflow) {
- // title
- setTitle(workflow.getName());
- if (workflow.getVersion() != null && workflow.getVersion().trim().length() > 0) {
- StringBuilder titleBuf =
- new StringBuilder()
- .append(workflow.getName())
- .append(WorkflowDiagramUtils.versionSeparator)
- .append(workflow.getVersion());
- setTitle(titleBuf.toString());
- }
-
- // legend
- if (workflow.getDescription() != null && workflow.getDescription().trim().length() > 0) {
- StringBuilder legendBuff =
- new StringBuilder()
- .append(WorkflowDiagramUtils.legendStart)
- .append(workflow.getDescription())
- .append(WorkflowDiagramUtils.legendEnd);
- setLegend(legendBuff.toString());
- } else {
- setLegend("");
- }
-
- // footer
- setFooter(WorkflowDiagramUtils.footer);
-
- // state definitions
- inspectStateDefinitions(workflow);
-
- // states info
- inspectStatesInfo(workflow);
-
- // states connections
- inspectStatesConnections(workflow);
- }
-
- private void inspectStateDefinitions(Workflow workflow) {
- for (State state : workflow.getStates()) {
- modelStateDefs.add(new ModelStateDef(state.getName(), state.getType().value()));
- }
- }
-
- private void inspectStatesConnections(Workflow workflow) {
- State workflowStartState = WorkflowDiagramUtils.getWorkflowStartState(workflow);
- modelConnections.add(
- new ModelConnection(WorkflowDiagramUtils.wfStart, workflowStartState.getName(), ""));
-
- List workflowStates = workflow.getStates();
- for (State state : workflowStates) {
- if (state instanceof SwitchState) {
- SwitchState switchState = (SwitchState) state;
- if (switchState.getDataConditions() != null && switchState.getDataConditions().size() > 0) {
- for (DataCondition dataCondition : switchState.getDataConditions()) {
-
- if (dataCondition.getTransition() != null) {
- if (dataCondition.getTransition().getProduceEvents() != null
- && dataCondition.getTransition().getProduceEvents().size() > 0) {
- List producedEvents =
- dataCondition.getTransition().getProduceEvents().stream()
- .map(t -> t.getEventRef())
- .collect(Collectors.toList());
-
- String desc = "";
- if (dataCondition.getName() != null
- && dataCondition.getName().trim().length() > 0) {
- desc = dataCondition.getName();
- }
- desc +=
- " Produced Events: " + producedEvents.stream().collect(Collectors.joining(","));
- modelConnections.add(
- new ModelConnection(
- switchState.getName(), dataCondition.getTransition().getNextState(), desc));
- } else {
- String desc = "";
- if (dataCondition.getName() != null
- && dataCondition.getName().trim().length() > 0) {
- desc = dataCondition.getName();
- }
- modelConnections.add(
- new ModelConnection(
- switchState.getName(), dataCondition.getTransition().getNextState(), desc));
- }
- }
-
- if (dataCondition.getEnd() != null) {
- if (dataCondition.getEnd().getProduceEvents() != null
- && dataCondition.getEnd().getProduceEvents().size() > 0) {
- List producedEvents =
- dataCondition.getEnd().getProduceEvents().stream()
- .map(t -> t.getEventRef())
- .collect(Collectors.toList());
-
- String desc = "";
- if (dataCondition.getName() != null
- && dataCondition.getName().trim().length() > 0) {
- desc = dataCondition.getName();
- }
- desc +=
- " Produced Events: " + producedEvents.stream().collect(Collectors.joining(","));
- modelConnections.add(
- new ModelConnection(switchState.getName(), WorkflowDiagramUtils.wfEnd, desc));
- } else {
- String desc = "";
- if (dataCondition.getName() != null
- && dataCondition.getName().trim().length() > 0) {
- desc = dataCondition.getName();
- }
- modelConnections.add(
- new ModelConnection(switchState.getName(), WorkflowDiagramUtils.wfEnd, desc));
- }
- }
- }
- }
-
- if (switchState.getEventConditions() != null
- && switchState.getEventConditions().size() > 0) {
- for (EventCondition eventCondition : switchState.getEventConditions()) {
-
- if (eventCondition.getTransition() != null) {
- if (eventCondition.getTransition().getProduceEvents() != null
- && eventCondition.getTransition().getProduceEvents().size() > 0) {
- List producedEvents =
- eventCondition.getTransition().getProduceEvents().stream()
- .map(t -> t.getEventRef())
- .collect(Collectors.toList());
-
- String desc = "";
- if (eventCondition.getName() != null
- && eventCondition.getName().trim().length() > 0) {
- desc = eventCondition.getName();
- }
- desc +=
- " Produced Events: " + producedEvents.stream().collect(Collectors.joining(","));
- modelConnections.add(
- new ModelConnection(
- switchState.getName(),
- eventCondition.getTransition().getNextState(),
- desc));
- } else {
- String desc = "";
- if (eventCondition.getName() != null
- && eventCondition.getName().trim().length() > 0) {
- desc = eventCondition.getName();
- }
- modelConnections.add(
- new ModelConnection(
- switchState.getName(),
- eventCondition.getTransition().getNextState(),
- desc));
- }
- }
-
- if (eventCondition.getEnd() != null) {
- if (eventCondition.getEnd().getProduceEvents() != null
- && eventCondition.getEnd().getProduceEvents().size() > 0) {
- List producedEvents =
- eventCondition.getEnd().getProduceEvents().stream()
- .map(t -> t.getEventRef())
- .collect(Collectors.toList());
-
- String desc = "";
- if (eventCondition.getName() != null
- && eventCondition.getName().trim().length() > 0) {
- desc = eventCondition.getName();
- }
- desc +=
- " Produced Events: " + producedEvents.stream().collect(Collectors.joining(","));
- modelConnections.add(
- new ModelConnection(switchState.getName(), WorkflowDiagramUtils.wfEnd, desc));
- } else {
- String desc = "";
- if (eventCondition.getName() != null
- && eventCondition.getName().trim().length() > 0) {
- desc = eventCondition.getName();
- }
- modelConnections.add(
- new ModelConnection(switchState.getName(), WorkflowDiagramUtils.wfEnd, desc));
- }
- }
- }
- }
-
- // default
- if (switchState.getDefaultCondition() != null) {
- if (switchState.getDefaultCondition().getTransition() != null) {
- if (switchState.getDefaultCondition().getTransition().getProduceEvents() != null
- && switchState.getDefaultCondition().getTransition().getProduceEvents().size()
- > 0) {
- List producedEvents =
- switchState.getDefaultCondition().getTransition().getProduceEvents().stream()
- .map(t -> t.getEventRef())
- .collect(Collectors.toList());
-
- String desc = "default - ";
- desc +=
- " Produced Events: " + producedEvents.stream().collect(Collectors.joining(","));
- modelConnections.add(
- new ModelConnection(
- switchState.getName(),
- switchState.getDefaultCondition().getTransition().getNextState(),
- desc));
- } else {
- String desc = "default";
- modelConnections.add(
- new ModelConnection(
- switchState.getName(),
- switchState.getDefaultCondition().getTransition().getNextState(),
- desc));
- }
- }
-
- if (switchState.getDefaultCondition().getEnd() != null) {
- if (switchState.getDefaultCondition().getEnd().getProduceEvents() != null
- && switchState.getDefaultCondition().getEnd().getProduceEvents().size() > 0) {
- List producedEvents =
- switchState.getDefaultCondition().getEnd().getProduceEvents().stream()
- .map(t -> t.getEventRef())
- .collect(Collectors.toList());
-
- String desc = "default - ";
- desc +=
- " Produced Events: " + producedEvents.stream().collect(Collectors.joining(","));
- modelConnections.add(
- new ModelConnection(switchState.getName(), WorkflowDiagramUtils.wfEnd, desc));
- } else {
- String desc = "default";
- modelConnections.add(
- new ModelConnection(switchState.getName(), WorkflowDiagramUtils.wfEnd, desc));
- }
- }
- }
- } else {
- if (state.getTransition() != null) {
- if (state.getTransition().getProduceEvents() != null
- && state.getTransition().getProduceEvents().size() > 0) {
- List producedEvents =
- state.getTransition().getProduceEvents().stream()
- .map(t -> t.getEventRef())
- .collect(Collectors.toList());
-
- String desc =
- "Produced Events: " + producedEvents.stream().collect(Collectors.joining(","));
- modelConnections.add(
- new ModelConnection(state.getName(), state.getTransition().getNextState(), desc));
- } else {
- modelConnections.add(
- new ModelConnection(state.getName(), state.getTransition().getNextState(), ""));
- }
- }
-
- if (state.getEnd() != null) {
- if (state.getEnd().getProduceEvents() != null
- && state.getEnd().getProduceEvents().size() > 0) {
- List producedEvents =
- state.getEnd().getProduceEvents().stream()
- .map(t -> t.getEventRef())
- .collect(Collectors.toList());
-
- String desc =
- "Produced Events: " + producedEvents.stream().collect(Collectors.joining(","));
- modelConnections.add(
- new ModelConnection(state.getName(), WorkflowDiagramUtils.wfEnd, desc));
- } else {
- modelConnections.add(
- new ModelConnection(state.getName(), WorkflowDiagramUtils.wfEnd, ""));
- }
- }
- }
- }
- }
-
- private void inspectStatesInfo(Workflow workflow) {
- List workflowStates = workflow.getStates();
- for (State state : workflowStates) {
- ModelState modelState = new ModelState(state.getName());
-
- if (state instanceof EventState) {
- EventState eventState = (EventState) state;
-
- List events =
- eventState.getOnEvents().stream()
- .flatMap(t -> t.getEventRefs().stream())
- .collect(Collectors.toList());
-
- modelState.addInfo("Type: Event State");
- modelState.addInfo("Events: " + events.stream().collect(Collectors.joining(" ")));
- }
-
- if (state instanceof OperationState) {
- OperationState operationState = (OperationState) state;
-
- modelState.addInfo("Type: Operation State");
- modelState.addInfo(
- "Action mode: "
- + Optional.ofNullable(operationState.getActionMode())
- .orElse(OperationState.ActionMode.SEQUENTIAL));
- modelState.addInfo(
- "Num. of actions: "
- + Optional.ofNullable(operationState.getActions().size()).orElse(0));
- }
-
- if (state instanceof SwitchState) {
- SwitchState switchState = (SwitchState) state;
-
- modelState.addInfo("Type: Switch State");
- if (switchState.getDataConditions() != null && switchState.getDataConditions().size() > 0) {
- modelState.addInfo("Condition type: data-based");
- modelState.addInfo("Num. of conditions: " + switchState.getDataConditions().size());
- }
-
- if (switchState.getEventConditions() != null
- && switchState.getEventConditions().size() > 0) {
- modelState.addInfo("Condition type: event-based");
- modelState.addInfo("Num. of conditions: " + switchState.getEventConditions().size());
- }
-
- if (switchState.getDefaultCondition() != null) {
- if (switchState.getDefaultCondition().getTransition() != null) {
- modelState.addInfo(
- "Default to: " + switchState.getDefaultCondition().getTransition().getNextState());
- }
-
- if (switchState.getDefaultCondition().getEnd() != null) {
- modelState.addInfo("Default to: End");
- }
- }
- }
-
- if (state instanceof SleepState) {
- SleepState sleepState = (SleepState) state;
-
- modelState.addInfo("Type: Sleep State");
- modelState.addInfo("Duration: " + sleepState.getDuration());
- }
-
- if (state instanceof ParallelState) {
- ParallelState parallelState = (ParallelState) state;
-
- modelState.addInfo("Type: Parallel State");
- modelState.addInfo(
- "Completion type: \"" + parallelState.getCompletionType().value() + "\"");
- modelState.addInfo("Num. of branches: " + parallelState.getBranches().size());
- }
-
- if (state instanceof InjectState) {
- modelState.addInfo("Type: Inject State");
- }
-
- if (state instanceof ForEachState) {
- ForEachState forEachState = (ForEachState) state;
-
- modelState.addInfo("Type: ForEach State");
- modelState.addInfo("Input collection: " + forEachState.getInputCollection());
- if (forEachState.getActions() != null && forEachState.getActions().size() > 0) {
- modelState.addInfo("Num. of actions: " + forEachState.getActions().size());
- }
- }
-
- if (state instanceof CallbackState) {
- CallbackState callbackState = (CallbackState) state;
-
- modelState.addInfo("Type: Callback State");
- modelState.addInfo(
- "Callback function: " + callbackState.getAction().getFunctionRef().getRefName());
- modelState.addInfo("Callback event: " + callbackState.getEventRef());
- }
-
- modelStates.add(modelState);
- }
- }
-
- public Workflow getWorkflow() {
- return workflow;
- }
-
- public void setWorkflow(Workflow workflow) {
- this.workflow = workflow;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getLegend() {
- return legend;
- }
-
- public void setLegend(String legend) {
- this.legend = legend;
- }
-
- public String getFooter() {
- return footer;
- }
-
- public void setFooter(String footer) {
- this.footer = footer;
- }
-
- public List getModelStates() {
- return modelStates;
- }
-
- public void setModelStates(List modelStates) {
- this.modelStates = modelStates;
- }
-
- public List getModelConnections() {
- return modelConnections;
- }
-
- public void setModelConnections(List modelConnections) {
- this.modelConnections = modelConnections;
- }
-
- public List getModelStateDefs() {
- return modelStateDefs;
- }
-
- public void setModelStateDefs(List modelStateDefs) {
- this.modelStateDefs = modelStateDefs;
- }
-
- public boolean getShowLegend() {
- return showLegend;
- }
-}
diff --git a/diagram/src/main/java/io/serverlessworkflow/diagram/utils/WorkflowDiagramUtils.java b/diagram/src/main/java/io/serverlessworkflow/diagram/utils/WorkflowDiagramUtils.java
deleted file mode 100644
index 586d91db..00000000
--- a/diagram/src/main/java/io/serverlessworkflow/diagram/utils/WorkflowDiagramUtils.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.diagram.utils;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.api.states.DefaultState;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class WorkflowDiagramUtils {
- public static final String versionSeparator = " v";
- public static final String wfStart = "wfstart";
- public static final String wfEnd = "wfend";
- public static final String startEnd = "[*]";
- public static final String connection = " --> ";
- public static final String description = " : ";
- public static final String title = "title ";
- public static final String footer =
- "center footer Serverless Workflow Specification - serverlessworkflow.io";
- public static final String legendStart =
- new StringBuilder().append("legend top center").append(System.lineSeparator()).toString();
- public static final String legendEnd =
- new StringBuilder().append(System.lineSeparator()).append("endlegend").toString();
- public static final String stateDef = "state ";
- public static final String stateAsName = " as ";
- public static final String typeDefStart = " << ";
- public static final String typeDefEnd = " >> ";
-
- public static State getWorkflowStartState(Workflow workflow) {
- return workflow.getStates().stream()
- .filter(ws -> ws.getName().equals(workflow.getStart().getStateName()))
- .findFirst()
- .get();
- }
-
- public static List getStatesByType(Workflow workflow, DefaultState.Type type) {
- return workflow.getStates().stream()
- .filter(ws -> ws.getType() == type)
- .collect(Collectors.toList());
- }
-
- public static List getWorkflowEndStates(Workflow workflow) {
- return workflow.getStates().stream()
- .filter(ws -> ws.getEnd() != null)
- .collect(Collectors.toList());
- }
-}
diff --git a/diagram/src/main/java/io/serverlessworkflow/diagram/utils/WorkflowToPlantuml.java b/diagram/src/main/java/io/serverlessworkflow/diagram/utils/WorkflowToPlantuml.java
deleted file mode 100644
index 956bcbeb..00000000
--- a/diagram/src/main/java/io/serverlessworkflow/diagram/utils/WorkflowToPlantuml.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.diagram.utils;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.diagram.config.ThymeleafConfig;
-import io.serverlessworkflow.diagram.model.WorkflowDiagramModel;
-import org.thymeleaf.TemplateEngine;
-import org.thymeleaf.context.Context;
-
-public class WorkflowToPlantuml {
-
- public static String convert(String template, Workflow workflow, boolean showLegend) {
- TemplateEngine plantUmlTemplateEngine = ThymeleafConfig.templateEngine;
- Context context = new Context();
- context.setVariable("diagram", new WorkflowDiagramModel(workflow, showLegend));
-
- return plantUmlTemplateEngine.process(template, context);
- }
-}
diff --git a/diagram/src/main/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowDiagram b/diagram/src/main/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowDiagram
deleted file mode 100644
index 637a614f..00000000
--- a/diagram/src/main/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowDiagram
+++ /dev/null
@@ -1 +0,0 @@
-io.serverlessworkflow.diagram.WorkflowDiagramImpl
\ No newline at end of file
diff --git a/diagram/src/main/resources/templates/plantuml/workflow-template.txt b/diagram/src/main/resources/templates/plantuml/workflow-template.txt
deleted file mode 100644
index daf5fd6c..00000000
--- a/diagram/src/main/resources/templates/plantuml/workflow-template.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-@startuml
-skinparam backgroundColor White
-skinparam legendBackgroundColor White
-skinparam legendBorderColor White
-skinparam state {
- StartColor Green
- EndColor Orange
- BackgroundColor GhostWhite
- BackgroundColor<< workflow >> White
- BorderColor Black
- ArrowColor Black
-
- BorderColor<< event >> #7fe5f0
- BorderColor<< operation >> #bada55
- BorderColor<< switch >> #92a0f2
- BorderColor<< sleep >> #b83b5e
- BorderColor<< parallel >> #6a2c70
- BorderColor<< inject >> #1e5f74
- BorderColor<< foreach >> #931a25
- BorderColor<< callback >> #ffcb8e
-}
-state "[(${diagram.title})]" as workflow << workflow >> {
-
-[# th:each="stateDef : ${diagram.modelStateDefs}" ]
-[(${stateDef.toString()})]
-[/]
-
-[# th:each="state : ${diagram.modelStates}" ]
-[(${state.toString()})]
-[/]
-
-[# th:each="connection : ${diagram.modelConnections}" ]
-[(${connection.toString()})]
-[/]
-
-}
-
-[# th:if="${diagram.showLegend}" ]
-legend center
-State Types and Border Colors:
-| Event | Operation | Switch | Sleep | Parallel | Inject | ForEach | CallBack |
-|<#7fe5f0>|<#bada55>|<#92a0f2>|<#b83b5e>|<#6a2c70>|<#1e5f74>|<#931a25>|<#ffcb8e>|
-endlegend
-[/]
-
-@enduml
\ No newline at end of file
diff --git a/diagram/src/test/java/io/serverlessworkflow/diagram/test/CustomTemplateWorkflowDiagramTest.java b/diagram/src/test/java/io/serverlessworkflow/diagram/test/CustomTemplateWorkflowDiagramTest.java
deleted file mode 100644
index 451ef265..00000000
--- a/diagram/src/test/java/io/serverlessworkflow/diagram/test/CustomTemplateWorkflowDiagramTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.diagram.test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.interfaces.WorkflowDiagram;
-import io.serverlessworkflow.diagram.WorkflowDiagramImpl;
-import io.serverlessworkflow.diagram.test.utils.DiagramTestUtils;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-public class CustomTemplateWorkflowDiagramTest {
-
- @ParameterizedTest
- @ValueSource(strings = {"/examples/applicantrequest.json", "/examples/applicantrequest.yml"})
- public void testSpecExamplesParsing(String workflowLocation) throws Exception {
-
- Workflow workflow = Workflow.fromSource(DiagramTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- WorkflowDiagram workflowDiagram =
- new WorkflowDiagramImpl()
- .showLegend(true)
- .setWorkflow(workflow)
- .setTemplate("custom-template");
-
- String diagramSVG = workflowDiagram.getSvgDiagram();
- Assertions.assertNotNull(diagramSVG);
- // check custom template "customcolor" in the legend
- Assertions.assertTrue(diagramSVG.contains("customcolor"));
- }
-}
diff --git a/diagram/src/test/java/io/serverlessworkflow/diagram/test/WorkflowDiagramTest.java b/diagram/src/test/java/io/serverlessworkflow/diagram/test/WorkflowDiagramTest.java
deleted file mode 100644
index 5251634b..00000000
--- a/diagram/src/test/java/io/serverlessworkflow/diagram/test/WorkflowDiagramTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.diagram.test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.interfaces.WorkflowDiagram;
-import io.serverlessworkflow.diagram.WorkflowDiagramImpl;
-import io.serverlessworkflow.diagram.test.utils.DiagramTestUtils;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-public class WorkflowDiagramTest {
-
- @ParameterizedTest
- @ValueSource(
- strings = {
- "/examples/applicantrequest.json",
- "/examples/applicantrequest.yml",
- "/examples/carauctionbids.json",
- "/examples/carauctionbids.yml",
- "/examples/creditcheck.json",
- "/examples/creditcheck.yml",
- "/examples/eventbasedgreeting.json",
- "/examples/eventbasedgreeting.yml",
- "/examples/finalizecollegeapplication.json",
- "/examples/finalizecollegeapplication.yml",
- "/examples/greeting.json",
- "/examples/greeting.yml",
- "/examples/helloworld.json",
- "/examples/helloworld.yml",
- "/examples/jobmonitoring.json",
- "/examples/jobmonitoring.yml",
- "/examples/monitorpatient.json",
- "/examples/monitorpatient.yml",
- "/examples/parallel.json",
- "/examples/parallel.yml",
- "/examples/provisionorder.json",
- "/examples/provisionorder.yml",
- "/examples/sendcloudevent.json",
- "/examples/sendcloudevent.yml",
- "/examples/solvemathproblems.json",
- "/examples/solvemathproblems.yml",
- "/examples/foreachstatewithactions.json",
- "/examples/foreachstatewithactions.yml",
- "/examples/periodicinboxcheck.json",
- "/examples/periodicinboxcheck.yml",
- "/examples/vetappointmentservice.json",
- "/examples/vetappointmentservice.yml",
- "/examples/eventbasedtransition.json",
- "/examples/eventbasedtransition.yml",
- "/examples/roomreadings.json",
- "/examples/roomreadings.yml",
- "/examples/checkcarvitals.json",
- "/examples/checkcarvitals.yml",
- "/examples/booklending.json",
- "/examples/booklending.yml"
- })
- public void testSpecExamplesParsing(String workflowLocation) throws Exception {
-
- Workflow workflow = Workflow.fromSource(DiagramTestUtils.readWorkflowFile(workflowLocation));
-
- assertNotNull(workflow);
- assertNotNull(workflow.getId());
- assertNotNull(workflow.getName());
- assertNotNull(workflow.getStates());
-
- WorkflowDiagram workflowDiagram = new WorkflowDiagramImpl();
- workflowDiagram.setWorkflow(workflow);
-
- String diagramSVG = workflowDiagram.getSvgDiagram();
-
- Assertions.assertNotNull(diagramSVG);
- }
-}
diff --git a/diagram/src/test/java/io/serverlessworkflow/diagram/test/utils/DiagramTestUtils.java b/diagram/src/test/java/io/serverlessworkflow/diagram/test/utils/DiagramTestUtils.java
deleted file mode 100644
index 6365ba78..00000000
--- a/diagram/src/test/java/io/serverlessworkflow/diagram/test/utils/DiagramTestUtils.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.diagram.test.utils;
-
-import io.serverlessworkflow.api.mapper.JsonObjectMapper;
-import io.serverlessworkflow.api.mapper.YamlObjectMapper;
-import java.io.*;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-public class DiagramTestUtils {
- private static JsonObjectMapper jsonObjectMapper = new JsonObjectMapper();
- private static YamlObjectMapper yamlObjectMapper = new YamlObjectMapper();
-
- public static final Path resourceDirectory = Paths.get("src", "test", "resources");
- public static final String absolutePath = resourceDirectory.toFile().getAbsolutePath();
-
- public static Path getResourcePath(String file) {
- return Paths.get(absolutePath + File.separator + file);
- }
-
- public static InputStream getInputStreamFromPath(Path path) throws Exception {
- return Files.newInputStream(path);
- }
-
- public static String readWorkflowFile(String location) {
- return readFileAsString(classpathResourceReader(location));
- }
-
- public static Reader classpathResourceReader(String location) {
- return new InputStreamReader(DiagramTestUtils.class.getResourceAsStream(location));
- }
-
- public static String readFileAsString(Reader reader) {
- try {
- StringBuilder fileData = new StringBuilder(1000);
- char[] buf = new char[1024];
- int numRead;
- while ((numRead = reader.read(buf)) != -1) {
- String readData = String.valueOf(buf, 0, numRead);
- fileData.append(readData);
- buf = new char[1024];
- }
- reader.close();
- return fileData.toString();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/diagram/src/test/resources/examples/applicantrequest.json b/diagram/src/test/resources/examples/applicantrequest.json
deleted file mode 100644
index 1621c2bd..00000000
--- a/diagram/src/test/resources/examples/applicantrequest.json
+++ /dev/null
@@ -1,59 +0,0 @@
-{
- "id": "applicantrequest",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Applicant Request Decision Workflow",
- "description": "Determine if applicant request is valid",
- "start": "CheckApplication",
- "functions": [
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/applicationapi.json#emailRejection"
- }
- ],
- "states":[
- {
- "name":"CheckApplication",
- "type":"switch",
- "dataConditions": [
- {
- "condition": "${ .applicants | .age >= 18 }",
- "transition": "StartApplication"
- },
- {
- "condition": "${ .applicants | .age < 18 }",
- "transition": "RejectApplication"
- }
- ],
- "defaultCondition": {
- "transition": "RejectApplication"
- }
- },
- {
- "name": "StartApplication",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "startApplicationWorkflowId"
- }
- ],
- "end": true
- },
- {
- "name":"RejectApplication",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .applicant }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/applicantrequest.yml b/diagram/src/test/resources/examples/applicantrequest.yml
deleted file mode 100644
index ae0db1be..00000000
--- a/diagram/src/test/resources/examples/applicantrequest.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-id: applicantrequest
-version: '1.0'
-specVersion: '0.8'
-name: Applicant Request Decision Workflow
-description: Determine if applicant request is valid
-start: CheckApplication
-functions:
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/applicationapi.json#emailRejection
-states:
- - name: CheckApplication
- type: switch
- dataConditions:
- - condition: "${ .applicants | .age >= 18 }"
- transition: StartApplication
- - condition: "${ .applicants | .age < 18 }"
- transition: RejectApplication
- defaultCondition:
- transition: RejectApplication
- - name: StartApplication
- type: operation
- actions:
- - subFlowRef: startApplicationWorkflowId
- end: true
- - name: RejectApplication
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .applicant }"
- end: true
diff --git a/diagram/src/test/resources/examples/booklending.json b/diagram/src/test/resources/examples/booklending.json
deleted file mode 100644
index faad4ea5..00000000
--- a/diagram/src/test/resources/examples/booklending.json
+++ /dev/null
@@ -1,130 +0,0 @@
-{
- "id": "booklending",
- "name": "Book Lending Workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "Book Lending Request",
- "states": [
- {
- "name": "Book Lending Request",
- "type": "event",
- "onEvents": [
- {
- "eventRefs": ["Book Lending Request Event"]
- }
- ],
- "transition": "Get Book Status"
- },
- {
- "name": "Get Book Status",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "Get status for book",
- "arguments": {
- "bookid": "${ .book.id }"
- }
- }
- }
- ],
- "transition": "Book Status Decision"
- },
- {
- "name": "Book Status Decision",
- "type": "switch",
- "dataConditions": [
- {
- "name": "Book is on loan",
- "condition": "${ .book.status == \"onloan\" }",
- "transition": "Report Status To Lender"
- },
- {
- "name": "Check is available",
- "condition": "${ .book.status == \"available\" }",
- "transition": "Check Out Book"
- }
- ]
- },
- {
- "name": "Report Status To Lender",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "Send status to lender",
- "arguments": {
- "bookid": "${ .book.id }",
- "message": "Book ${ .book.title } is already on loan"
- }
- }
- }
- ],
- "transition": "Wait for Lender response"
- },
- {
- "name": "Wait for Lender response",
- "type": "switch",
- "eventConditions": [
- {
- "name": "Hold Book",
- "eventRef": "Hold Book Event",
- "transition": "Request Hold"
- },
- {
- "name": "Decline Book Hold",
- "eventRef": "Decline Hold Event",
- "transition": "Cancel Request"
- }
- ]
- },
- {
- "name": "Request Hold",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "Request hold for lender",
- "arguments": {
- "bookid": "${ .book.id }",
- "lender": "${ .lender }"
- }
- }
- }
- ],
- "transition": "Wait two weeks"
- },
- {
- "name": "Wait two weeks",
- "type": "sleep",
- "duration": "P2W",
- "transition": "Get Book Status"
- },
- {
- "name": "Check Out Book",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "Check out book with id",
- "arguments": {
- "bookid": "${ .book.id }"
- }
- }
- },
- {
- "functionRef": {
- "refName": "Notify Lender for checkout",
- "arguments": {
- "bookid": "${ .book.id }",
- "lender": "${ .lender }"
- }
- }
- }
- ],
- "end": true
- }
- ],
- "functions": [],
- "events": []
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/booklending.yml b/diagram/src/test/resources/examples/booklending.yml
deleted file mode 100644
index 57903c07..00000000
--- a/diagram/src/test/resources/examples/booklending.yml
+++ /dev/null
@@ -1,75 +0,0 @@
-id: booklending
-name: Book Lending Workflow
-version: '1.0'
-specVersion: '0.8'
-start: Book Lending Request
-states:
- - name: Book Lending Request
- type: event
- onEvents:
- - eventRefs:
- - Book Lending Request Event
- transition: Get Book Status
- - name: Get Book Status
- type: operation
- actions:
- - functionRef:
- refName: Get status for book
- arguments:
- bookid: "${ .book.id }"
- transition: Book Status Decision
- - name: Book Status Decision
- type: switch
- dataConditions:
- - name: Book is on loan
- condition: ${ .book.status == "onloan" }
- transition: Report Status To Lender
- - name: Check is available
- condition: ${ .book.status == "available" }
- transition: Check Out Book
- - name: Report Status To Lender
- type: operation
- actions:
- - functionRef:
- refName: Send status to lender
- arguments:
- bookid: "${ .book.id }"
- message: Book ${ .book.title } is already on loan
- transition: Wait for Lender response
- - name: Wait for Lender response
- type: switch
- eventConditions:
- - name: Hold Book
- eventRef: Hold Book Event
- transition: Request Hold
- - name: Decline Book Hold
- eventRef: Decline Hold Event
- transition: Cancel Request
- - name: Request Hold
- type: operation
- actions:
- - functionRef:
- refName: Request fold for lender
- arguments:
- bookid: "${ .book.id }"
- lender: "${ .lender }"
- transition: Wait two weeks
- - name: Wait two weeks
- type: sleep
- duration: P2W
- transition: Get Book Status
- - name: Check Out Book
- type: operation
- actions:
- - functionRef:
- refName: Check out book with id
- arguments:
- bookid: "${ .book.id }"
- - functionRef:
- refName: Notify Lender for checkout
- arguments:
- bookid: "${ .book.id }"
- lender: "${ .lender }"
- end: true
-functions:
-events:
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/carauctionbids.json b/diagram/src/test/resources/examples/carauctionbids.json
deleted file mode 100644
index 7ea84d9a..00000000
--- a/diagram/src/test/resources/examples/carauctionbids.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "id": "handleCarAuctionBid",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Car Auction Bidding Workflow",
- "description": "Store a single bid whole the car auction is active",
- "start": {
- "stateName": "StoreCarAuctionBid",
- "schedule": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z"
- },
- "functions": [
- {
- "name": "StoreBidFunction",
- "operation": "http://myapis.org/carauctionapi.json#storeBid"
- }
- ],
- "events": [
- {
- "name": "CarBidEvent",
- "type": "carBidMadeType",
- "source": "carBidEventSource"
- }
- ],
- "states": [
- {
- "name": "StoreCarAuctionBid",
- "type": "event",
- "exclusive": true,
- "onEvents": [
- {
- "eventRefs": ["CarBidEvent"],
- "actions": [{
- "functionRef": {
- "refName": "StoreBidFunction",
- "arguments": {
- "bid": "${ .bid }"
- }
- }
- }]
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/carauctionbids.yml b/diagram/src/test/resources/examples/carauctionbids.yml
deleted file mode 100644
index adfe0d08..00000000
--- a/diagram/src/test/resources/examples/carauctionbids.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-id: handleCarAuctionBid
-version: '1.0'
-specVersion: '0.8'
-name: Car Auction Bidding Workflow
-description: Store a single bid whole the car auction is active
-start:
- stateName: StoreCarAuctionBid
- schedule: 2020-03-20T09:00:00Z/2020-03-20T15:00:00Z
-functions:
- - name: StoreBidFunction
- operation: http://myapis.org/carauctionapi.json#storeBid
-events:
- - name: CarBidEvent
- type: carBidMadeType
- source: carBidEventSource
-states:
- - name: StoreCarAuctionBid
- type: event
- exclusive: true
- onEvents:
- - eventRefs:
- - CarBidEvent
- actions:
- - functionRef:
- refName: StoreBidFunction
- arguments:
- bid: "${ .bid }"
- end: true
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/checkcarvitals.json b/diagram/src/test/resources/examples/checkcarvitals.json
deleted file mode 100644
index 973153fc..00000000
--- a/diagram/src/test/resources/examples/checkcarvitals.json
+++ /dev/null
@@ -1,122 +0,0 @@
-{
- "id": "vitalscheck",
- "name": "Car Vitals Check",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "CheckVitals",
- "states": [
- {
- "name": "CheckVitals",
- "type": "operation",
- "actions": [
- {
- "functionRef": "checkTirePressure"
- },
- {
- "functionRef": "checkOilPressure"
- },
- {
- "functionRef": "checkCoolantLevel"
- },
- {
- "functionRef": "checkBattery"
- }
- ],
- "transition": "EvaluateChecks"
- },
- {
- "name": "EvaluateChecks",
- "type": "switch",
- "dataConditions": [
- {
- "name": "Some Evaluations failed",
- "condition": ".evaluations[?(@.check == 'failed')]",
- "end": {
- "produceEvents": [
- {
- "eventRef": "DisplayFailedChecksOnDashboard",
- "data": "${ .evaluations }"
- }
- ]
-
- }
- }
- ],
- "defaultCondition": {
- "transition": "WaitTwoMinutes"
- }
- },
- {
- "name": "WaitTwoMinutes",
- "type": "event",
- "onEvents": [
- {
- "eventRefs": ["StopVitalsCheck"],
- "eventDataFilter": {
- "toStateData": "${ .stopReceived }"
- }
- }
- ],
- "timeouts": {
- "eventTimeout": "PT2M"
- },
- "transition": "ShouldStopOrContinue"
- },
- {
- "name": "ShouldStopOrContinue",
- "type": "switch",
- "dataConditions": [
- {
- "name": "Stop Event Received",
- "condition": "${ has(\"stopReceived\") }",
- "end": {
- "produceEvents": [
- {
- "eventRef": "VitalsCheckingStopped"
- }
- ]
-
- }
- }
- ],
- "defaultCondition": {
- "transition": "CheckVitals"
- }
- }
- ],
- "events": [
- {
- "name": "StopVitalsCheck",
- "type": "car.events",
- "source": "my/car"
- },
- {
- "name": "VitalsCheckingStopped",
- "type": "car.events",
- "source": "my/car"
- },
- {
- "name": "DisplayFailedChecksOnDashboard",
- "kind": "produced",
- "type": "my.car.events"
- }
- ],
- "functions": [
- {
- "name": "checkTirePressure",
- "operation": "mycarservices.json#checktirepressure"
- },
- {
- "name": "checkOilPressure",
- "operation": "mycarservices.json#checkoilpressure"
- },
- {
- "name": "checkCoolantLevel",
- "operation": "mycarservices.json#checkcoolantlevel"
- },
- {
- "name": "checkBattery",
- "operation": "mycarservices.json#checkbattery"
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/checkcarvitals.yml b/diagram/src/test/resources/examples/checkcarvitals.yml
deleted file mode 100644
index 31bd571a..00000000
--- a/diagram/src/test/resources/examples/checkcarvitals.yml
+++ /dev/null
@@ -1,64 +0,0 @@
-id: vitalscheck
-name: Car Vitals Check
-version: '1.0'
-specVersion: '0.8'
-start: CheckVitals
-states:
- - name: CheckVitals
- type: operation
- actions:
- - functionRef: checkTirePressure
- - functionRef: checkOilPressure
- - functionRef: checkCoolantLevel
- - functionRef: checkBattery
- transition: EvaluateChecks
- - name: EvaluateChecks
- type: switch
- dataConditions:
- - name: Some Evaluations failed
- condition: ".evaluations[?(@.check == 'failed')]"
- end:
- produceEvents:
- - eventRef: DisplayFailedChecksOnDashboard
- data: "${ .evaluations }"
- defaultCondition:
- transition: WaitTwoMinutes
- - name: WaitTwoMinutes
- type: event
- onEvents:
- - eventRefs:
- - StopVitalsCheck
- eventDataFilter:
- toStateData: "${ .stopReceived }"
- timeouts:
- eventTimeout: PT2M
- transition: ShouldStopOrContinue
- - name: ShouldStopOrContinue
- type: switch
- dataConditions:
- - name: Stop Event Received
- condition: ${ has("stopReceived") }
- end:
- produceEvents:
- - eventRef: VitalsCheckingStopped
- defaultCondition:
- transition: CheckVitals
-events:
- - name: StopVitalsCheck
- type: car.events
- source: my/car
- - name: VitalsCheckingStopped
- type: car.events
- source: my/car
- - name: DisplayFailedChecksOnDashboard
- kind: produced
- type: my.car.events
-functions:
- - name: checkTirePressure
- operation: mycarservices.json#checktirepressure
- - name: checkOilPressure
- operation: mycarservices.json#checkoilpressure
- - name: checkCoolantLevel
- operation: mycarservices.json#checkcoolantlevel
- - name: checkBattery
- operation: mycarservices.json#checkbattery
diff --git a/diagram/src/test/resources/examples/creditcheck.json b/diagram/src/test/resources/examples/creditcheck.json
deleted file mode 100644
index 466d2eb7..00000000
--- a/diagram/src/test/resources/examples/creditcheck.json
+++ /dev/null
@@ -1,92 +0,0 @@
-{
- "id": "customercreditcheck",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Customer Credit Check Workflow",
- "description": "Perform Customer Credit Check",
- "start": "CheckCredit",
- "functions": [
- {
- "name": "creditCheckFunction",
- "operation": "http://myapis.org/creditcheckapi.json#doCreditCheck"
- },
- {
- "name": "sendRejectionEmailFunction",
- "operation": "http://myapis.org/creditcheckapi.json#rejectionEmail"
- }
- ],
- "events": [
- {
- "name": "CreditCheckCompletedEvent",
- "type": "creditCheckCompleteType",
- "source": "creditCheckSource",
- "correlation": [
- {
- "contextAttributeName": "customerId"
- }
- ]
- }
- ],
- "states": [
- {
- "name": "CheckCredit",
- "type": "callback",
- "action": {
- "functionRef": {
- "refName": "callCreditCheckMicroservice",
- "arguments": {
- "customer": "${ .customer }"
- }
- }
- },
- "eventRef": "CreditCheckCompletedEvent",
- "timeouts": {
- "stateExecTimeout": "PT15M"
- },
- "transition": "EvaluateDecision"
- },
- {
- "name": "EvaluateDecision",
- "type": "switch",
- "dataConditions": [
- {
- "condition": "${ .creditCheck | .decision == \"Approved\" }",
- "transition": "StartApplication"
- },
- {
- "condition": "${ .creditCheck | .decision == \"Denied\" }",
- "transition": "RejectApplication"
- }
- ],
- "defaultCondition": {
- "transition": "RejectApplication"
- }
- },
- {
- "name": "StartApplication",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "startApplicationWorkflowId"
- }
- ],
- "end": true
- },
- {
- "name": "RejectApplication",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": {
- "refName": "sendRejectionEmailFunction",
- "arguments": {
- "applicant": "${ .customer }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/creditcheck.yml b/diagram/src/test/resources/examples/creditcheck.yml
deleted file mode 100644
index 8831ada7..00000000
--- a/diagram/src/test/resources/examples/creditcheck.yml
+++ /dev/null
@@ -1,52 +0,0 @@
-id: customercreditcheck
-version: '1.0'
-specVersion: '0.8'
-name: Customer Credit Check Workflow
-description: Perform Customer Credit Check
-start: CheckCredit
-functions:
- - name: creditCheckFunction
- operation: http://myapis.org/creditcheckapi.json#doCreditCheck
- - name: sendRejectionEmailFunction
- operation: http://myapis.org/creditcheckapi.json#rejectionEmail
-events:
- - name: CreditCheckCompletedEvent
- type: creditCheckCompleteType
- source: creditCheckSource
- correlation:
- - contextAttributeName: customerId
-states:
- - name: CheckCredit
- type: callback
- action:
- functionRef:
- refName: callCreditCheckMicroservice
- arguments:
- customer: "${ .customer }"
- eventRef: CreditCheckCompletedEvent
- timeouts:
- stateExecTimeout: PT15M
- transition: EvaluateDecision
- - name: EvaluateDecision
- type: switch
- dataConditions:
- - condition: ${ .creditCheck | .decision == "Approved" }
- transition: StartApplication
- - condition: ${ .creditCheck | .decision == "Denied" }
- transition: RejectApplication
- defaultCondition:
- transition: RejectApplication
- - name: StartApplication
- type: operation
- actions:
- - subFlowRef: startApplicationWorkflowId
- end: true
- - name: RejectApplication
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: sendRejectionEmailFunction
- arguments:
- applicant: "${ .customer }"
- end: true
diff --git a/diagram/src/test/resources/examples/eventbasedgreeting.json b/diagram/src/test/resources/examples/eventbasedgreeting.json
deleted file mode 100644
index efdc2c92..00000000
--- a/diagram/src/test/resources/examples/eventbasedgreeting.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- "id": "eventbasedgreeting",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Event Based Greeting Workflow",
- "description": "Event Based Greeting",
- "start": "Greet",
- "events": [
- {
- "name": "GreetingEvent",
- "type": "greetingEventType",
- "source": "greetingEventSource"
- }
- ],
- "functions": [
- {
- "name": "greetingFunction",
- "operation": "file://myapis/greetingapis.json#greeting"
- }
- ],
- "states":[
- {
- "name":"Greet",
- "type":"event",
- "onEvents": [{
- "eventRefs": ["GreetingEvent"],
- "eventDataFilter": {
- "data": "${ .data.greet }"
- },
- "actions":[
- {
- "functionRef": {
- "refName": "greetingFunction",
- "arguments": {
- "name": "${ .greet.name }"
- }
- }
- }
- ]
- }],
- "stateDataFilter": {
- "output": "${ .payload.greeting }"
- },
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/eventbasedgreeting.yml b/diagram/src/test/resources/examples/eventbasedgreeting.yml
deleted file mode 100644
index c18b61fe..00000000
--- a/diagram/src/test/resources/examples/eventbasedgreeting.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-id: eventbasedgreeting
-version: '1.0'
-specVersion: '0.8'
-name: Event Based Greeting Workflow
-description: Event Based Greeting
-start: Greet
-events:
- - name: GreetingEvent
- type: greetingEventType
- source: greetingEventSource
-functions:
- - name: greetingFunction
- operation: file://myapis/greetingapis.json#greeting
-states:
- - name: Greet
- type: event
- onEvents:
- - eventRefs:
- - GreetingEvent
- eventDataFilter:
- data: "${ .data.greet }"
- actions:
- - functionRef:
- refName: greetingFunction
- arguments:
- name: "${ .greet.name }"
- stateDataFilter:
- output: "${ .payload.greeting }"
- end: true
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/eventbasedtransition.json b/diagram/src/test/resources/examples/eventbasedtransition.json
deleted file mode 100644
index da0b8d6e..00000000
--- a/diagram/src/test/resources/examples/eventbasedtransition.json
+++ /dev/null
@@ -1,72 +0,0 @@
-{
- "id": "eventbasedswitch",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Event Based Switch Transitions",
- "description": "Event Based Switch Transitions",
- "start": "CheckVisaStatus",
- "events": [
- {
- "name": "visaApprovedEvent",
- "type": "VisaApproved",
- "source": "visaCheckSource"
- },
- {
- "name": "visaRejectedEvent",
- "type": "VisaRejected",
- "source": "visaCheckSource"
- }
- ],
- "states":[
- {
- "name":"CheckVisaStatus",
- "type":"switch",
- "eventConditions": [
- {
- "eventRef": "visaApprovedEvent",
- "transition": "HandleApprovedVisa"
- },
- {
- "eventRef": "visaRejectedEvent",
- "transition": "HandleRejectedVisa"
- }
- ],
- "timeouts": {
- "eventTimeout": "PT1H"
- },
- "defaultCondition": {
- "transition": "HandleNoVisaDecision"
- }
- },
- {
- "name": "HandleApprovedVisa",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleApprovedVisaWorkflowID"
- }
- ],
- "end": true
- },
- {
- "name": "HandleRejectedVisa",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleRejectedVisaWorkflowID"
- }
- ],
- "end": true
- },
- {
- "name": "HandleNoVisaDecision",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleNoVisaDecisionWorkflowId"
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/eventbasedtransition.yml b/diagram/src/test/resources/examples/eventbasedtransition.yml
deleted file mode 100644
index bb1203a1..00000000
--- a/diagram/src/test/resources/examples/eventbasedtransition.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-id: eventbasedswitch
-version: '1.0'
-specVersion: '0.8'
-name: Event Based Switch Transitions
-description: Event Based Switch Transitions
-start: CheckVisaStatus
-events:
- - name: visaApprovedEvent
- type: VisaApproved
- source: visaCheckSource
- - name: visaRejectedEvent
- type: VisaRejected
- source: visaCheckSource
-states:
- - name: CheckVisaStatus
- type: switch
- eventConditions:
- - eventRef: visaApprovedEvent
- transition: HandleApprovedVisa
- - eventRef: visaRejectedEvent
- transition: HandleRejectedVisa
- timeouts:
- eventTimeout: PT1H
- defaultCondition:
- transition: HandleNoVisaDecision
- - name: HandleApprovedVisa
- type: operation
- actions:
- - subFlowRef: handleApprovedVisaWorkflowID
- end: true
- - name: HandleRejectedVisa
- type: operation
- actions:
- - subFlowRef: handleRejectedVisaWorkflowID
- end: true
- - name: HandleNoVisaDecision
- type: operation
- actions:
- - subFlowRef: handleNoVisaDecisionWorkflowId
- end: true
diff --git a/diagram/src/test/resources/examples/finalizecollegeapplication.json b/diagram/src/test/resources/examples/finalizecollegeapplication.json
deleted file mode 100644
index 8fcb7670..00000000
--- a/diagram/src/test/resources/examples/finalizecollegeapplication.json
+++ /dev/null
@@ -1,74 +0,0 @@
-{
- "id": "finalizeCollegeApplication",
- "name": "Finalize College Application",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "FinalizeApplication",
- "events": [
- {
- "name": "ApplicationSubmitted",
- "type": "org.application.submitted",
- "source": "applicationsource",
- "correlation": [
- {
- "contextAttributeName": "applicantId"
- }
- ]
- },
- {
- "name": "SATScoresReceived",
- "type": "org.application.satscores",
- "source": "applicationsource",
- "correlation": [
- {
- "contextAttributeName": "applicantId"
- }
- ]
- },
- {
- "name": "RecommendationLetterReceived",
- "type": "org.application.recommendationLetter",
- "source": "applicationsource",
- "correlation": [
- {
- "contextAttributeName": "applicantId"
- }
- ]
- }
- ],
- "functions": [
- {
- "name": "finalizeApplicationFunction",
- "operation": "http://myapis.org/collegeapplicationapi.json#finalize"
- }
- ],
- "states": [
- {
- "name": "FinalizeApplication",
- "type": "event",
- "exclusive": false,
- "onEvents": [
- {
- "eventRefs": [
- "ApplicationSubmitted",
- "SATScoresReceived",
- "RecommendationLetterReceived"
- ],
- "actions": [
- {
- "functionRef": {
- "refName": "finalizeApplicationFunction",
- "arguments": {
- "student": "${ .applicantId }"
- }
- }
- }
- ]
- }
- ],
- "end": {
- "terminate": true
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/finalizecollegeapplication.yml b/diagram/src/test/resources/examples/finalizecollegeapplication.yml
deleted file mode 100644
index 0d2fd30c..00000000
--- a/diagram/src/test/resources/examples/finalizecollegeapplication.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-id: finalizeCollegeApplication
-name: Finalize College Application
-version: '1.0'
-specVersion: '0.8'
-start: FinalizeApplication
-events:
- - name: ApplicationSubmitted
- type: org.application.submitted
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: SATScoresReceived
- type: org.application.satscores
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: RecommendationLetterReceived
- type: org.application.recommendationLetter
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
-functions:
- - name: finalizeApplicationFunction
- operation: http://myapis.org/collegeapplicationapi.json#finalize
-states:
- - name: FinalizeApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/foreachstatewithactions.json b/diagram/src/test/resources/examples/foreachstatewithactions.json
deleted file mode 100644
index d312e3ac..00000000
--- a/diagram/src/test/resources/examples/foreachstatewithactions.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "id": "foreachstatewithactions",
- "name": "ForEach State With Actions",
- "description": "ForEach State With Actions",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "SendConfirmationForEachCompletedhOrder",
- "functions": [
- {
- "name": "sendConfirmationFunction",
- "operation": "http://myapis.org/confirmationapi.json#sendConfirmation"
- }
- ],
- "states": [
- {
- "name":"SendConfirmationForEachCompletedhOrder",
- "type":"foreach",
- "inputCollection": "${ .orders[?(@.completed == true)] }",
- "iterationParam": "${ .completedorder }",
- "actions":[
- {
- "functionRef": {
- "refName": "sendConfirmationFunction",
- "arguments": {
- "orderNumber": "${ .completedorder.orderNumber }",
- "email": "${ .completedorder.email }"
- }
- }
- }],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/foreachstatewithactions.yml b/diagram/src/test/resources/examples/foreachstatewithactions.yml
deleted file mode 100644
index e3f5ed29..00000000
--- a/diagram/src/test/resources/examples/foreachstatewithactions.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-id: foreachstatewithactions
-name: ForEach State With Actions
-description: ForEach State With Actions
-version: '1.0'
-specVersion: '0.8'
-start: SendConfirmationForEachCompletedhOrder
-functions:
- - name: sendConfirmationFunction
- operation: http://myapis.org/confirmationapi.json#sendConfirmation
-states:
- - name: SendConfirmationForEachCompletedhOrder
- type: foreach
- inputCollection: "${ .orders[?(@.completed == true)] }"
- iterationParam: "${ .completedorder }"
- actions:
- - functionRef:
- refName: sendConfirmationFunction
- arguments:
- orderNumber: "${ .completedorder.orderNumber }"
- email: "${ .completedorder.email }"
- end: true
diff --git a/diagram/src/test/resources/examples/greeting.json b/diagram/src/test/resources/examples/greeting.json
deleted file mode 100644
index f9138d90..00000000
--- a/diagram/src/test/resources/examples/greeting.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "id": "greeting",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Greeting Workflow",
- "description": "Greet Someone",
- "start": "Greet",
- "functions": [
- {
- "name": "greetingFunction",
- "operation": "file://myapis/greetingapis.json#greeting"
- }
- ],
- "states":[
- {
- "name":"Greet",
- "type":"operation",
- "actions":[
- {
- "functionRef": {
- "refName": "greetingFunction",
- "arguments": {
- "name": "${ .person.name }"
- }
- },
- "actionDataFilter": {
- "results": "${ .greeting }"
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/greeting.yml b/diagram/src/test/resources/examples/greeting.yml
deleted file mode 100644
index ceb14ae0..00000000
--- a/diagram/src/test/resources/examples/greeting.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-id: greeting
-version: '1.0'
-specVersion: '0.8'
-name: Greeting Workflow
-description: Greet Someone
-start: Greet
-functions:
- - name: greetingFunction
- operation: file://myapis/greetingapis.json#greeting
-states:
- - name: Greet
- type: operation
- actions:
- - functionRef:
- refName: greetingFunction
- arguments:
- name: "${ .person.name }"
- actionDataFilter:
- results: "${ .greeting }"
- end: true
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/helloworld.json b/diagram/src/test/resources/examples/helloworld.json
deleted file mode 100644
index c8d48ca8..00000000
--- a/diagram/src/test/resources/examples/helloworld.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "id": "helloworld",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Hello World Workflow",
- "description": "Inject Hello World",
- "start": "Hello State",
- "states":[
- {
- "name":"Hello State",
- "type":"inject",
- "data": {
- "result": "Hello World!"
- },
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/helloworld.yml b/diagram/src/test/resources/examples/helloworld.yml
deleted file mode 100644
index 32a84296..00000000
--- a/diagram/src/test/resources/examples/helloworld.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-id: helloworld
-version: '1.0'
-specVersion: '0.8'
-name: Hello World Workflow
-description: Inject Hello World
-start: Hello State
-states:
- - name: Hello State
- type: inject
- data:
- result: Hello World!
- end: true
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/jobmonitoring.json b/diagram/src/test/resources/examples/jobmonitoring.json
deleted file mode 100644
index 8b0b8e9c..00000000
--- a/diagram/src/test/resources/examples/jobmonitoring.json
+++ /dev/null
@@ -1,143 +0,0 @@
-{
- "id": "jobmonitoring",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Job Monitoring",
- "description": "Monitor finished execution of a submitted job",
- "start": "SubmitJob",
- "functions": [
- {
- "name": "submitJob",
- "operation": "http://myapis.org/monitorapi.json#doSubmit"
- },
- {
- "name": "checkJobStatus",
- "operation": "http://myapis.org/monitorapi.json#checkStatus"
- },
- {
- "name": "reportJobSuceeded",
- "operation": "http://myapis.org/monitorapi.json#reportSucceeded"
- },
- {
- "name": "reportJobFailed",
- "operation": "http://myapis.org/monitorapi.json#reportFailure"
- }
- ],
- "states":[
- {
- "name":"SubmitJob",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "submitJob",
- "arguments": {
- "name": "${ .job.name }"
- }
- },
- "actionDataFilter": {
- "results": "${ .jobuid }"
- }
- }
- ],
- "onErrors": [
- {
- "errorRef": "AllErrors",
- "transition": "SubmitError"
- }
- ],
- "stateDataFilter": {
- "output": "${ .jobuid }"
- },
- "transition": "WaitForCompletion"
- },
- {
- "name": "SubmitError",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleJobSubmissionErrorWorkflow"
- }
- ],
- "end": true
- },
- {
- "name": "WaitForCompletion",
- "type": "sleep",
- "duration": "PT5S",
- "transition": "GetJobStatus"
- },
- {
- "name":"GetJobStatus",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "checkJobStatus",
- "arguments": {
- "name": "${ .jobuid }"
- }
- },
- "actionDataFilter": {
- "results": "${ .jobstatus }"
- }
- }
- ],
- "stateDataFilter": {
- "output": "${ .jobstatus }"
- },
- "transition": "DetermineCompletion"
- },
- {
- "name":"DetermineCompletion",
- "type":"switch",
- "dataConditions": [
- {
- "condition": "${ .jobStatus == \"SUCCEEDED\" }",
- "transition": "JobSucceeded"
- },
- {
- "condition": "${ .jobStatus == \"FAILED\" }",
- "transition": "JobFailed"
- }
- ],
- "defaultCondition": {
- "transition": "WaitForCompletion"
- }
- },
- {
- "name":"JobSucceeded",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "reportJobSuceeded",
- "arguments": {
- "name": "${ .jobuid }"
- }
- }
- }
- ],
- "end": true
- },
- {
- "name":"JobFailed",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "reportJobFailed",
- "arguments": {
- "name": "${ .jobuid }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/jobmonitoring.yml b/diagram/src/test/resources/examples/jobmonitoring.yml
deleted file mode 100644
index eab235d5..00000000
--- a/diagram/src/test/resources/examples/jobmonitoring.yml
+++ /dev/null
@@ -1,81 +0,0 @@
-id: jobmonitoring
-version: '1.0'
-specVersion: '0.8'
-name: Job Monitoring
-description: Monitor finished execution of a submitted job
-start: SubmitJob
-functions:
- - name: submitJob
- operation: http://myapis.org/monitorapi.json#doSubmit
- - name: checkJobStatus
- operation: http://myapis.org/monitorapi.json#checkStatus
- - name: reportJobSuceeded
- operation: http://myapis.org/monitorapi.json#reportSucceeded
- - name: reportJobFailed
- operation: http://myapis.org/monitorapi.json#reportFailure
-states:
- - name: SubmitJob
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: submitJob
- arguments:
- name: "${ .job.name }"
- actionDataFilter:
- results: "${ .jobuid }"
- onErrors:
- - errorRef: "AllErrors"
- transition: SubmitError
- stateDataFilter:
- output: "${ .jobuid }"
- transition: WaitForCompletion
- - name: SubmitError
- type: operation
- actions:
- - subFlowRef: handleJobSubmissionErrorWorkflow
- end: true
- - name: WaitForCompletion
- type: sleep
- duration: PT5S
- transition: GetJobStatus
- - name: GetJobStatus
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: checkJobStatus
- arguments:
- name: "${ .jobuid }"
- actionDataFilter:
- results: "${ .jobstatus }"
- stateDataFilter:
- output: "${ .jobstatus }"
- transition: DetermineCompletion
- - name: DetermineCompletion
- type: switch
- dataConditions:
- - condition: ${ .jobStatus == "SUCCEEDED" }
- transition: JobSucceeded
- - condition: ${ .jobStatus == "FAILED" }
- transition: JobFailed
- defaultCondition:
- transition: WaitForCompletion
- - name: JobSucceeded
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: reportJobSuceeded
- arguments:
- name: "${ .jobuid }"
- end: true
- - name: JobFailed
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: reportJobFailed
- arguments:
- name: "${ .jobuid }"
- end: true
diff --git a/diagram/src/test/resources/examples/monitorpatient.json b/diagram/src/test/resources/examples/monitorpatient.json
deleted file mode 100644
index 594bf18c..00000000
--- a/diagram/src/test/resources/examples/monitorpatient.json
+++ /dev/null
@@ -1,96 +0,0 @@
-{
- "id": "patientVitalsWorkflow",
- "name": "Monitor Patient Vitals",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "MonitorVitals",
- "events": [
- {
- "name": "HighBodyTemperature",
- "type": "org.monitor.highBodyTemp",
- "source": "monitoringSource",
- "correlation": [
- {
- "contextAttributeName": "patientId"
- }
- ]
- },
- {
- "name": "HighBloodPressure",
- "type": "org.monitor.highBloodPressure",
- "source": "monitoringSource",
- "correlation": [
- {
- "contextAttributeName": "patientId"
- }
- ]
- },
- {
- "name": "HighRespirationRate",
- "type": "org.monitor.highRespirationRate",
- "source": "monitoringSource",
- "correlation": [
- {
- "contextAttributeName": "patientId"
- }
- ]
- }
- ],
- "functions": [
- {
- "name": "callPulmonologist",
- "operation": "http://myapis.org/patientapis.json#callPulmonologist"
- },
- {
- "name": "sendTylenolOrder",
- "operation": "http://myapis.org/patientapis.json#tylenolOrder"
- },
- {
- "name": "callNurse",
- "operation": "http://myapis.org/patientapis.json#callNurse"
- }
- ],
- "states": [
- {
- "name": "MonitorVitals",
- "type": "event",
- "exclusive": true,
- "onEvents": [{
- "eventRefs": ["HighBodyTemperature"],
- "actions": [{
- "functionRef": {
- "refName": "sendTylenolOrder",
- "arguments": {
- "patientid": "${ .patientId }"
- }
- }
- }]
- },
- {
- "eventRefs": ["HighBloodPressure"],
- "actions": [{
- "functionRef": {
- "refName": "callNurse",
- "arguments": {
- "patientid": "${ .patientId }"
- }
- }
- }]
- },
- {
- "eventRefs": ["HighRespirationRate"],
- "actions": [{
- "functionRef": {
- "refName": "callPulmonologist",
- "arguments": {
- "patientid": "${ .patientId }"
- }
- }
- }]
- }
- ],
- "end": {
- "terminate": true
- }
- }]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/monitorpatient.yml b/diagram/src/test/resources/examples/monitorpatient.yml
deleted file mode 100644
index c27fbea9..00000000
--- a/diagram/src/test/resources/examples/monitorpatient.yml
+++ /dev/null
@@ -1,56 +0,0 @@
-id: patientVitalsWorkflow
-name: Monitor Patient Vitals
-version: '1.0'
-specVersion: '0.8'
-start: MonitorVitals
-events:
- - name: HighBodyTemperature
- type: org.monitor.highBodyTemp
- source: monitoringSource
- correlation:
- - contextAttributeName: patientId
- - name: HighBloodPressure
- type: org.monitor.highBloodPressure
- source: monitoringSource
- correlation:
- - contextAttributeName: patientId
- - name: HighRespirationRate
- type: org.monitor.highRespirationRate
- source: monitoringSource
- correlation:
- - contextAttributeName: patientId
-functions:
- - name: callPulmonologist
- operation: http://myapis.org/patientapis.json#callPulmonologist
- - name: sendTylenolOrder
- operation: http://myapis.org/patientapis.json#tylenolOrder
- - name: callNurse
- operation: http://myapis.org/patientapis.json#callNurse
-states:
- - name: MonitorVitals
- type: event
- exclusive: true
- onEvents:
- - eventRefs:
- - HighBodyTemperature
- actions:
- - functionRef:
- refName: sendTylenolOrder
- arguments:
- patientid: "${ .patientId }"
- - eventRefs:
- - HighBloodPressure
- actions:
- - functionRef:
- refName: callNurse
- arguments:
- patientid: "${ .patientId }"
- - eventRefs:
- - HighRespirationRate
- actions:
- - functionRef:
- refName: callPulmonologist
- arguments:
- patientid: "${ .patientId }"
- end:
- terminate: true
diff --git a/diagram/src/test/resources/examples/parallel.json b/diagram/src/test/resources/examples/parallel.json
deleted file mode 100644
index 1d614f50..00000000
--- a/diagram/src/test/resources/examples/parallel.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "id": "parallelexec",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Parallel Execution Workflow",
- "description": "Executes two branches in parallel",
- "start": "ParallelExec",
- "states":[
- {
- "name": "ParallelExec",
- "type": "parallel",
- "completionType": "allOf",
- "branches": [
- {
- "name": "ShortDelayBranch"
- },
- {
- "name": "LongDelayBranch"
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/parallel.yml b/diagram/src/test/resources/examples/parallel.yml
deleted file mode 100644
index 5a586cdf..00000000
--- a/diagram/src/test/resources/examples/parallel.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-id: parallelexec
-version: '1.0'
-specVersion: '0.8'
-name: Parallel Execution Workflow
-description: Executes two branches in parallel
-start: ParallelExec
-states:
- - name: ParallelExec
- type: parallel
- completionType: allOf
- branches:
- - name: ShortDelayBranch
- - name: LongDelayBranch
- end: true
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/periodicinboxcheck.json b/diagram/src/test/resources/examples/periodicinboxcheck.json
deleted file mode 100644
index 6c1ecc96..00000000
--- a/diagram/src/test/resources/examples/periodicinboxcheck.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "id": "checkInbox",
- "name": "Check Inbox Workflow",
- "description": "Periodically Check Inbox",
- "start": {
- "stateName": "CheckInbox",
- "schedule": {
- "cron": "0 0/15 * * * ?"
- }
- },
- "version": "1.0",
- "specVersion": "0.8",
- "functions": [
- {
- "name": "checkInboxFunction",
- "operation": "http://myapis.org/inboxapi.json#checkNewMessages"
- },
- {
- "name": "sendTextFunction",
- "operation": "http://myapis.org/inboxapi.json#sendText"
- }
- ],
- "states": [
- {
- "name": "CheckInbox",
- "type": "operation",
- "actionMode": "sequential",
- "actions": [
- {
- "functionRef": "checkInboxFunction"
- }
- ],
- "transition": "SendTextForHighPriority"
- },
- {
- "name": "SendTextForHighPriority",
- "type": "foreach",
- "inputCollection": "${ .messages }",
- "iterationParam": "singlemessage",
- "actions": [
- {
- "functionRef": {
- "refName": "sendTextFunction",
- "arguments": {
- "message": "${ .singlemessage }"
- }
- }
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/periodicinboxcheck.yml b/diagram/src/test/resources/examples/periodicinboxcheck.yml
deleted file mode 100644
index d04932e6..00000000
--- a/diagram/src/test/resources/examples/periodicinboxcheck.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-id: checkInbox
-name: Check Inbox Workflow
-description: Periodically Check Inbox
-start:
- stateName: CheckInbox
- schedule:
- cron: 0 0/15 * * * ?
-version: '1.0'
-specVersion: '0.8'
-functions:
- - name: checkInboxFunction
- operation: http://myapis.org/inboxapi.json#checkNewMessages
- - name: sendTextFunction
- operation: http://myapis.org/inboxapi.json#sendText
-states:
- - name: CheckInbox
- type: operation
- actionMode: sequential
- actions:
- - functionRef: checkInboxFunction
- transition: SendTextForHighPriority
- - name: SendTextForHighPriority
- type: foreach
- inputCollection: "${ .messages }"
- iterationParam: singlemessage
- actions:
- - functionRef:
- refName: sendTextFunction
- arguments:
- message: "${ .singlemessage }"
- end: true
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/provisionorder.json b/diagram/src/test/resources/examples/provisionorder.json
deleted file mode 100644
index 57d3b33a..00000000
--- a/diagram/src/test/resources/examples/provisionorder.json
+++ /dev/null
@@ -1,89 +0,0 @@
-{
- "id": "provisionorders",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Provision Orders",
- "description": "Provision Orders and handle errors thrown",
- "start": "ProvisionOrder",
- "functions": [
- {
- "name": "provisionOrderFunction",
- "operation": "http://myapis.org/provisioningapi.json#doProvision"
- }
- ],
- "states":[
- {
- "name":"ProvisionOrder",
- "type":"operation",
- "actionMode":"sequential",
- "actions":[
- {
- "functionRef": {
- "refName": "provisionOrderFunction",
- "arguments": {
- "order": "${ .order }"
- }
- }
- }
- ],
- "stateDataFilter": {
- "output": "${ .exceptions }"
- },
- "transition": "ApplyOrder",
- "onErrors": [
- {
- "errorRef": "Missing order id",
- "transition": "MissingId"
- },
- {
- "errorRef": "Missing order item",
- "transition": "MissingItem"
- },
- {
- "errorRef": "Missing order quantity",
- "transition": "MissingQuantity"
- }
- ]
- },
- {
- "name": "MissingId",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleMissingIdExceptionWorkflow"
- }
- ],
- "end": true
- },
- {
- "name": "MissingItem",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleMissingItemExceptionWorkflow"
- }
- ],
- "end": true
- },
- {
- "name": "MissingQuantity",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "handleMissingQuantityExceptionWorkflow"
- }
- ],
- "end": true
- },
- {
- "name": "ApplyOrder",
- "type": "operation",
- "actions": [
- {
- "subFlowRef": "applyOrderWorkflowId"
- }
- ],
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/provisionorder.yml b/diagram/src/test/resources/examples/provisionorder.yml
deleted file mode 100644
index 7233e5c3..00000000
--- a/diagram/src/test/resources/examples/provisionorder.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-id: provisionorders
-version: '1.0'
-specVersion: '0.8'
-name: Provision Orders
-description: Provision Orders and handle errors thrown
-start: ProvisionOrder
-functions:
- - name: provisionOrderFunction
- operation: http://myapis.org/provisioningapi.json#doProvision
-states:
- - name: ProvisionOrder
- type: operation
- actionMode: sequential
- actions:
- - functionRef:
- refName: provisionOrderFunction
- arguments:
- order: "${ .order }"
- stateDataFilter:
- output: "${ .exceptions }"
- transition: ApplyOrder
- onErrors:
- - errorRef: Missing order id
- transition: MissingId
- - errorRef: Missing order item
- transition: MissingItem
- - errorRef: Missing order quantity
- transition: MissingQuantity
- - name: MissingId
- type: operation
- actions:
- - subFlowRef: handleMissingIdExceptionWorkflow
- end: true
- - name: MissingItem
- type: operation
- actions:
- - subFlowRef: handleMissingItemExceptionWorkflow
- end: true
- - name: MissingQuantity
- type: operation
- actions:
- - subFlowRef: handleMissingQuantityExceptionWorkflow
- end: true
- - name: ApplyOrder
- type: operation
- actions:
- - subFlowRef: applyOrderWorkflowId
- end: true
diff --git a/diagram/src/test/resources/examples/roomreadings.json b/diagram/src/test/resources/examples/roomreadings.json
deleted file mode 100644
index 14f58b9b..00000000
--- a/diagram/src/test/resources/examples/roomreadings.json
+++ /dev/null
@@ -1,85 +0,0 @@
-{
- "id": "roomreadings",
- "name": "Room Temp and Humidity Workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "ConsumeReading",
- "timeouts": {
- "workflowExecTimeout": {
- "duration": "PT1H",
- "runBefore": "GenerateReport"
- }
- },
- "keepActive": true,
- "states": [
- {
- "name": "ConsumeReading",
- "type": "event",
- "onEvents": [
- {
- "eventRefs": ["TemperatureEvent", "HumidityEvent"],
- "actions": [
- {
- "functionRef": {
- "refName": "LogReading"
- }
- }
- ],
- "eventDataFilter": {
- "data": "${ .readings }"
- }
- }
- ],
- "end": true
- },
- {
- "name": "GenerateReport",
- "type": "operation",
- "actions": [
- {
- "functionRef": {
- "refName": "ProduceReport",
- "arguments": {
- "data": "${ .readings }"
- }
- }
- }
- ],
- "end": {
- "terminate": true
- }
- }
- ],
- "events": [
- {
- "name": "TemperatureEvent",
- "type": "my.home.sensors",
- "source": "/home/rooms/+",
- "correlation": [
- {
- "contextAttributeName": "roomId"
- }
- ]
- },
- {
- "name": "HumidityEvent",
- "type": "my.home.sensors",
- "source": "/home/rooms/+",
- "correlation": [
- {
- "contextAttributeName": "roomId"
- }
- ]
- }
- ],
- "functions": [
- {
- "name": "LogReading",
- "operation": "http.myorg.io/ordersservices.json#logreading"
- },
- {
- "name": "ProduceReport",
- "operation": "http.myorg.io/ordersservices.json#produceReport"
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/roomreadings.yml b/diagram/src/test/resources/examples/roomreadings.yml
deleted file mode 100644
index 948de4a0..00000000
--- a/diagram/src/test/resources/examples/roomreadings.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-id: roomreadings
-name: Room Temp and Humidity Workflow
-version: '1.0'
-specVersion: '0.8'
-start: ConsumeReading
-timeouts:
- workflowExecTimeout:
- duration: PT1H
- runBefore: GenerateReport
-keepActive: true
-states:
- - name: ConsumeReading
- type: event
- onEvents:
- - eventRefs:
- - TemperatureEvent
- - HumidityEvent
- actions:
- - functionRef:
- refName: LogReading
- eventDataFilter:
- data: "${ .readings }"
- end: true
- - name: GenerateReport
- type: operation
- actions:
- - functionRef:
- refName: ProduceReport
- arguments:
- data: "${ .readings }"
- end:
- terminate: true
-events:
- - name: TemperatureEvent
- type: my.home.sensors
- source: "/home/rooms/+"
- correlation:
- - contextAttributeName: roomId
- - name: HumidityEvent
- type: my.home.sensors
- source: "/home/rooms/+"
- correlation:
- - contextAttributeName: roomId
-functions:
- - name: LogReading
- operation: http.myorg.io/ordersservices.json#logreading
- - name: ProduceReport
- operation: http.myorg.io/ordersservices.json#produceReport
diff --git a/diagram/src/test/resources/examples/sendcloudevent.json b/diagram/src/test/resources/examples/sendcloudevent.json
deleted file mode 100644
index 14cd9cad..00000000
--- a/diagram/src/test/resources/examples/sendcloudevent.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "id": "sendcloudeventonprovision",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Send CloudEvent on provision completion",
- "start": "ProvisionOrdersState",
- "events": [
- {
- "name": "provisioningCompleteEvent",
- "type": "provisionCompleteType",
- "kind": "produced"
- }
- ],
- "functions": [
- {
- "name": "provisionOrderFunction",
- "operation": "http://myapis.org/provisioning.json#doProvision"
- }
- ],
- "states": [
- {
- "name": "ProvisionOrdersState",
- "type": "foreach",
- "inputCollection": "${ .orders }",
- "iterationParam": "singleorder",
- "outputCollection": "${ .provisionedOrders }",
- "actions": [
- {
- "functionRef": {
- "refName": "provisionOrderFunction",
- "arguments": {
- "order": "${ .singleorder }"
- }
- }
- }
- ],
- "end": {
- "produceEvents": [{
- "eventRef": "provisioningCompleteEvent",
- "data": "${ .provisionedOrders }"
- }]
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/sendcloudevent.yml b/diagram/src/test/resources/examples/sendcloudevent.yml
deleted file mode 100644
index 037b0648..00000000
--- a/diagram/src/test/resources/examples/sendcloudevent.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-id: sendcloudeventonprovision
-version: '1.0'
-specVersion: '0.8'
-name: Send CloudEvent on provision completion
-start: ProvisionOrdersState
-events:
- - name: provisioningCompleteEvent
- type: provisionCompleteType
- kind: produced
-functions:
- - name: provisionOrderFunction
- operation: http://myapis.org/provisioning.json#doProvision
-states:
- - name: ProvisionOrdersState
- type: foreach
- inputCollection: "${ .orders }"
- iterationParam: singleorder
- outputCollection: "${ .provisionedOrders }"
- actions:
- - functionRef:
- refName: provisionOrderFunction
- arguments:
- order: "${ .singleorder }"
- end:
- produceEvents:
- - eventRef: provisioningCompleteEvent
- data: "${ .provisionedOrders }"
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/singleeventstate.json b/diagram/src/test/resources/examples/singleeventstate.json
deleted file mode 100644
index 7e8607a0..00000000
--- a/diagram/src/test/resources/examples/singleeventstate.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- "id": "testEvents",
- "name": "Test Events Workflow",
- "description": "This is a test events workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "EventState",
- "events": [
- {
- "name": "event1",
- "source": "event1source",
- "type": "event1type"
- },
- {
- "name": "event2",
- "source": "evet2source",
- "type": "event2type"
- },
- {
- "name": "event3",
- "source": "event3source",
- "type": "event3type"
- },
- {
- "name": "event4",
- "source": "event4source",
- "type": "event4type"
- }
- ],
- "states": [
- {
- "name": "EventState",
- "type": "event",
- "end": true,
- "onEvents": [
- {
- "eventRefs": ["event1", "event2"],
- "actions": []
- },
- {
- "eventRefs": ["event3", "event4"],
- "actions": []
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/singleeventstate.yml b/diagram/src/test/resources/examples/singleeventstate.yml
deleted file mode 100644
index 776625fc..00000000
--- a/diagram/src/test/resources/examples/singleeventstate.yml
+++ /dev/null
@@ -1,33 +0,0 @@
----
-id: testEvents
-name: Test Events Workflow
-description: This is a test events workflow
-version: '1.0'
-specVersion: '0.8'
-start: EventState
-events:
- - name: event1
- source: event1source
- type: event1type
- - name: event2
- source: evet2source
- type: event2type
- - name: event3
- source: event3source
- type: event3type
- - name: event4
- source: event4source
- type: event4type
-states:
- - name: EventState
- type: event
- end: true
- onEvents:
- - eventRefs:
- - event1
- - event2
- actions: []
- - eventRefs:
- - event3
- - event4
- actions: []
diff --git a/diagram/src/test/resources/examples/singleswitchstate.json b/diagram/src/test/resources/examples/singleswitchstate.json
deleted file mode 100644
index ee7a7ba4..00000000
--- a/diagram/src/test/resources/examples/singleswitchstate.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "id": "testSwitch",
- "name": "Test Switch State Workflow",
- "description": "This is a test switch state workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "SwitchIt",
- "states": [
- {
- "name": "SwitchIt",
- "type": "switch",
- "dataConditions": [
- {
- "name": "first",
- "condition": "",
- "transition": "FromFirstCondition"
- },
- {
- "name": "second",
- "condition": "",
- "transition": "FromSecondCondition"
- },
- {
- "name": "third",
- "condition": "",
- "end": true
- },
- {
- "name": "fourth",
- "condition": "",
- "end": true
- }
- ]
- },
- {
- "name": "FromFirstCondition",
- "type": "sleep",
- "duration": "PT2M",
- "end": true
- },
- {
- "name": "FromSecondCondition",
- "type": "inject",
- "data": {},
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/singleswitchstate.yml b/diagram/src/test/resources/examples/singleswitchstate.yml
deleted file mode 100644
index eeb32233..00000000
--- a/diagram/src/test/resources/examples/singleswitchstate.yml
+++ /dev/null
@@ -1,31 +0,0 @@
----
-id: testSwitch
-name: Test Switch State Workflow
-description: This is a test switch state workflow
-version: '1.0'
-specVersion: '0.8'
-start: SwitchIt
-states:
- - name: SwitchIt
- type: switch
- dataConditions:
- - name: first
- condition: ''
- transition: FromFirstCondition
- - name: second
- condition: ''
- transition: FromSecondCondition
- - name: third
- condition: ''
- end: true
- - name: fourth
- condition: ''
- end: true
- - name: FromFirstCondition
- type: sleep
- duration: PT2M
- end: true
- - name: FromSecondCondition
- type: inject
- data: {}
- end: true
diff --git a/diagram/src/test/resources/examples/singleswitchstateeventconditions.json b/diagram/src/test/resources/examples/singleswitchstateeventconditions.json
deleted file mode 100644
index e3478696..00000000
--- a/diagram/src/test/resources/examples/singleswitchstateeventconditions.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "id": "testSwitch",
- "name": "Test Switch State Workflow",
- "description": "This is a test switch state workflow",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "SwitchIt",
- "states": [
- {
- "name": "SwitchIt",
- "type": "switch",
- "eventConditions": [
- {
- "name": "first",
- "eventRef": "firstEvent",
- "transition": "FromFirstCondition"
- },
- {
- "name": "second",
- "eventRef": "secondEvent",
- "transition": "FromSecondCondition"
- },
- {
- "name": "third",
- "eventRef": "thirdEvent",
- "end": true
- },
- {
- "name": "fourth",
- "eventRef": "fourthEvent",
- "end": true
- }
- ]
- },
- {
- "name": "FromFirstCondition",
- "type": "sleep",
- "duration": "PT2M",
- "end": true
- },
- {
- "name": "FromSecondCondition",
- "type": "inject",
- "data": {},
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/singleswitchstateeventconditions.yml b/diagram/src/test/resources/examples/singleswitchstateeventconditions.yml
deleted file mode 100644
index 1fe4a29b..00000000
--- a/diagram/src/test/resources/examples/singleswitchstateeventconditions.yml
+++ /dev/null
@@ -1,31 +0,0 @@
----
-id: testSwitch
-name: Test Switch State Workflow
-description: This is a test switch state workflow
-version: '1.0'
-specVersion: '0.8'
-start: SwitchIt
-states:
- - name: SwitchIt
- type: switch
- eventConditions:
- - name: first
- eventRef: firstEvent
- transition: FromFirstCondition
- - name: second
- eventRef: secondEvent
- transition: FromSecondCondition
- - name: third
- eventRef: thirdEvent
- end: true
- - name: fourth
- eventRef: fourthEvent
- end: true
- - name: FromFirstCondition
- type: sleep
- duration: PT2M
- end: true
- - name: FromSecondCondition
- type: inject
- data: {}
- end: true
diff --git a/diagram/src/test/resources/examples/solvemathproblems.json b/diagram/src/test/resources/examples/solvemathproblems.json
deleted file mode 100644
index 29c9de38..00000000
--- a/diagram/src/test/resources/examples/solvemathproblems.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "id": "solvemathproblems",
- "version": "1.0",
- "specVersion": "0.8",
- "name": "Solve Math Problems Workflow",
- "description": "Solve math problems",
- "start": "Solve",
- "functions": [
- {
- "name": "solveMathExpressionFunction",
- "operation": "http://myapis.org/mapthapis.json#solveExpression"
- }
- ],
- "states":[
- {
- "name":"Solve",
- "type":"foreach",
- "inputCollection": "${ .expressions }",
- "iterationParam": "singleexpression",
- "outputCollection": "${ .results }",
- "actions":[
- {
- "functionRef": {
- "refName": "solveMathExpressionFunction",
- "arguments": {
- "expression": "${ .singleexpression }"
- }
- }
- }
- ],
- "stateDataFilter": {
- "output": "${ .results }"
- },
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/solvemathproblems.yml b/diagram/src/test/resources/examples/solvemathproblems.yml
deleted file mode 100644
index 883c3e1b..00000000
--- a/diagram/src/test/resources/examples/solvemathproblems.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-id: solvemathproblems
-version: '1.0'
-specVersion: '0.8'
-name: Solve Math Problems Workflow
-description: Solve math problems
-start: Solve
-functions:
- - name: solveMathExpressionFunction
- operation: http://myapis.org/mapthapis.json#solveExpression
-states:
- - name: Solve
- type: foreach
- inputCollection: "${ .expressions }"
- iterationParam: singleexpression
- outputCollection: "${ .results }"
- actions:
- - functionRef:
- refName: solveMathExpressionFunction
- arguments:
- expression: "${ .singleexpression }"
- stateDataFilter:
- output: "${ .results }"
- end: true
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/vetappointmentservice.json b/diagram/src/test/resources/examples/vetappointmentservice.json
deleted file mode 100644
index 92db914e..00000000
--- a/diagram/src/test/resources/examples/vetappointmentservice.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "id": "VetAppointmentWorkflow",
- "name": "Vet Appointment Workflow",
- "description": "Vet service call via events",
- "version": "1.0",
- "specVersion": "0.8",
- "start": "MakeVetAppointmentState",
- "events": [
- {
- "name": "MakeVetAppointment",
- "source": "VetServiceSoure",
- "kind": "produced"
- },
- {
- "name": "VetAppointmentInfo",
- "source": "VetServiceSource",
- "kind": "consumed"
- }
- ],
- "states": [
- {
- "name": "MakeVetAppointmentState",
- "type": "operation",
- "actions": [
- {
- "name": "MakeAppointmentAction",
- "eventRef": {
- "triggerEventRef": "MakeVetAppointment",
- "data": "${ .patientInfo }",
- "resultEventRef": "VetAppointmentInfo"
- },
- "actionDataFilter": {
- "results": "${ .appointmentInfo }"
- }
- }
- ],
- "timeouts": {
- "actionExecTimeout": "PT15M"
- },
- "end": true
- }
- ]
-}
\ No newline at end of file
diff --git a/diagram/src/test/resources/examples/vetappointmentservice.yml b/diagram/src/test/resources/examples/vetappointmentservice.yml
deleted file mode 100644
index d102f32b..00000000
--- a/diagram/src/test/resources/examples/vetappointmentservice.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-id: VetAppointmentWorkflow
-name: Vet Appointment Workflow
-description: Vet service call via events
-version: '1.0'
-specVersion: '0.8'
-start: MakeVetAppointmentState
-events:
- - name: MakeVetAppointment
- source: VetServiceSoure
- kind: produced
- - name: VetAppointmentInfo
- source: VetServiceSource
- kind: consumed
-states:
- - name: MakeVetAppointmentState
- type: operation
- actions:
- - name: MakeAppointmentAction
- eventRef:
- triggerEventRef: MakeVetAppointment
- data: "${ .patientInfo }"
- resultEventRef: VetAppointmentInfo
- actionDataFilter:
- results: "${ .appointmentInfo }"
- timeouts:
- actionExecTimeout: PT15M
- end: true
diff --git a/diagram/src/test/resources/templates/plantuml/custom-template.txt b/diagram/src/test/resources/templates/plantuml/custom-template.txt
deleted file mode 100644
index e162afc5..00000000
--- a/diagram/src/test/resources/templates/plantuml/custom-template.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-@startuml
-skinparam backgroundColor White
-skinparam legendBackgroundColor White
-skinparam legendBorderColor White
-skinparam state {
- StartColor Green
- EndColor Orange
- BackgroundColor GhostWhite
- BackgroundColor<< workflow >> White
- BorderColor Black
- ArrowColor Black
-
- BorderColor<< event >> #7fe5f0
- BorderColor<< operation >> #bada55
- BorderColor<< switch >> #92a0f2
- BorderColor<< sleep >> #b83b5e
- BorderColor<< parallel >> #6a2c70
- BorderColor<< inject >> #1e5f74
- BorderColor<< foreach >> #931a25
- BorderColor<< callback >> #ffcb8e
-}
-state "[(${diagram.title})]" as workflow << workflow >> {
-
-[# th:each="stateDef : ${diagram.modelStateDefs}" ]
-[(${stateDef.toString()})]
-[/]
-
-[# th:each="state : ${diagram.modelStates}" ]
-[(${state.toString()})]
-[/]
-
-[# th:each="connection : ${diagram.modelConnections}" ]
-[(${connection.toString()})]
-[/]
-
-}
-
-[# th:if="${diagram.showLegend}" ]
-legend center
-State Types and Border Colors:
-| Event | Operation | Switch | Sleep | Parallel | Inject | ForEach | CallBack |
-|<#7fe5f0>|<#bada55>|<#92a0f2>|<#b83b5e>|<#6a2c70>|<#1e5f74>|<#931a25>||
-endlegend
-[/]
-
-@enduml
\ No newline at end of file
diff --git a/img/jobmonitoring.png b/img/jobmonitoring.png
deleted file mode 100644
index cf53109a..00000000
Binary files a/img/jobmonitoring.png and /dev/null differ
diff --git a/img/provisionorders.png b/img/provisionorders.png
deleted file mode 100644
index e8fc69f5..00000000
Binary files a/img/provisionorders.png and /dev/null differ
diff --git a/pom.xml b/pom.xml
index d661d4d3..6635b583 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,10 +38,7 @@
api
- spi
- validation
- diagram
- utils
+ custom-generator
@@ -49,7 +46,7 @@
${java.version}
${java.version}
UTF-8
- 3.6.2
+ 3.9.7
3.2.0
@@ -62,7 +59,7 @@
3.2.4
3.4.1
${java.version}
- 1.1.2
+ 1.2.1
3.7.0
3.0.1
3.3.1
@@ -73,18 +70,13 @@
1.5.6
2.17.1
1.4.0
- 3.14.0
- 0.17.0
- 1.3
3.1.0
1.5.0
3.26.0
5.10.2
5.12.0
2.0.13
- 8059
- 3.1.2.RELEASE
-
+
true
@@ -117,11 +109,6 @@
slf4j-api
${version.org.slf4j}
-
- org.slf4j
- jcl-over-slf4j
- ${version.org.slf4j}
-
com.fasterxml.jackson.core
jackson-core
@@ -136,44 +123,23 @@
com.networknt
json-schema-validator
${version.com.networknt}
-
-
- org.apache.commons
- commons-lang3
-
-
com.fasterxml.jackson.dataformat
jackson-dataformat-yaml
${version.com.fasterxml.jackson}
+
+ org.jsonschema2pojo
+ jsonschema2pojo-core
+ ${version.jsonschema2pojo-maven-plugin}
+
jakarta.validation
jakarta.validation-api
${version.jakarta.validation}
-
- org.apache.commons
- commons-lang3
- ${version.commons.lang}
-
-
- org.thymeleaf
- thymeleaf
- ${version.thymeleaf}
-
-
- net.sourceforge.plantuml
- plantuml
- ${version.plantuml}
-
-
- guru.nidi
- graphviz-java
- ${version.graphviz}
-
-
+
org.junit.jupiter
@@ -211,18 +177,6 @@
${version.org.assertj}
test
-
- org.hamcrest
- hamcrest-library
- ${version.hamcrest}
- test
-
-
- org.skyscreamer
- jsonassert
- ${version.jsonassert}
- test
-
diff --git a/spi/.gitignore b/spi/.gitignore
deleted file mode 100644
index d4dfde66..00000000
--- a/spi/.gitignore
+++ /dev/null
@@ -1,31 +0,0 @@
-HELP.md
-target/
-!.mvn/wrapper/maven-wrapper.jar
-!**/src/main/**
-!**/src/test/**
-
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-build/
-
-### VS Code ###
-.vscode/
\ No newline at end of file
diff --git a/spi/pom.xml b/spi/pom.xml
deleted file mode 100644
index b04be92b..00000000
--- a/spi/pom.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
- 4.0.0
-
-
- io.serverlessworkflow
- serverlessworkflow-parent
- 7.0.0-SNAPSHOT
-
-
- serverlessworkflow-spi
- Serverless Workflow :: SPI
- jar
- Java SDK for Serverless Workflow Specification
-
-
-
- org.slf4j
- slf4j-api
-
-
-
- io.serverlessworkflow
- serverlessworkflow-api
- ${project.version}
-
-
-
-
- org.junit.jupiter
- junit-jupiter-api
- test
-
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.junit.jupiter
- junit-jupiter-params
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- ch.qos.logback
- logback-classic
- test
-
-
- org.assertj
- assertj-core
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${project.build.directory}/checkstyle.log
- true
- true
- true
- false
- false
- ${checkstyle.logViolationsToConsole}
- ${checkstyle.failOnViolation}
-
- ${project.build.sourceDirectory}
- ${project.build.testSourceDirectory}
-
-
-
-
- compile
-
- check
-
-
-
-
-
- com.spotify.fmt
- fmt-maven-plugin
-
- src/main/java
- src/test/java
- false
- .*\.java
- false
- false
-
-
-
-
-
- format
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/spi/src/main/java/io/serverlessworkflow/spi/WorkflowDiagramProvider.java b/spi/src/main/java/io/serverlessworkflow/spi/WorkflowDiagramProvider.java
deleted file mode 100644
index ad0e8180..00000000
--- a/spi/src/main/java/io/serverlessworkflow/spi/WorkflowDiagramProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.spi;
-
-import io.serverlessworkflow.api.interfaces.WorkflowDiagram;
-import java.util.Iterator;
-import java.util.ServiceLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class WorkflowDiagramProvider {
- private WorkflowDiagram workflowDiagram;
-
- private static Logger logger = LoggerFactory.getLogger(WorkflowDiagramProvider.class);
-
- public WorkflowDiagramProvider() {
- ServiceLoader foundWorkflowDiagrams =
- ServiceLoader.load(WorkflowDiagram.class);
- Iterator it = foundWorkflowDiagrams.iterator();
- if (it.hasNext()) {
- workflowDiagram = it.next();
- logger.info("Found workflow diagram: " + workflowDiagram.toString());
- }
- }
-
- private static class LazyHolder {
-
- static final WorkflowDiagramProvider INSTANCE = new WorkflowDiagramProvider();
- }
-
- public static WorkflowDiagramProvider getInstance() {
- return WorkflowDiagramProvider.LazyHolder.INSTANCE;
- }
-
- public WorkflowDiagram get() {
- return workflowDiagram;
- }
-}
diff --git a/spi/src/main/java/io/serverlessworkflow/spi/WorkflowPropertySourceProvider.java b/spi/src/main/java/io/serverlessworkflow/spi/WorkflowPropertySourceProvider.java
deleted file mode 100644
index ef3bcf40..00000000
--- a/spi/src/main/java/io/serverlessworkflow/spi/WorkflowPropertySourceProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.spi;
-
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.util.Iterator;
-import java.util.ServiceLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class WorkflowPropertySourceProvider {
- private WorkflowPropertySource workflowPropertySource;
-
- private static Logger logger = LoggerFactory.getLogger(WorkflowValidatorProvider.class);
-
- public WorkflowPropertySourceProvider() {
- ServiceLoader foundPropertyContext =
- ServiceLoader.load(WorkflowPropertySource.class);
- Iterator it = foundPropertyContext.iterator();
- if (it.hasNext()) {
- workflowPropertySource = it.next();
- logger.info("Found property source: " + workflowPropertySource.toString());
- }
- }
-
- private static class LazyHolder {
-
- static final WorkflowPropertySourceProvider INSTANCE = new WorkflowPropertySourceProvider();
- }
-
- public static WorkflowPropertySourceProvider getInstance() {
- return WorkflowPropertySourceProvider.LazyHolder.INSTANCE;
- }
-
- public WorkflowPropertySource get() {
- return workflowPropertySource;
- }
-}
diff --git a/spi/src/main/java/io/serverlessworkflow/spi/WorkflowValidatorProvider.java b/spi/src/main/java/io/serverlessworkflow/spi/WorkflowValidatorProvider.java
deleted file mode 100644
index 815f5fb6..00000000
--- a/spi/src/main/java/io/serverlessworkflow/spi/WorkflowValidatorProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.spi;
-
-import io.serverlessworkflow.api.interfaces.WorkflowValidator;
-import java.util.Iterator;
-import java.util.ServiceLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class WorkflowValidatorProvider {
- private WorkflowValidator workflowValidator;
-
- private static Logger logger = LoggerFactory.getLogger(WorkflowValidatorProvider.class);
-
- public WorkflowValidatorProvider() {
- ServiceLoader foundWorkflowValidators =
- ServiceLoader.load(WorkflowValidator.class);
- Iterator it = foundWorkflowValidators.iterator();
- if (it.hasNext()) {
- workflowValidator = it.next();
- logger.info("Found workflow validator: " + workflowValidator.toString());
- }
- }
-
- private static class LazyHolder {
-
- static final WorkflowValidatorProvider INSTANCE = new WorkflowValidatorProvider();
- }
-
- public static WorkflowValidatorProvider getInstance() {
- return LazyHolder.INSTANCE;
- }
-
- public WorkflowValidator get() {
- return workflowValidator;
- }
-}
diff --git a/spi/src/test/java/io/serverlessworkflow/spi/test/ServiceProvidersTest.java b/spi/src/test/java/io/serverlessworkflow/spi/test/ServiceProvidersTest.java
deleted file mode 100644
index b6ec9c73..00000000
--- a/spi/src/test/java/io/serverlessworkflow/spi/test/ServiceProvidersTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.spi.test;
-
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import io.serverlessworkflow.api.interfaces.WorkflowValidator;
-import io.serverlessworkflow.spi.WorkflowPropertySourceProvider;
-import io.serverlessworkflow.spi.WorkflowValidatorProvider;
-import io.serverlessworkflow.spi.test.providers.TestWorkflowPropertySource;
-import io.serverlessworkflow.spi.test.providers.TestWorkflowValidator;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class ServiceProvidersTest {
-
- @Test
- public void testWorkflowValidatorProvider() {
- WorkflowValidator validator = WorkflowValidatorProvider.getInstance().get();
- Assertions.assertNotNull(validator);
- Assertions.assertTrue(validator instanceof TestWorkflowValidator);
- }
-
- @Test
- public void testWorkflowPropertySourceProvider() {
- WorkflowPropertySource propertySource = WorkflowPropertySourceProvider.getInstance().get();
- Assertions.assertNotNull(propertySource);
- Assertions.assertTrue(propertySource instanceof TestWorkflowPropertySource);
- }
-}
diff --git a/spi/src/test/java/io/serverlessworkflow/spi/test/providers/TestWorkflowPropertySource.java b/spi/src/test/java/io/serverlessworkflow/spi/test/providers/TestWorkflowPropertySource.java
deleted file mode 100644
index a17bbdde..00000000
--- a/spi/src/test/java/io/serverlessworkflow/spi/test/providers/TestWorkflowPropertySource.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.spi.test.providers;
-
-import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-public class TestWorkflowPropertySource implements WorkflowPropertySource {
-
- private Properties source = new Properties();
-
- @Override
- public Properties getPropertySource() {
- Map propertySourcetMap = new HashMap<>();
- propertySourcetMap.put("wfname", "test-wf");
- propertySourcetMap.put("delaystate.name", "delay-state");
- propertySourcetMap.put("delaystate.timedelay", "PT5S");
- propertySourcetMap.put("delaystate.type", "DELAY");
-
- source.putAll(propertySourcetMap);
-
- return source;
- }
-
- @Override
- public void setPropertySource(Properties source) {
- this.source = source;
- }
-}
diff --git a/spi/src/test/java/io/serverlessworkflow/spi/test/providers/TestWorkflowValidator.java b/spi/src/test/java/io/serverlessworkflow/spi/test/providers/TestWorkflowValidator.java
deleted file mode 100644
index 14d38137..00000000
--- a/spi/src/test/java/io/serverlessworkflow/spi/test/providers/TestWorkflowValidator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.spi.test.providers;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.interfaces.WorkflowValidator;
-import io.serverlessworkflow.api.validation.ValidationError;
-import java.util.List;
-
-public class TestWorkflowValidator implements WorkflowValidator {
-
- @Override
- public WorkflowValidator setWorkflow(Workflow workflow) {
- return this;
- }
-
- @Override
- public WorkflowValidator setSource(String source) {
- return this;
- }
-
- @Override
- public List validate() {
- return null;
- }
-
- @Override
- public boolean isValid() {
- return false;
- }
-
- @Override
- public WorkflowValidator setSchemaValidationEnabled(boolean schemaValidationEnabled) {
- return this;
- }
-
- @Override
- public WorkflowValidator reset() {
- return this;
- }
-}
diff --git a/spi/src/test/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowPropertySource b/spi/src/test/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowPropertySource
deleted file mode 100644
index ce3c644b..00000000
--- a/spi/src/test/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowPropertySource
+++ /dev/null
@@ -1 +0,0 @@
-io.serverlessworkflow.spi.test.providers.TestWorkflowPropertySource
\ No newline at end of file
diff --git a/spi/src/test/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowValidator b/spi/src/test/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowValidator
deleted file mode 100644
index d25b29d9..00000000
--- a/spi/src/test/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowValidator
+++ /dev/null
@@ -1 +0,0 @@
-io.serverlessworkflow.spi.test.providers.TestWorkflowValidator
\ No newline at end of file
diff --git a/utils/pom.xml b/utils/pom.xml
deleted file mode 100644
index 62d90e8d..00000000
--- a/utils/pom.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
- 4.0.0
-
-
- io.serverlessworkflow
- serverlessworkflow-parent
- 7.0.0-SNAPSHOT
-
-
- serverlessworkflow-util
- Serverless Workflow :: Utils
- jar
- Java SDK for Serverless Workflow Specification
-
-
-
- org.slf4j
- slf4j-api
-
-
-
- io.serverlessworkflow
- serverlessworkflow-api
- ${project.version}
-
-
-
-
- org.junit.jupiter
- junit-jupiter-api
- test
-
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.junit.jupiter
- junit-jupiter-params
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- ch.qos.logback
- logback-classic
- test
-
-
- org.assertj
- assertj-core
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${project.build.directory}/checkstyle.log
- true
- true
- true
- false
- false
- ${checkstyle.logViolationsToConsole}
- ${checkstyle.failOnViolation}
-
- ${project.build.sourceDirectory}
- ${project.build.testSourceDirectory}
-
-
-
-
- compile
-
- check
-
-
-
-
-
- com.spotify.fmt
- fmt-maven-plugin
-
- src/main/java
- src/test/java
- false
- .*\.java
- false
- false
-
-
-
-
-
- format
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/utils/src/main/java/io/serverlessworkflow/utils/WorkflowUtils.java b/utils/src/main/java/io/serverlessworkflow/utils/WorkflowUtils.java
deleted file mode 100644
index 671d3c50..00000000
--- a/utils/src/main/java/io/serverlessworkflow/utils/WorkflowUtils.java
+++ /dev/null
@@ -1,665 +0,0 @@
-/*
- * 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.utils;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.actions.Action;
-import io.serverlessworkflow.api.branches.Branch;
-import io.serverlessworkflow.api.defaultdef.DefaultConditionDefinition;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.api.events.OnEvents;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.api.functions.FunctionRef;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.api.start.Start;
-import io.serverlessworkflow.api.states.*;
-import io.serverlessworkflow.api.switchconditions.DataCondition;
-import io.serverlessworkflow.api.switchconditions.EventCondition;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/** Provides common utility methods to provide most often needed answers from a workflow */
-@SuppressWarnings("StreamToLoop")
-public final class WorkflowUtils {
- private static final int DEFAULT_STARTING_STATE_POSITION = 0;
- private static final long DEFAULT_STATE_COUNT = 0;
-
- /**
- * Gets State matching Start state. If start is not present returns first state. If start is
- * present, returns the matching start State. If matching state is not present, returns null
- *
- * @param workflow workflow
- * @return {@code state} when present else returns {@code null}
- */
- public static State getStartingState(Workflow workflow) {
- if (!hasStates(workflow)) {
- return null;
- }
-
- Start start = workflow.getStart();
- if (start == null) {
- return workflow.getStates().get(DEFAULT_STARTING_STATE_POSITION);
- } else {
- Optional startingState =
- workflow.getStates().stream()
- .filter(state -> state.getName().equals(start.getStateName()))
- .findFirst();
- return startingState.orElse(null);
- }
- }
-
- /**
- * Gets List of States matching stateType
- *
- * @param workflow
- * @param stateType
- * @return {@code List}. Returns {@code null} when workflow is null.
- */
- public static List getStates(Workflow workflow, DefaultState.Type stateType) {
- if (!hasStates(workflow)) {
- return null;
- }
-
- return workflow.getStates().stream()
- .filter(state -> state.getType() == stateType)
- .collect(Collectors.toList());
- }
-
- /**
- * @return {@code List}. Returns {@code NULL}
- * when workflow is null or when workflow does not contain events
- */
- public static List getDefinedConsumedEvents(Workflow workflow) {
- return getDefinedEvents(workflow, EventDefinition.Kind.CONSUMED);
- }
-
- /**
- * @return {@code List}. Returns {@code NULL}
- * when workflow is null or when workflow does not contain events
- */
- public static List getDefinedProducedEvents(Workflow workflow) {
- return getDefinedEvents(workflow, EventDefinition.Kind.PRODUCED);
- }
-
- /**
- * Gets list of event definition matching eventKind
- *
- * @param workflow
- * @return {@code List}. Returns {@code NULL}
- * when workflow is null or when workflow does not contain events
- */
- public static List getDefinedEvents(
- Workflow workflow, EventDefinition.Kind eventKind) {
- if (!hasEventDefs(workflow)) {
- return null;
- }
-
- List eventDefs = workflow.getEvents().getEventDefs();
- return eventDefs.stream()
- .filter(eventDef -> eventDef.getKind() == eventKind)
- .collect(Collectors.toList());
- }
-
- /**
- * @return {@code int} Returns count of defined event count matching eventKind
- */
- public static int getDefinedEventsCount(Workflow workflow, EventDefinition.Kind eventKind) {
- List definedEvents = getDefinedEvents(workflow, eventKind);
- return definedEvents == null ? 0 : definedEvents.size();
- }
-
- /**
- * @return {@code int} Returns count of Defined Consumed Event Count
- */
- public static int getDefinedConsumedEventsCount(Workflow workflow) {
- return getDefinedEventsCount(workflow, EventDefinition.Kind.CONSUMED);
- }
-
- /**
- * @return {@code int} Returns count of Defined Produced Event Count
- */
- public static int getDefinedProducedEventsCount(Workflow workflow) {
- return getDefinedEventsCount(workflow, EventDefinition.Kind.PRODUCED);
- }
-
- /**
- * Gets Consumed Events of parent workflow Iterates through states in parent workflow and collects
- * all the ConsumedEvents. Sub Workflows of the Workflow are not considered for
- * getting Consumed Events
- *
- * @return Returns {@code List}
- */
- public static List getWorkflowConsumedEvents(Workflow workflow) {
- return getWorkflowEventDefinitions(workflow, EventDefinition.Kind.CONSUMED);
- }
-
- /**
- * Gets Produced Events of parent workflow Iterates through states in parent workflow and collects
- * all the ConsumedEvents. Sub Workflows of the Workflow are not considered for
- * getting Consumed Events
- *
- * @return Returns {@code List}
- */
- public static List getWorkflowProducedEvents(Workflow workflow) {
- return getWorkflowEventDefinitions(workflow, EventDefinition.Kind.PRODUCED);
- }
-
- /**
- * Gets Events of parent workflow matching {@code EventDefinition.Kind} Iterates through states in
- * parent workflow and collects all the events matching {@code EventDefinition.Kind} .
- *
- * @return Returns {@code List}
- */
- public static List getWorkflowEventDefinitions(
- Workflow workflow, EventDefinition.Kind eventKind) {
- if (!hasStates(workflow)) {
- return null;
- }
-
- List uniqueWorkflowEventsFromStates = getUniqueWorkflowEventsFromStates(workflow);
- List definedConsumedEvents = getDefinedEvents(workflow, eventKind);
- if (definedConsumedEvents == null) {
- return null;
- }
- return definedConsumedEvents.stream()
- .filter(definedEvent -> uniqueWorkflowEventsFromStates.contains(definedEvent.getName()))
- .collect(Collectors.toList());
- }
-
- /** Returns a list of unique event names from workflow states */
- public static List getUniqueWorkflowEventsFromStates(Workflow workflow) {
- List eventReferences = new ArrayList<>();
-
- for (State state : workflow.getStates()) {
- if (state instanceof SwitchState) {
- SwitchState switchState = (SwitchState) state;
- if (switchState.getEventConditions() != null) {
- switchState
- .getEventConditions()
- .forEach(eventCondition -> eventReferences.add(eventCondition.getEventRef()));
- }
- } else if (state instanceof CallbackState) {
- CallbackState callbackState = (CallbackState) state;
- if (callbackState.getEventRef() != null) eventReferences.add(callbackState.getEventRef());
- if (callbackState.getAction() != null && callbackState.getAction().getEventRef() != null) {
- eventReferences.addAll(getActionEvents(callbackState.getAction()));
- }
- } else if (state instanceof EventState) {
- EventState eventState = (EventState) state;
- if (eventState.getOnEvents() != null) {
- eventState
- .getOnEvents()
- .forEach(
- onEvents -> {
- eventReferences.addAll(onEvents.getEventRefs());
- if (onEvents.getActions() != null) {
- for (Action action : onEvents.getActions()) {
- eventReferences.addAll(getActionEvents(action));
- }
- }
- });
- }
- } else if (state instanceof OperationState) {
- OperationState operationState = (OperationState) state;
- if (operationState.getActions() != null) {
- for (Action action : operationState.getActions()) {
- eventReferences.addAll(getActionEvents(action));
- }
- }
- } else if (state instanceof ParallelState) {
- ParallelState parallelState = (ParallelState) state;
- if (parallelState.getBranches() != null) {
- for (Branch branch : parallelState.getBranches()) {
- if (branch.getActions() != null) {
- for (Action action : branch.getActions()) {
- eventReferences.addAll(getActionEvents(action));
- }
- }
- }
- }
- }
- }
-
- return eventReferences.stream().distinct().collect(Collectors.toList());
- }
-
- /**
- * @return Returns {@code int } Count of the workflow consumed events. Does not
- * consider sub-workflows
- */
- public static int getWorkflowConsumedEventsCount(Workflow workflow) {
- List workflowConsumedEvents = getWorkflowConsumedEvents(workflow);
- return workflowConsumedEvents == null ? 0 : workflowConsumedEvents.size();
- }
-
- /**
- * @return Returns {@code int} Count of the workflow produced events. Does not
- * consider sub-workflows in the count
- */
- public static int getWorkflowProducedEventsCount(Workflow workflow) {
- List workflowProducedEvents = getWorkflowProducedEvents(workflow);
- return workflowProducedEvents == null ? 0 : workflowProducedEvents.size();
- }
-
- /**
- * @return Returns function definition for actions
- */
- public static FunctionDefinition getFunctionDefinitionsForAction(
- Workflow workflow, String action) {
- if (!hasFunctionDefs(workflow)) return null;
- FunctionRef functionRef = getFunctionRefFromAction(workflow, action);
- if (functionRef == null) return null;
- final Optional functionDefinition =
- workflow.getFunctions().getFunctionDefs().stream()
- .filter(functionDef -> functionDef.getName().equals(functionRef.getRefName()))
- .distinct()
- .findFirst();
-
- return functionDefinition.isPresent() ? functionDefinition.get() : null;
- }
-
- /**
- * @return : Returns @{code List} which uses a function defintion
- */
- public static List getActionsForFunctionDefinition(
- Workflow workflow, String functionDefinitionName) {
- if (!hasFunctionDefs(workflow, functionDefinitionName)) return null;
- return getActionsWhichUsesFunctionDefinition(workflow, functionDefinitionName);
- }
-
- /**
- * Gets Num of State in the workflow does not consider child workflow
- *
- * @param workflow
- * @return
- */
- public static long getNumOfStates(Workflow workflow) {
- return hasStates(workflow) ? workflow.getStates().size() : DEFAULT_STATE_COUNT;
- }
-
- /**
- * Gets Num of States for State Type
- *
- * @param workflow
- * @param type
- * @return
- */
- public static long getNumOfStates(Workflow workflow, DefaultState.Type type) {
- return hasStates(workflow)
- ? workflow.getStates().stream().filter(state -> state.getType() == type).count()
- : DEFAULT_STATE_COUNT;
- }
-
- /**
- * Returns workflow state from provided name, or null if not found.
- *
- * @param workflow
- * @param name
- * @return
- */
- public static State getStateWithName(Workflow workflow, String name) {
- if (!hasStates(workflow)) {
- return null;
- }
-
- Optional state =
- workflow.getStates().stream().filter(s -> s.getName().equals(name)).findFirst();
-
- if (state.isPresent()) {
- return state.get();
- } else {
- return null;
- }
- }
-
- public static long getNumOfEndStates(Workflow workflow) {
- if (hasStates(workflow)) {
- long count = workflow.getStates().stream().filter(state -> state.getEnd() != null).count();
- List switchStates =
- workflow.getStates().stream()
- .filter(state -> state instanceof SwitchState)
- .collect(Collectors.toList());
- for (State state : switchStates) {
- SwitchState switchState = (SwitchState) state;
- List eventConditions = switchState.getEventConditions();
- if (eventConditions != null) {
- count =
- count
- + eventConditions.stream()
- .filter(eventCondition -> eventCondition.getEnd() != null)
- .count();
- }
- List dataConditions = switchState.getDataConditions();
- if (dataConditions != null) {
- count =
- count
- + dataConditions.stream()
- .filter(dataCondition -> dataCondition.getEnd() != null)
- .count();
- }
- DefaultConditionDefinition defaultCondition = switchState.getDefaultCondition();
- if (defaultCondition != null) {
- count = (defaultCondition.getEnd() != null) ? count + 1 : count;
- }
- }
- return count;
- } else {
- return DEFAULT_STATE_COUNT;
- }
- }
-
- public static List getActionsWhichUsesFunctionDefinition(
- Workflow workflow, String functionDefinitionName) {
- List actions = new ArrayList<>();
- for (State state : workflow.getStates()) {
- if (state instanceof EventState) {
- EventState eventState = (EventState) state;
- List onEvents = eventState.getOnEvents();
- if (onEvents != null) {
- for (OnEvents onEvent : onEvents) {
- if (onEvent != null) {
- List onEventActions = onEvent.getActions();
- if (onEventActions != null) {
- for (Action onEventAction : onEventActions) {
- if (checkIfActionUsesFunctionDefinition(functionDefinitionName, onEventAction))
- actions.add(onEventAction);
- }
- }
- }
- }
- }
- } else if (state instanceof CallbackState) {
- CallbackState callbackState = (CallbackState) state;
- final Action callbackStateAction = callbackState.getAction();
- if (checkIfActionUsesFunctionDefinition(functionDefinitionName, callbackStateAction)) {
- actions.add(callbackStateAction);
- }
-
- } else if (state instanceof OperationState) {
- OperationState operationState = (OperationState) state;
- final List operationStateActions = operationState.getActions();
- if (operationStateActions != null) {
- for (Action operationStateAction : operationStateActions) {
- if (checkIfActionUsesFunctionDefinition(functionDefinitionName, operationStateAction)) {
- actions.add(operationStateAction);
- }
- }
- }
- } else if (state instanceof ParallelState) {
- ParallelState parallelState = (ParallelState) state;
- List parallelStateBranches = parallelState.getBranches();
- if (parallelStateBranches != null) {
- for (Branch branch : parallelStateBranches) {
- List branchActions = branch.getActions();
- if (branchActions != null) {
- for (Action branchAction : branchActions) {
- if (checkIfActionUsesFunctionDefinition(functionDefinitionName, branchAction)) {
- actions.add(branchAction);
- }
- }
- }
- }
- }
- } else if (state instanceof ForEachState) {
- ForEachState forEachState = (ForEachState) state;
- List forEachStateActions = forEachState.getActions();
- if (forEachStateActions != null) {
- for (Action forEachStateAction : forEachStateActions) {
- if (checkIfActionUsesFunctionDefinition(functionDefinitionName, forEachStateAction)) {
- actions.add(forEachStateAction);
- }
- }
- }
- }
- }
-
- return actions;
- }
-
- public static boolean checkIfActionUsesFunctionDefinition(
- String functionDefinitionName, Action action) {
- return action != null
- && action.getFunctionRef() != null
- && action.getFunctionRef().getRefName() != null
- && action.getFunctionRef().getRefName().equals(functionDefinitionName);
- }
-
- public static boolean hasFunctionDefs(Workflow workflow, String functionDefinitionName) {
- if (!hasFunctionDefs(workflow)) return false;
- List functionDefs = workflow.getFunctions().getFunctionDefs();
- return functionDefs.stream()
- .anyMatch(
- functionDefinition -> functionDefinition.getName().equals(functionDefinitionName));
- }
-
- public static FunctionRef getFunctionRefFromAction(Workflow workflow, String action) {
- if (!hasStates(workflow)) return null;
-
- for (State state : workflow.getStates()) {
- if (state instanceof EventState) {
- EventState eventState = (EventState) state;
- List onEvents = eventState.getOnEvents();
- if (onEvents != null) {
- for (OnEvents onEvent : onEvents) {
- if (onEvent != null) {
- List onEventActions = onEvent.getActions();
- if (onEventActions != null) {
- for (Action onEventAction : onEventActions) {
- if (onEventAction != null
- && onEventAction.getName() != null
- && onEventAction.getName().equals(action))
- return onEventAction.getFunctionRef();
- }
- }
- }
- }
- }
- } else if (state instanceof CallbackState) {
- CallbackState callbackState = (CallbackState) state;
- final Action callbackStateAction = callbackState.getAction();
- if (callbackStateAction != null
- && callbackStateAction.getName() != null
- && callbackStateAction.getName().equals(action)) {
- return callbackStateAction.getFunctionRef();
- }
-
- } else if (state instanceof OperationState) {
- OperationState operationState = (OperationState) state;
- final List operationStateActions = operationState.getActions();
- if (operationStateActions != null) {
- for (Action operationStateAction : operationStateActions) {
- if (operationStateAction != null
- && operationStateAction.getName() != null
- && operationStateAction.getName().equals(action)) {
- return operationStateAction.getFunctionRef();
- }
- }
- }
- } else if (state instanceof ParallelState) {
- ParallelState parallelState = (ParallelState) state;
- List parallelStateBranches = parallelState.getBranches();
- if (parallelStateBranches != null) {
- for (Branch branch : parallelStateBranches) {
- List branchActions = branch.getActions();
- if (branchActions != null) {
- for (Action branchAction : branchActions) {
- if (branchAction != null
- && branchAction.getName() != null
- && branchAction.getName().equals(action)) {
- return branchAction.getFunctionRef();
- }
- }
- }
- }
- }
- } else if (state instanceof ForEachState) {
- ForEachState forEachState = (ForEachState) state;
- List forEachStateActions = forEachState.getActions();
- if (forEachStateActions != null) {
- for (Action forEachStateAction : forEachStateActions) {
- if (forEachStateAction != null
- && forEachStateAction.getName() != null
- && forEachStateAction.getName().equals(action)) {
- return forEachStateAction.getFunctionRef();
- }
- }
- }
- }
- }
-
- return null;
- }
-
- public static boolean hasFunctionDefs(Workflow workflow) {
- return workflow != null
- && workflow.getFunctions() != null
- && workflow.getFunctions().getFunctionDefs() != null
- && !workflow.getFunctions().getFunctionDefs().isEmpty();
- }
-
- /** Returns true if workflow has states, otherwise false */
- public static boolean hasStates(Workflow workflow) {
- return workflow != null && workflow.getStates() != null && !workflow.getStates().isEmpty();
- }
-
- /** Returns true if workflow has events definitions, otherwise false */
- public static boolean hasEventDefs(Workflow workflow) {
- return workflow != null
- && workflow.getEvents() != null
- && workflow.getEvents().getEventDefs() != null
- && !workflow.getEvents().getEventDefs().isEmpty();
- }
-
- /** Gets event refs of an action */
- public static List getActionEvents(Action action) {
- List actionEvents = new ArrayList<>();
-
- if (action != null && action.getEventRef() != null) {
- if (action.getEventRef().getTriggerEventRef() != null) {
- actionEvents.add(action.getEventRef().getTriggerEventRef());
- }
- if (action.getEventRef().getResultEventRef() != null) {
- actionEvents.add(action.getEventRef().getResultEventRef());
- }
- }
-
- return actionEvents;
- }
-
- /**
- * Merges two JsonNode
- *
- * @param mainNode
- * @param updateNode
- * @return merged JsonNode
- */
- public static JsonNode mergeNodes(JsonNode mainNode, JsonNode updateNode) {
-
- Iterator fieldNames = updateNode.fieldNames();
- while (fieldNames.hasNext()) {
-
- String fieldName = fieldNames.next();
- JsonNode jsonNode = mainNode.get(fieldName);
- // if field exists and is an embedded object
- if (jsonNode != null && jsonNode.isObject()) {
- mergeNodes(jsonNode, updateNode.get(fieldName));
- } else {
- if (mainNode instanceof ObjectNode) {
- // Overwrite field
- JsonNode value = updateNode.get(fieldName);
- ((ObjectNode) mainNode).set(fieldName, value);
- }
- }
- }
-
- return mainNode;
- }
-
- /**
- * Adds node as field
- *
- * @param mainNode
- * @param toAddNode
- * @param fieldName
- * @return original, main node with field added
- */
- public static JsonNode addNode(JsonNode mainNode, JsonNode toAddNode, String fieldName) {
- ((ObjectNode) mainNode).set(fieldName, toAddNode);
- return mainNode;
- }
-
- /**
- * Adds array with name
- *
- * @param mainNode
- * @param toAddArray
- * @param arrayName
- * @return original, main node with array added
- */
- public static JsonNode addArray(JsonNode mainNode, ArrayNode toAddArray, String arrayName) {
- ((ObjectNode) mainNode).set(arrayName, toAddArray);
- return mainNode;
- }
-
- /**
- * Adds a object field
- *
- * @param mainNode
- * @param toAddValue
- * @param fieldName
- * @return original, main node with field added
- */
- public static JsonNode addFieldValue(JsonNode mainNode, Object toAddValue, String fieldName) {
- ObjectMapper mapper = new ObjectMapper();
- ((ObjectNode) mainNode).set(fieldName, mapper.valueToTree(toAddValue));
- return mainNode;
- }
-
- /**
- * Returns a list of function definitions that have the given type.
- *
- * @param workflow
- * @param type
- * @return list of functions defs or null
- */
- public static List getFunctionDefinitionsWithType(
- Workflow workflow, FunctionDefinition.Type type) {
- if (!hasFunctionDefs(workflow)) return null;
- return workflow.getFunctions().getFunctionDefs().stream()
- .filter(fd -> fd.getType().equals(type))
- .collect(Collectors.toList());
- }
-
- /**
- * Returns function definition with provided name
- *
- * @param workflow
- * @param name
- * @return function definition or null
- */
- public static FunctionDefinition getFunctionDefinitionWithName(Workflow workflow, String name) {
- if (!hasFunctionDefs(workflow)) return null;
- Optional funcDef =
- workflow.getFunctions().getFunctionDefs().stream()
- .filter(fd -> fd.getName().equals(name))
- .findFirst();
- return funcDef.orElse(null);
- }
-}
diff --git a/utils/src/test/java/io/serverlessworkflow/util/DefinedEventsTest.java b/utils/src/test/java/io/serverlessworkflow/util/DefinedEventsTest.java
deleted file mode 100644
index 2e480dba..00000000
--- a/utils/src/test/java/io/serverlessworkflow/util/DefinedEventsTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.util;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.util.testutil.TestUtils;
-import io.serverlessworkflow.utils.WorkflowUtils;
-import java.util.List;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-class DefinedEventsTest {
- @ParameterizedTest
- @ValueSource(strings = {"/events/workflowwithevents.yml"})
- public void testGetDefinedConsumedEvents(String workflowEvents) {
- int consumedEventsCount = 2;
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowEvents);
- List consumedEvents = WorkflowUtils.getDefinedConsumedEvents(workflow);
- assertEquals(consumedEventsCount, consumedEvents.size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/events/workflowwithevents.yml"})
- public void testGetDefinedroducedEvents(String workflowEvents) {
- int producedEventsCounts = 1;
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowEvents);
- List producedEvents = WorkflowUtils.getDefinedProducedEvents(workflow);
- assertEquals(producedEventsCounts, producedEvents.size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/events/workflowwithevents.yml"})
- public void testGetDefinedConsumedEventsCount(String workflowEvents) {
- int consumedEventsCountExpected = 2;
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowEvents);
- int consumedEventsCount = WorkflowUtils.getDefinedConsumedEventsCount(workflow);
- assertEquals(consumedEventsCountExpected, consumedEventsCount);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/events/workflowwithevents.yml"})
- public void testGetDefinedroducedEventsCount(String workflowEvents) {
- int producedEventsCountExpected = 1;
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowEvents);
- int producedEventsCount = WorkflowUtils.getDefinedProducedEventsCount(workflow);
- assertEquals(producedEventsCountExpected, producedEventsCount);
- }
-
- @Test
- public void testGetDefinedEventsForNullWorkflow() {
- assertNull(WorkflowUtils.getDefinedEvents(null, EventDefinition.Kind.CONSUMED));
- }
-
- @Test
- public void testGetDefinedEventsCountForNullWorkflow() {
- int expectedCount = 0;
- assertEquals(
- expectedCount, WorkflowUtils.getDefinedEventsCount(null, EventDefinition.Kind.PRODUCED));
- }
-}
diff --git a/utils/src/test/java/io/serverlessworkflow/util/EventsTest.java b/utils/src/test/java/io/serverlessworkflow/util/EventsTest.java
deleted file mode 100644
index ab0c2413..00000000
--- a/utils/src/test/java/io/serverlessworkflow/util/EventsTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.util;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.util.testutil.TestUtils;
-import io.serverlessworkflow.utils.WorkflowUtils;
-import java.util.*;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-public class EventsTest {
- @ParameterizedTest
- @ValueSource(strings = {"/events/workflowwithevents.yml"})
- public void testGetConsumedEvents(String workflowEvents) {
- int expectedEventsCount = 2;
- Collection expectedConsumedEvent =
- Arrays.asList("SATScoresReceived", "RecommendationLetterReceived");
- Set uniqueExpectedConsumedEvent = new HashSet<>(expectedConsumedEvent);
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowEvents);
- List consumedEvents = WorkflowUtils.getWorkflowConsumedEvents(workflow);
- assertEquals(expectedEventsCount, consumedEvents.size());
- for (EventDefinition consumedEvent : consumedEvents) {
- assertTrue(uniqueExpectedConsumedEvent.contains(consumedEvent.getName()));
- }
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/events/workflowwithevents.yml"})
- public void testGetConsumedEventsCount(String workflowEvents) {
- int expectedEventsCount = 2;
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowEvents);
- int workflowConsumedEventsCount = WorkflowUtils.getWorkflowConsumedEventsCount(workflow);
- Arrays.asList(expectedEventsCount, workflowConsumedEventsCount);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/events/workflowwithproducedevents.yml"})
- public void testGetWorkflowProducedEvents(String workflowProducedEvents) {
- int expectedEventsCount = 1;
- Collection expectedProducedEvent = Arrays.asList("ApplicationSubmitted");
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowProducedEvents);
- List producedEvents = WorkflowUtils.getWorkflowProducedEvents(workflow);
- assertNotNull(producedEvents);
- assertEquals(expectedEventsCount, producedEvents.size());
- for (EventDefinition producedEvent : producedEvents) {
- assertTrue(expectedProducedEvent.contains(producedEvent.getName()));
- }
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/events/workflowwithproducedevents.yml"})
- public void testGetWorkflowProducedEventsCount(String workflowProducedEvents) {
- int expectedEventsCount = 1;
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowProducedEvents);
- int producedEventsCount = WorkflowUtils.getWorkflowProducedEventsCount(workflow);
- assertEquals(expectedEventsCount, producedEventsCount);
- }
-}
diff --git a/utils/src/test/java/io/serverlessworkflow/util/FunctionDefinitionsTest.java b/utils/src/test/java/io/serverlessworkflow/util/FunctionDefinitionsTest.java
deleted file mode 100644
index 14b00bcc..00000000
--- a/utils/src/test/java/io/serverlessworkflow/util/FunctionDefinitionsTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.util;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.actions.Action;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.util.testutil.TestUtils;
-import io.serverlessworkflow.utils.WorkflowUtils;
-import java.util.List;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-public class FunctionDefinitionsTest {
-
- @ParameterizedTest
- @ValueSource(strings = {"/funcdefinitiontest/functiondefinition.yml"})
- public void testFunctionDefsForAction(String funcDefinitions) {
- String actionLookUp = "finalizeApplicationAction";
- String expectedFunctionRefName = "finalizeApplicationFunction";
- Workflow workflow = TestUtils.createWorkflowFromTestResource(funcDefinitions);
- FunctionDefinition finalizeApplicationFunctionDefinition =
- WorkflowUtils.getFunctionDefinitionsForAction(workflow, actionLookUp);
- assertNotNull(finalizeApplicationFunctionDefinition);
- assertEquals(expectedFunctionRefName, finalizeApplicationFunctionDefinition.getName());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/funcdefinitiontest/functiondefinition.yml"})
- public void testFunctionDefsForActionNotPresent(String funcDefinitions) {
- String actionLookUp = "finalizeApplicationFunctionNotPresent";
- Workflow workflow = TestUtils.createWorkflowFromTestResource(funcDefinitions);
- FunctionDefinition finalizeApplicationFunctionDefinition =
- WorkflowUtils.getFunctionDefinitionsForAction(workflow, actionLookUp);
- assertNull(finalizeApplicationFunctionDefinition);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/funcdefinitiontest/functiondefinition.yml"})
- public void testFunctionDefsForNullWorkflow(String funcDefinitions) {
- assertNull(WorkflowUtils.getFunctionDefinitionsForAction(null, "TestAction"));
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/funcdefinitiontest/functiondefinition.yml"})
- public void testGetActionsForFunctionDefinition(String funcDefinitions) {
- String functionRefName = "finalizeApplicationFunction";
- int expectedActionCount = 2;
- Workflow workflow = TestUtils.createWorkflowFromTestResource(funcDefinitions);
- List actionsForFunctionDefinition =
- WorkflowUtils.getActionsForFunctionDefinition(workflow, functionRefName);
- assertEquals(expectedActionCount, actionsForFunctionDefinition.size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/funcdefinitiontest/functiondefinition.yml"})
- public void testGetFunctionDefinitionWithName(String funcDefinitions) {
- Workflow workflow = TestUtils.createWorkflowFromTestResource(funcDefinitions);
- assertNotNull(
- WorkflowUtils.getFunctionDefinitionWithName(workflow, "finalizeApplicationFunction"));
- }
-}
diff --git a/utils/src/test/java/io/serverlessworkflow/util/FunctionsWithTypeTest.java b/utils/src/test/java/io/serverlessworkflow/util/FunctionsWithTypeTest.java
deleted file mode 100644
index ab30aece..00000000
--- a/utils/src/test/java/io/serverlessworkflow/util/FunctionsWithTypeTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.util;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.util.testutil.TestUtils;
-import io.serverlessworkflow.utils.WorkflowUtils;
-import java.util.List;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-public class FunctionsWithTypeTest {
- @ParameterizedTest
- @ValueSource(strings = {"/functiontypes/workflowfunctiontypes.yml"})
- public void testGetNumStates(String workflowWithStates) {
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowWithStates);
- List expressionFunctionDefs =
- WorkflowUtils.getFunctionDefinitionsWithType(workflow, FunctionDefinition.Type.EXPRESSION);
- assertNotNull(expressionFunctionDefs);
- assertEquals(2, expressionFunctionDefs.size());
- assertEquals("Function One", expressionFunctionDefs.get(0).getName());
- assertEquals("Function Three", expressionFunctionDefs.get(1).getName());
- }
-}
diff --git a/utils/src/test/java/io/serverlessworkflow/util/GetNumTests.java b/utils/src/test/java/io/serverlessworkflow/util/GetNumTests.java
deleted file mode 100644
index 1a2827a4..00000000
--- a/utils/src/test/java/io/serverlessworkflow/util/GetNumTests.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.util;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.states.DefaultState;
-import io.serverlessworkflow.util.testutil.TestUtils;
-import io.serverlessworkflow.utils.WorkflowUtils;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-public class GetNumTests {
- @ParameterizedTest
- @ValueSource(strings = {"/getStates/workflowwithstates.yml"})
- public void testGetNumStates(String workflowWithStates) {
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowWithStates);
- int expectedStatesCount = 2;
- assertEquals(expectedStatesCount, WorkflowUtils.getNumOfStates(workflow));
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/start/workflowwithnostate.yml"})
- public void testGetNumStatesForNoStateInWorkflow(String workflowWithStates) {
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowWithStates);
- int expectedStatesCount = 0;
- assertEquals(expectedStatesCount, WorkflowUtils.getNumOfStates(workflow));
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/getStates/workflowwithstates.yml"})
- public void testGetNumStatesOfEventType(String workflowWithStates) {
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowWithStates);
- int expectedStatesCount = 2;
- assertEquals(
- expectedStatesCount, WorkflowUtils.getNumOfStates(workflow, DefaultState.Type.EVENT));
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/events/workflowwithevents.yml"})
- public void testGetNumEndStates(String workflowWithStates) {
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowWithStates);
- int expectedEndStatesCount = 2;
- assertEquals(expectedEndStatesCount, WorkflowUtils.getNumOfEndStates(workflow));
- }
-}
diff --git a/utils/src/test/java/io/serverlessworkflow/util/GetStatesTest.java b/utils/src/test/java/io/serverlessworkflow/util/GetStatesTest.java
deleted file mode 100644
index 7d977251..00000000
--- a/utils/src/test/java/io/serverlessworkflow/util/GetStatesTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.util;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.api.states.DefaultState;
-import io.serverlessworkflow.api.states.EventState;
-import io.serverlessworkflow.util.testutil.TestUtils;
-import io.serverlessworkflow.utils.WorkflowUtils;
-import java.util.List;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-class GetStatesTest {
-
- @ParameterizedTest
- @ValueSource(strings = {"/getStates/workflowwithstates.yml"})
- public void testGetStatesByDefaultState(String workflowWithState) {
- int matchingEvents = 2;
- int notMatchingEvents = 0;
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowWithState);
- List matchingStates = WorkflowUtils.getStates(workflow, DefaultState.Type.EVENT);
- List notMatchingStates = WorkflowUtils.getStates(workflow, DefaultState.Type.SLEEP);
- assertEquals(matchingEvents, matchingStates.size());
- assertEquals(notMatchingEvents, notMatchingStates.size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/getStates/workflowwithstates.yml"})
- public void testGetStateByName(String workflowWithState) {
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowWithState);
-
- State finalizeApplicationState =
- WorkflowUtils.getStateWithName(workflow, "FinalizeApplication");
- assertNotNull(finalizeApplicationState);
- assertTrue(finalizeApplicationState instanceof EventState);
-
- State cancelApplicationState = WorkflowUtils.getStateWithName(workflow, "CancelApplication");
- assertNotNull(cancelApplicationState);
- assertTrue(cancelApplicationState instanceof EventState);
- }
-
- @Test
- public void testGetsStatesForNullWorkflow() {
- assertNull(WorkflowUtils.getStates(null, DefaultState.Type.EVENT));
- }
-}
diff --git a/utils/src/test/java/io/serverlessworkflow/util/JsonManipulationTest.java b/utils/src/test/java/io/serverlessworkflow/util/JsonManipulationTest.java
deleted file mode 100644
index 9673e689..00000000
--- a/utils/src/test/java/io/serverlessworkflow/util/JsonManipulationTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.util;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import io.serverlessworkflow.utils.WorkflowUtils;
-import org.junit.jupiter.api.Test;
-
-public class JsonManipulationTest {
- private static final ObjectMapper mapper = new ObjectMapper();
-
- @Test
- public void testAddFieldValue() throws Exception {
- String mainString = "{\"k1\":\"v1\",\"k2\":\"v2\"}";
- JsonNode mainNode = mapper.readTree(mainString);
- String toAddString = "v3";
-
- JsonNode added = WorkflowUtils.addFieldValue(mainNode, toAddString, "k3");
-
- assertNotNull(added);
- assertEquals("v3", added.get("k3").asText());
- }
-
- @Test
- public void testAddNode() throws Exception {
- String mainString = "{\"k1\":\"v1\",\"k2\":\"v2\"}";
- JsonNode mainNode = mapper.readTree(mainString);
- String toAddString = "{\"k3\":\"v3\"}";
- JsonNode toAddNode = mapper.readTree(toAddString);
-
- JsonNode added = WorkflowUtils.addNode(mainNode, toAddNode, "newnode");
-
- assertNotNull(added);
- assertEquals("v3", added.get("newnode").get("k3").asText());
- }
-
- @Test
- public void testAddArray() throws Exception {
- String mainString = "{\"k1\":\"v1\",\"k2\":\"v2\"}";
- JsonNode mainNode = mapper.readTree(mainString);
- String toAddString = "[\"a\", \"b\"]";
- JsonNode toAddNode = mapper.readTree(toAddString);
-
- JsonNode added = WorkflowUtils.addArray(mainNode, (ArrayNode) toAddNode, "newarray");
-
- assertNotNull(added);
- assertNotNull(added.get("newarray"));
- assertEquals(2, added.get("newarray").size());
- assertEquals("a", added.get("newarray").get(0).asText());
- assertEquals("b", added.get("newarray").get(1).asText());
- }
-
- @Test
- public void testMergeNodes() throws Exception {
- String mainString = "{\"k1\":\"v1\",\"k2\":\"v2\"}";
- JsonNode mainNode = mapper.readTree(mainString);
- String toMergeString = "{\"k3\":\"v3\",\"k4\":\"v4\"}";
- JsonNode toMergeNode = mapper.readTree(toMergeString);
-
- JsonNode merged = WorkflowUtils.mergeNodes(mainNode, toMergeNode);
-
- assertNotNull(merged);
- assertEquals("v3", merged.get("k3").asText());
- assertEquals("v4", merged.get("k4").asText());
- }
-
- @Test
- public void testMergeWithOverwrite() throws Exception {
- String mainString = "{\"k1\":\"v1\",\"k2\":\"v2\"}";
- JsonNode mainNode = mapper.readTree(mainString);
- String toMergeString = "{\"k2\":\"v2new\",\"k3\":\"v3\"}";
- JsonNode toMergeNode = mapper.readTree(toMergeString);
-
- JsonNode merged = WorkflowUtils.mergeNodes(mainNode, toMergeNode);
-
- assertNotNull(merged);
- assertEquals("v2new", merged.get("k2").asText());
- assertEquals("v3", merged.get("k3").asText());
- }
-}
diff --git a/utils/src/test/java/io/serverlessworkflow/util/StartStateTest.java b/utils/src/test/java/io/serverlessworkflow/util/StartStateTest.java
deleted file mode 100644
index aad5de7f..00000000
--- a/utils/src/test/java/io/serverlessworkflow/util/StartStateTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.util;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.util.testutil.TestUtils;
-import io.serverlessworkflow.utils.WorkflowUtils;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-class StartStateTest {
-
- @ParameterizedTest
- @ValueSource(strings = {"/start/workflowwithstartstate.yml"})
- public void testGetStartState(String workflowWithStartState) {
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowWithStartState);
- State startingState = WorkflowUtils.getStartingState(workflow);
- assertNotNull(startingState);
- assertEquals(startingState.getName(), workflow.getStart().getStateName());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/start/workflowwithstartnotspecified.yml"})
- public void testGetStartStateForWorkflowWithStartNotSpecified(
- String workflowWithStartStateNotSpecified) {
- Workflow workflow =
- TestUtils.createWorkflowFromTestResource(workflowWithStartStateNotSpecified);
- State startingState = WorkflowUtils.getStartingState(workflow);
- assertEquals(workflow.getStates().get(0).getName(), startingState.getName());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {"/start/workflowwithnostate.yml"})
- public void testGetStartStateForWorkflowWithNoState(String workflowWithNoState) {
- Workflow workflow = TestUtils.createWorkflowFromTestResource(workflowWithNoState);
- State startingState = WorkflowUtils.getStartingState(workflow);
- assertNull(startingState);
- }
-
- @Test
- public void testGetStateForNullWorkflow() {
- State startingState = WorkflowUtils.getStartingState(null);
- assertNull(startingState);
- }
-}
diff --git a/utils/src/test/java/io/serverlessworkflow/util/testutil/TestUtils.java b/utils/src/test/java/io/serverlessworkflow/util/testutil/TestUtils.java
deleted file mode 100644
index c4c59820..00000000
--- a/utils/src/test/java/io/serverlessworkflow/util/testutil/TestUtils.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.util.testutil;
-
-import io.serverlessworkflow.api.Workflow;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-public class TestUtils {
-
- public static Workflow createWorkflow(String source) {
- return Workflow.fromSource(source);
- }
-
- public static Workflow createWorkflowFromTestResource(String fileRelativePath) {
- InputStreamReader reader = getTestResourceStreamReader(fileRelativePath);
- return createWorkflow(readFileAsString(reader));
- }
-
- public static String readFileAsString(Reader reader) {
- try {
- StringBuilder fileData = new StringBuilder(1000);
- char[] buf = new char[1024];
- int numRead;
- while ((numRead = reader.read(buf)) != -1) {
- String readData = String.valueOf(buf, 0, numRead);
- fileData.append(readData);
- buf = new char[1024];
- }
- reader.close();
- return fileData.toString();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- private static InputStreamReader getTestResourceStreamReader(String fileRelativePath) {
- return new InputStreamReader(TestUtils.class.getResourceAsStream(fileRelativePath));
- }
-}
diff --git a/utils/src/test/resources/events/workflowwithevents.yml b/utils/src/test/resources/events/workflowwithevents.yml
deleted file mode 100644
index 211b53e2..00000000
--- a/utils/src/test/resources/events/workflowwithevents.yml
+++ /dev/null
@@ -1,56 +0,0 @@
-id: finalizeCollegeApplication
-name: Finalize College Application
-version: '1.0'
-specVersion: '0.8'
-events:
- - name: ApplicationSubmitted
- type: org.application.submitted
- source: applicationsource
- kind: produced
- correlation:
- - contextAttributeName: applicantId
- - name: SATScoresReceived
- type: org.application.satscores
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: RecommendationLetterReceived
- type: org.application.recommendationLetter
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
-functions:
- - name: finalizeApplicationFunction
- operation: http://myapis.org/collegeapplicationapi.json#finalize
-states:
- - name: FinalizeApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
-
- - name: CancelApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
\ No newline at end of file
diff --git a/utils/src/test/resources/events/workflowwithproducedevents.yml b/utils/src/test/resources/events/workflowwithproducedevents.yml
deleted file mode 100644
index 8cd80895..00000000
--- a/utils/src/test/resources/events/workflowwithproducedevents.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-id: finalizeCollegeApplication
-name: Finalize College Application
-version: '1.0'
-specVersion: '0.8'
-events:
- - name: ApplicationSubmitted
- type: org.application.submitted
- source: applicationsource
- kind: produced
- correlation:
- - contextAttributeName: applicantId
- - name: SATScoresReceived
- type: org.application.satscores
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: RecommendationLetterReceived
- type: org.application.recommendationLetter
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
-functions:
- - name: finalizeApplicationFunction
- operation: http://myapis.org/collegeapplicationapi.json#finalize
-states:
- - name: FinalizeApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
- produceEvents:
- - eventRef: ApplicationSubmitted
- data: "${ .provisionedOrders }"
-
- - name: CancelApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
\ No newline at end of file
diff --git a/utils/src/test/resources/funcdefinitiontest/functiondefinition.yml b/utils/src/test/resources/funcdefinitiontest/functiondefinition.yml
deleted file mode 100644
index 7ad953a7..00000000
--- a/utils/src/test/resources/funcdefinitiontest/functiondefinition.yml
+++ /dev/null
@@ -1,58 +0,0 @@
-id: finalizeCollegeApplication
-name: Finalize College Application
-version: '1.0'
-specVersion: '0.8'
-events:
- - name: ApplicationSubmitted
- type: org.application.submitted
- source: applicationsource
- kind: produced
- correlation:
- - contextAttributeName: applicantId
- - name: SATScoresReceived
- type: org.application.satscores
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: RecommendationLetterReceived
- type: org.application.recommendationLetter
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
-functions:
- - name: finalizeApplicationFunction
- operation: http://myapis.org/collegeapplicationapi.json#finalize
-states:
- - name: FinalizeApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - name : finalizeApplicationAction
- functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
-
- - name: CancelApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - name : finalizeApplicationAction
- functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
\ No newline at end of file
diff --git a/utils/src/test/resources/functiontypes/workflowfunctiontypes.yml b/utils/src/test/resources/functiontypes/workflowfunctiontypes.yml
deleted file mode 100644
index a205f469..00000000
--- a/utils/src/test/resources/functiontypes/workflowfunctiontypes.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-id: functiontypes
-version: '1.0'
-specVersion: '0.8'
-name: Function Types Workflow
-functions:
- - name: Function One
- type: expression
- operation: ".one"
- - name: Function Two
- type: asyncapi
- operation: banking.yaml#largerTransation
- - name: Function Three
- type: expression
- operation: ".three"
-states:
- - name: Dummy
- type: operation
- actions:
- - functionRef: Function One
- - functionRef: Function Two
- - functionRef: Function Three
- end: true
diff --git a/utils/src/test/resources/getStates/workflowwithstates.yml b/utils/src/test/resources/getStates/workflowwithstates.yml
deleted file mode 100644
index 9ac1edb5..00000000
--- a/utils/src/test/resources/getStates/workflowwithstates.yml
+++ /dev/null
@@ -1,55 +0,0 @@
-id: finalizeCollegeApplication
-name: Finalize College Application
-version: '1.0'
-specVersion: '0.8'
-events:
- - name: ApplicationSubmitted
- type: org.application.submitted
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: SATScoresReceived
- type: org.application.satscores
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: RecommendationLetterReceived
- type: org.application.recommendationLetter
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
-functions:
- - name: finalizeApplicationFunction
- operation: http://myapis.org/collegeapplicationapi.json#finalize
-states:
- - name: FinalizeApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
-
- - name: CancelApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
\ No newline at end of file
diff --git a/utils/src/test/resources/start/workflowwithnostate.yml b/utils/src/test/resources/start/workflowwithnostate.yml
deleted file mode 100644
index a16e68df..00000000
--- a/utils/src/test/resources/start/workflowwithnostate.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-id: finalizeCollegeApplication
-name: Finalize College Application
-version: '1.0'
-specVersion: '0.8'
-start: FinalizeApplication
-events:
- - name: ApplicationSubmitted
- type: org.application.submitted
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: SATScoresReceived
- type: org.application.satscores
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: RecommendationLetterReceived
- type: org.application.recommendationLetter
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
-functions:
- - name: finalizeApplicationFunction
- operation: http://myapis.org/collegeapplicationapi.json#finalize
diff --git a/utils/src/test/resources/start/workflowwithstartnotspecified.yml b/utils/src/test/resources/start/workflowwithstartnotspecified.yml
deleted file mode 100644
index 03bb87c5..00000000
--- a/utils/src/test/resources/start/workflowwithstartnotspecified.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-id: finalizeCollegeApplication
-name: Finalize College Application
-version: '1.0'
-specVersion: '0.8'
-events:
- - name: ApplicationSubmitted
- type: org.application.submitted
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: SATScoresReceived
- type: org.application.satscores
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: RecommendationLetterReceived
- type: org.application.recommendationLetter
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
-functions:
- - name: finalizeApplicationFunction
- operation: http://myapis.org/collegeapplicationapi.json#finalize
-states:
- - name: FinalizeApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
\ No newline at end of file
diff --git a/utils/src/test/resources/start/workflowwithstartstate.yml b/utils/src/test/resources/start/workflowwithstartstate.yml
deleted file mode 100644
index 0d2fd30c..00000000
--- a/utils/src/test/resources/start/workflowwithstartstate.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-id: finalizeCollegeApplication
-name: Finalize College Application
-version: '1.0'
-specVersion: '0.8'
-start: FinalizeApplication
-events:
- - name: ApplicationSubmitted
- type: org.application.submitted
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: SATScoresReceived
- type: org.application.satscores
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
- - name: RecommendationLetterReceived
- type: org.application.recommendationLetter
- source: applicationsource
- correlation:
- - contextAttributeName: applicantId
-functions:
- - name: finalizeApplicationFunction
- operation: http://myapis.org/collegeapplicationapi.json#finalize
-states:
- - name: FinalizeApplication
- type: event
- exclusive: false
- onEvents:
- - eventRefs:
- - ApplicationSubmitted
- - SATScoresReceived
- - RecommendationLetterReceived
- actions:
- - functionRef:
- refName: finalizeApplicationFunction
- arguments:
- student: "${ .applicantId }"
- end:
- terminate: true
\ No newline at end of file
diff --git a/validation/.gitignore b/validation/.gitignore
deleted file mode 100644
index d4dfde66..00000000
--- a/validation/.gitignore
+++ /dev/null
@@ -1,31 +0,0 @@
-HELP.md
-target/
-!.mvn/wrapper/maven-wrapper.jar
-!**/src/main/**
-!**/src/test/**
-
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-build/
-
-### VS Code ###
-.vscode/
\ No newline at end of file
diff --git a/validation/pom.xml b/validation/pom.xml
deleted file mode 100644
index 71a32ff2..00000000
--- a/validation/pom.xml
+++ /dev/null
@@ -1,146 +0,0 @@
-
- 4.0.0
-
-
- io.serverlessworkflow
- serverlessworkflow-parent
- 7.0.0-SNAPSHOT
-
-
- serverlessworkflow-validation
- Serverless Workflow :: Validation
- jar
- Java SDK for Serverless Workflow Specification
-
-
-
- org.slf4j
- slf4j-api
-
-
- org.slf4j
- jcl-over-slf4j
-
-
-
- io.serverlessworkflow
- serverlessworkflow-api
- ${project.version}
-
-
-
- org.apache.commons
- commons-lang3
-
-
- com.networknt
- json-schema-validator
-
-
-
- org.junit.jupiter
- junit-jupiter-api
- test
-
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.junit.jupiter
- junit-jupiter-params
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- ch.qos.logback
- logback-classic
- test
-
-
- org.assertj
- assertj-core
- test
-
-
- org.hamcrest
- hamcrest-library
- test
-
-
- org.skyscreamer
- jsonassert
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${project.build.directory}/checkstyle.log
- true
- true
- true
- false
- false
- ${checkstyle.logViolationsToConsole}
- ${checkstyle.failOnViolation}
-
- ${project.build.sourceDirectory}
- ${project.build.testSourceDirectory}
-
-
-
-
- compile
-
- check
-
-
-
-
-
- com.spotify.fmt
- fmt-maven-plugin
-
- src/main/java
- src/test/java
- false
- .*\.java
- false
- false
-
-
-
-
-
- format
-
-
-
-
-
-
-
diff --git a/validation/src/main/java/io/serverlessworkflow/validation/WorkflowValidatorImpl.java b/validation/src/main/java/io/serverlessworkflow/validation/WorkflowValidatorImpl.java
deleted file mode 100644
index c7b7336f..00000000
--- a/validation/src/main/java/io/serverlessworkflow/validation/WorkflowValidatorImpl.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * 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.validation;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.networknt.schema.JsonSchemaFactory;
-import com.networknt.schema.SpecVersion.VersionFlag;
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.actions.Action;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.api.events.OnEvents;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.api.interfaces.State;
-import io.serverlessworkflow.api.interfaces.WorkflowValidator;
-import io.serverlessworkflow.api.retry.RetryDefinition;
-import io.serverlessworkflow.api.states.*;
-import io.serverlessworkflow.api.switchconditions.DataCondition;
-import io.serverlessworkflow.api.switchconditions.EventCondition;
-import io.serverlessworkflow.api.utils.Utils;
-import io.serverlessworkflow.api.validation.ValidationError;
-import io.serverlessworkflow.api.validation.WorkflowSchemaLoader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class WorkflowValidatorImpl implements WorkflowValidator {
-
- private static final Logger logger = LoggerFactory.getLogger(WorkflowValidatorImpl.class);
- private boolean schemaValidationEnabled = true;
- private final List validationErrors = new ArrayList<>();
- private final JsonNode workflowSchema = WorkflowSchemaLoader.getWorkflowSchema();
- private String source;
- private Workflow workflow;
-
- @Override
- public WorkflowValidator setWorkflow(Workflow workflow) {
- this.workflow = workflow;
- return this;
- }
-
- @Override
- public WorkflowValidator setSource(String source) {
- this.source = source;
- return this;
- }
-
- @Override
- public List validate() {
- validationErrors.clear();
- if (workflow == null) {
- try {
- if (schemaValidationEnabled && source != null) {
- JsonSchemaFactory.getInstance(VersionFlag.V7)
- .getSchema(workflowSchema)
- .validate(Utils.getNode(source))
- .forEach(m -> addValidationError(m.getMessage(), ValidationError.SCHEMA_VALIDATION));
- }
- } catch (IOException e) {
- logger.error("Unexpected error during validation", e);
- }
- }
-
- // if there are schema validation errors
- // there is no point of doing the workflow validation
- if (!validationErrors.isEmpty()) {
- return validationErrors;
- } else if (workflow == null) {
- workflow = Workflow.fromSource(source);
- }
-
- List functions =
- workflow.getFunctions() != null ? workflow.getFunctions().getFunctionDefs() : null;
-
- List events =
- workflow.getEvents() != null ? workflow.getEvents().getEventDefs() : null;
-
- if ((workflow.getId() == null || workflow.getId().trim().isEmpty())
- && (workflow.getKey() == null || workflow.getKey().trim().isEmpty())) {
- addValidationError(
- "Workflow id or key should not be empty", ValidationError.WORKFLOW_VALIDATION);
- }
-
- if (workflow.getVersion() == null || workflow.getVersion().trim().isEmpty()) {
- addValidationError(
- "Workflow version should not be empty", ValidationError.WORKFLOW_VALIDATION);
- }
-
- if (workflow.getRetries() != null && workflow.getRetries().getRetryDefs() != null) {
- workflow
- .getRetries()
- .getRetryDefs()
- .forEach(
- r -> {
- if (r.getName() == null || r.getName().isEmpty()) {
- addValidationError(
- "Retry name should not be empty", ValidationError.WORKFLOW_VALIDATION);
- }
- });
- }
-
- if (workflow.getStates() == null || workflow.getStates().isEmpty()) {
- addValidationError("No states found", ValidationError.WORKFLOW_VALIDATION);
- }
-
- if (workflow.getStates() != null && !workflow.getStates().isEmpty()) {
- boolean existingStateWithStartProperty = false;
- if (workflow.getStart() != null) {
- String startProperty = workflow.getStart().getStateName();
- for (State s : workflow.getStates()) {
- if (s.getName().equals(startProperty)) {
- existingStateWithStartProperty = true;
- break;
- }
- }
- } else {
- existingStateWithStartProperty = true;
- }
- if (!existingStateWithStartProperty) {
- addValidationError(
- "No state name found that matches the workflow start definition",
- ValidationError.WORKFLOW_VALIDATION);
- }
- }
-
- Validation validation = new Validation();
- if (workflow.getStates() != null && !workflow.getStates().isEmpty()) {
- workflow
- .getStates()
- .forEach(
- s -> {
- if (s.getName() != null && s.getName().trim().isEmpty()) {
- addValidationError(
- "State name should not be empty", ValidationError.WORKFLOW_VALIDATION);
- } else {
- validation.addState(s.getName());
- }
-
- if (s.getEnd() != null) {
- validation.addEndState();
- }
-
- if (s instanceof OperationState) {
- OperationState operationState = (OperationState) s;
- checkActionsDefinition(operationState.getActions(), functions, events);
- }
-
- if (s instanceof EventState) {
- EventState eventState = (EventState) s;
- if (eventState.getOnEvents() == null || eventState.getOnEvents().isEmpty()) {
- addValidationError(
- "Event State has no eventActions defined",
- ValidationError.WORKFLOW_VALIDATION);
- }
- List eventsActionsList = eventState.getOnEvents();
- for (OnEvents onEvents : eventsActionsList) {
-
- List eventRefs = onEvents.getEventRefs();
- if (eventRefs == null || eventRefs.isEmpty()) {
- addValidationError(
- "Event State eventsActions has no event refs",
- ValidationError.WORKFLOW_VALIDATION);
- } else {
- for (String eventRef : eventRefs) {
- if (isMissingEventsDefinition(eventRef, events)) {
- addValidationError(
- "Event State eventsActions eventRef does not match a declared workflow event definition",
- ValidationError.WORKFLOW_VALIDATION);
- }
- }
- }
- }
- }
-
- if (s instanceof SwitchState) {
- SwitchState switchState = (SwitchState) s;
- if ((switchState.getDataConditions() == null
- || switchState.getDataConditions().isEmpty())
- && (switchState.getEventConditions() == null
- || switchState.getEventConditions().isEmpty())) {
- addValidationError(
- "Switch state should define either data or event conditions",
- ValidationError.WORKFLOW_VALIDATION);
- }
-
- if (switchState.getDefaultCondition() == null) {
- addValidationError(
- "Switch state should define a default transition",
- ValidationError.WORKFLOW_VALIDATION);
- }
-
- if (switchState.getEventConditions() != null
- && !switchState.getEventConditions().isEmpty()) {
- List eventConditions = switchState.getEventConditions();
- for (EventCondition ec : eventConditions) {
- if (isMissingEventsDefinition(ec.getEventRef(), events)) {
- addValidationError(
- "Switch state event condition eventRef does not reference a defined workflow event",
- ValidationError.WORKFLOW_VALIDATION);
- }
- if (ec.getEnd() != null) {
- validation.addEndState();
- }
- }
- }
-
- if (switchState.getDataConditions() != null
- && !switchState.getDataConditions().isEmpty()) {
- List dataConditions = switchState.getDataConditions();
- for (DataCondition dc : dataConditions) {
- if (dc.getEnd() != null) {
- validation.addEndState();
- }
- }
- }
- }
-
- if (s instanceof SleepState) {
- SleepState sleepState = (SleepState) s;
- if (sleepState.getDuration() == null || sleepState.getDuration().isEmpty()) {
- addValidationError(
- "Sleep state should have a non-empty time delay",
- ValidationError.WORKFLOW_VALIDATION);
- }
- }
-
- if (s instanceof ParallelState) {
- ParallelState parallelState = (ParallelState) s;
-
- if (parallelState.getBranches() == null
- || parallelState.getBranches().size() < 2) {
- addValidationError(
- "Parallel state should have at lest two branches",
- ValidationError.WORKFLOW_VALIDATION);
- }
- }
-
- if (s instanceof InjectState) {
- InjectState injectState = (InjectState) s;
- if (injectState.getData() == null || injectState.getData().isEmpty()) {
- addValidationError(
- "InjectState should have non-null data",
- ValidationError.WORKFLOW_VALIDATION);
- }
- }
-
- if (s instanceof ForEachState) {
- ForEachState forEachState = (ForEachState) s;
- checkActionsDefinition(forEachState.getActions(), functions, events);
- if (forEachState.getInputCollection() == null
- || forEachState.getInputCollection().isEmpty()) {
- addValidationError(
- "ForEach state should have a valid inputCollection",
- ValidationError.WORKFLOW_VALIDATION);
- }
- }
-
- if (s instanceof CallbackState) {
- CallbackState callbackState = (CallbackState) s;
-
- if (isMissingEventsDefinition(callbackState.getEventRef(), events)) {
- addValidationError(
- "CallbackState event ref does not reference a defined workflow event definition",
- ValidationError.WORKFLOW_VALIDATION);
- }
-
- if (isMissingFunctionDefinition(
- callbackState.getAction().getFunctionRef().getRefName(), functions)) {
- addValidationError(
- "CallbackState action function ref does not reference a defined workflow function definition",
- ValidationError.WORKFLOW_VALIDATION);
- }
- }
- });
-
- if (validation.endStates == 0) {
- addValidationError("No end state found.", ValidationError.WORKFLOW_VALIDATION);
- }
- }
-
- return validationErrors;
- }
-
- @Override
- public boolean isValid() {
- return validate().isEmpty();
- }
-
- @Override
- public WorkflowValidator setSchemaValidationEnabled(boolean schemaValidationEnabled) {
- this.schemaValidationEnabled = schemaValidationEnabled;
- return this;
- }
-
- @Override
- public WorkflowValidator reset() {
- workflow = null;
- validationErrors.clear();
- schemaValidationEnabled = true;
- return this;
- }
-
- private void checkActionsDefinition(
- List actions, List functions, List events) {
- if (actions == null) {
- return;
- }
- for (Action action : actions) {
- if (action.getFunctionRef() != null) {
- if (action.getFunctionRef().getRefName().isEmpty()) {
- addValidationError(
- String.format(
- "State action '%s' functionRef should not be null or empty", action.getName()),
- ValidationError.WORKFLOW_VALIDATION);
- }
-
- if (isMissingFunctionDefinition(action.getFunctionRef().getRefName(), functions)) {
- addValidationError(
- String.format(
- "State action '%s' functionRef does not reference an existing workflow function definition",
- action.getName()),
- ValidationError.WORKFLOW_VALIDATION);
- }
- }
-
- if (action.getEventRef() != null) {
-
- if (isMissingEventsDefinition(action.getEventRef().getTriggerEventRef(), events)) {
- addValidationError(
- String.format(
- "State action '%s' trigger event def does not reference an existing workflow event definition",
- action.getName()),
- ValidationError.WORKFLOW_VALIDATION);
- }
-
- if (isMissingEventsDefinition(action.getEventRef().getResultEventRef(), events)) {
- addValidationError(
- String.format(
- "State action '%s' results event def does not reference an existing workflow event definition",
- action.getName()),
- ValidationError.WORKFLOW_VALIDATION);
- }
- }
-
- if (action.getRetryRef() != null
- && isMissingRetryDefinition(action.getRetryRef(), workflow.getRetries().getRetryDefs())) {
- addValidationError(
- String.format(
- "Operation State action '%s' retryRef does not reference an existing workflow retry definition",
- action.getName()),
- ValidationError.WORKFLOW_VALIDATION);
- }
- }
- }
-
- private boolean isMissingFunctionDefinition(
- String functionName, List functions) {
- if (functions != null) {
- return !functions.stream().anyMatch(f -> f.getName().equals(functionName));
- } else {
- return true;
- }
- }
-
- private boolean isMissingEventsDefinition(String eventName, List events) {
- if (eventName == null) {
- return false;
- }
- if (events != null) {
- return !events.stream().anyMatch(e -> e.getName().equals(eventName));
- } else {
- return true;
- }
- }
-
- private boolean isMissingRetryDefinition(String retryName, List retries) {
- return retries == null
- || !retries.stream().anyMatch(f -> f.getName() != null && f.getName().equals(retryName));
- }
-
- private static final Set skipMessages =
- Set.of(
- "$.start: string found, object expected",
- "$.functions: array found, object expected",
- "$.retries: array found, object expected",
- "$.errors: array found, object expected",
- "$.auth: array found, object expected");
-
- private void addValidationError(String message, String type) {
- if (skipMessages.contains(message)) {
- return;
- }
- ValidationError mainError = new ValidationError();
- mainError.setMessage(message);
- mainError.setType(type);
- validationErrors.add(mainError);
- }
-
- private class Validation {
- final Set states = new HashSet<>();
- Integer endStates = 0;
-
- void addState(String name) {
- if (states.contains(name)) {
- addValidationError(
- "State does not have an unique name: " + name, ValidationError.WORKFLOW_VALIDATION);
- } else {
- states.add(name);
- }
- }
-
- void addEndState() {
- endStates++;
- }
- }
-}
diff --git a/validation/src/main/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowValidator b/validation/src/main/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowValidator
deleted file mode 100644
index cebff91f..00000000
--- a/validation/src/main/resources/META-INF/services/io.serverlessworkflow.api.interfaces.WorkflowValidator
+++ /dev/null
@@ -1 +0,0 @@
-io.serverlessworkflow.validation.WorkflowValidatorImpl
\ No newline at end of file
diff --git a/validation/src/test/java/io/serverlessworkflow/validation/test/WorkflowValidationTest.java b/validation/src/test/java/io/serverlessworkflow/validation/test/WorkflowValidationTest.java
deleted file mode 100644
index d8828b48..00000000
--- a/validation/src/test/java/io/serverlessworkflow/validation/test/WorkflowValidationTest.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * 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.validation.test;
-
-import static io.serverlessworkflow.api.states.DefaultState.Type.OPERATION;
-import static io.serverlessworkflow.api.states.DefaultState.Type.SLEEP;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import io.serverlessworkflow.api.Workflow;
-import io.serverlessworkflow.api.actions.Action;
-import io.serverlessworkflow.api.end.End;
-import io.serverlessworkflow.api.error.ErrorDefinition;
-import io.serverlessworkflow.api.events.EventDefinition;
-import io.serverlessworkflow.api.events.EventRef;
-import io.serverlessworkflow.api.functions.FunctionDefinition;
-import io.serverlessworkflow.api.functions.FunctionDefinition.Type;
-import io.serverlessworkflow.api.functions.FunctionRef;
-import io.serverlessworkflow.api.interfaces.WorkflowValidator;
-import io.serverlessworkflow.api.retry.RetryDefinition;
-import io.serverlessworkflow.api.start.Start;
-import io.serverlessworkflow.api.states.ForEachState;
-import io.serverlessworkflow.api.states.InjectState;
-import io.serverlessworkflow.api.states.OperationState;
-import io.serverlessworkflow.api.states.SleepState;
-import io.serverlessworkflow.api.validation.ValidationError;
-import io.serverlessworkflow.api.workflow.Errors;
-import io.serverlessworkflow.api.workflow.Events;
-import io.serverlessworkflow.api.workflow.Functions;
-import io.serverlessworkflow.api.workflow.Retries;
-import io.serverlessworkflow.validation.WorkflowValidatorImpl;
-import java.util.Arrays;
-import java.util.List;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class WorkflowValidationTest {
-
- @Test
- public void testIncompleteJsonWithSchemaValidation() {
- WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
- List validationErrors =
- workflowValidator.setSource("{\n" + " \"id\": \"abc\" \n" + "}").validate();
- Assertions.assertNotNull(validationErrors);
- Assertions.assertEquals(3, validationErrors.size());
- }
-
- @Test
- public void testIncompleteYamlWithSchemaValidation() {
- WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
- List validationErrors =
- workflowValidator.setSource("---\n" + "key: abc\n").validate();
- Assertions.assertNotNull(validationErrors);
- Assertions.assertEquals(4, validationErrors.size());
- }
-
- @Test
- public void testFromIncompleteWorkflow() {
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withVersion("1.0")
- .withStart(new Start())
- .withStates(
- Arrays.asList(
- new SleepState()
- .withName("sleepState")
- .withType(SLEEP)
- .withEnd(new End())
- .withDuration("PT1M")));
-
- WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
- List validationErrors = workflowValidator.setWorkflow(workflow).validate();
- Assertions.assertNotNull(validationErrors);
- Assertions.assertEquals(1, validationErrors.size());
- Assertions.assertEquals(
- "No state name found that matches the workflow start definition",
- validationErrors.get(0).getMessage());
- }
-
- @Test
- public void testWorkflowMissingStates() {
- WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
- List validationErrors =
- workflowValidator
- .setSource(
- "{\n"
- + "\t\"id\": \"testwf\",\n"
- + "\t\"name\": \"test workflow\",\n"
- + " \"version\": \"1.0\",\n"
- + " \"start\": \"SomeState\",\n"
- + " \"states\": []\n"
- + "}")
- .validate();
- Assertions.assertNotNull(validationErrors);
- Assertions.assertEquals(1, validationErrors.size());
-
- Assertions.assertEquals("No states found", validationErrors.get(0).getMessage());
- }
-
- @Test
- public void testWorkflowMissingStatesIdAndKey() {
- WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
- List validationErrors =
- workflowValidator
- .setSource(
- "{\n"
- + "\t\"name\": \"test workflow\",\n"
- + " \"version\": \"1.0\",\n"
- + " \"start\": \"SomeState\",\n"
- + " \"states\": []\n"
- + "}")
- .validate();
- Assertions.assertNotNull(validationErrors);
- Assertions.assertEquals(1, validationErrors.size());
-
- Assertions.assertEquals(
- "$: required property 'id' not found", validationErrors.get(0).getMessage());
- }
-
- @Test
- public void testOperationStateNoFunctionRef() {
- WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
- List validationErrors =
- workflowValidator
- .setSource(
- "{\n"
- + "\"id\": \"checkInbox\",\n"
- + "\"name\": \"Check Inbox Workflow\",\n"
- + "\"description\": \"Periodically Check Inbox\",\n"
- + "\"version\": \"1.0\",\n"
- + "\"start\": \"CheckInbox\",\n"
- + "\"functions\": [\n"
- + "\n"
- + "],\n"
- + "\"states\": [\n"
- + " {\n"
- + " \"name\": \"CheckInbox\",\n"
- + " \"type\": \"operation\",\n"
- + " \"actionMode\": \"sequential\",\n"
- + " \"actions\": [\n"
- + " {\n"
- + " \"functionRef\": {\n"
- + " \"refName\": \"checkInboxFunction\"\n"
- + " }\n"
- + " }\n"
- + " ],\n"
- + " \"transition\": {\n"
- + " \"nextState\": \"SendTextForHighPrioriry\"\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"name\": \"SendTextForHighPrioriry\",\n"
- + " \"type\": \"foreach\",\n"
- + " \"inputCollection\": \"${ .message }\",\n"
- + " \"iterationParam\": \"${ .singlemessage }\",\n"
- + " \"end\": {\n"
- + " \"kind\": \"default\"\n"
- + " }\n"
- + " }\n"
- + "]\n"
- + "}")
- .validate();
-
- Assertions.assertNotNull(validationErrors);
- Assertions.assertEquals(1, validationErrors.size());
-
- Assertions.assertEquals(
- "State action 'null' functionRef does not reference an existing workflow function definition",
- validationErrors.get(0).getMessage());
- }
-
- @Test
- public void testValidateWorkflowForOptionalStartStateAndWorkflowName() {
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withVersion("1.0")
- .withStates(
- Arrays.asList(
- new SleepState()
- .withName("sleepState")
- .withType(SLEEP)
- .withEnd(new End())
- .withDuration("PT1M")));
-
- WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
- List validationErrors = workflowValidator.setWorkflow(workflow).validate();
- Assertions.assertNotNull(validationErrors);
- Assertions.assertEquals(0, validationErrors.size());
- }
-
- @Test
- public void testValidateWorkflowForOptionalIterationParam() {
- WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
- List validationErrors =
- workflowValidator
- .setSource(
- "{\n"
- + "\"id\": \"checkInbox\",\n"
- + " \"name\": \"Check Inbox Workflow\",\n"
- + "\"description\": \"Periodically Check Inbox\",\n"
- + "\"version\": \"1.0\",\n"
- + "\"start\": \"CheckInbox\",\n"
- + "\"functions\": [\n"
- + "\n"
- + "],\n"
- + "\"states\": [\n"
- + " {\n"
- + " \"name\": \"CheckInbox\",\n"
- + " \"type\": \"operation\",\n"
- + " \"actionMode\": \"sequential\",\n"
- + " \"actions\": [\n"
- + " {\n"
- + " \"functionRef\": {\n"
- + " \"refName\": \"checkInboxFunction\"\n"
- + " }\n"
- + " }\n"
- + " ],\n"
- + " \"transition\": {\n"
- + " \"nextState\": \"SendTextForHighPrioriry\"\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"name\": \"SendTextForHighPrioriry\",\n"
- + " \"type\": \"foreach\",\n"
- + " \"inputCollection\": \"${ .message }\",\n"
- + " \"end\": {\n"
- + " \"kind\": \"default\"\n"
- + " }\n"
- + " }\n"
- + "]\n"
- + "}")
- .validate();
-
- Assertions.assertNotNull(validationErrors);
- Assertions.assertEquals(
- 1,
- validationErrors.size()); // validation error raised for functionref not for iterationParam
- }
-
- @Test
- public void testMissingFunctionRefForCallbackState() {
- WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
- List validationErrors =
- workflowValidator
- .setSource(
- "{\n"
- + " \"id\": \"callbackstatemissingfuncref\",\n"
- + " \"version\": \"1.0\",\n"
- + " \"specVersion\": \"0.8\",\n"
- + " \"name\": \"Callback State Test\",\n"
- + " \"start\": \"CheckCredit\",\n"
- + " \"states\": [\n"
- + " {\n"
- + " \"name\": \"CheckCredit\",\n"
- + " \"type\": \"callback\",\n"
- + " \"action\": {\n"
- + " \"functionRef\": {\n"
- + " \"refName\": \"callCreditCheckMicroservice\",\n"
- + " \"arguments\": {\n"
- + " \"customer\": \"${ .customer }\"\n"
- + " }\n"
- + " }\n"
- + " },\n"
- + " \"eventRef\": \"CreditCheckCompletedEvent\",\n"
- + " \"timeouts\": {\n"
- + " \"stateExecTimeout\": \"PT15M\"\n"
- + " },\n"
- + " \"end\": true\n"
- + " }\n"
- + " ]\n"
- + "}")
- .validate();
-
- Assertions.assertNotNull(validationErrors);
- Assertions.assertEquals(2, validationErrors.size());
- Assertions.assertEquals(
- "CallbackState event ref does not reference a defined workflow event definition",
- validationErrors.get(0).getMessage());
- Assertions.assertEquals(
- "CallbackState action function ref does not reference a defined workflow function definition",
- validationErrors.get(1).getMessage());
- }
-
- @Test
- void testFunctionCall() {
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withVersion("1.0")
- .withStart(new Start().withStateName("start"))
- .withFunctions(
- new Functions(
- Arrays.asList(new FunctionDefinition("expression").withType(Type.EXPRESSION))))
- .withStates(
- Arrays.asList(
- new OperationState()
- .withName("start")
- .withType(OPERATION)
- .withActions(
- Arrays.asList(
- new Action().withFunctionRef(new FunctionRef("expression"))))
- .withEnd(new End())));
- Assertions.assertTrue(new WorkflowValidatorImpl().setWorkflow(workflow).validate().isEmpty());
- }
-
- @Test
- void testEventCall() {
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withVersion("1.0")
- .withStart(new Start().withStateName("start"))
- .withEvents(new Events(Arrays.asList(new EventDefinition().withName("event"))))
- .withRetries(new Retries(Arrays.asList(new RetryDefinition("start", "PT1S"))))
- .withStates(
- Arrays.asList(
- new OperationState()
- .withName("start")
- .withType(OPERATION)
- .withActions(
- Arrays.asList(
- new Action()
- .withEventRef(new EventRef().withTriggerEventRef("event"))))
- .withEnd(new End())));
- Assertions.assertTrue(new WorkflowValidatorImpl().setWorkflow(workflow).validate().isEmpty());
- }
-
- /**
- * @see Validation missing out
- * on refname in foreach>actions
- */
- @Test
- void testActionDefForEach() {
- Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withVersion("1.0")
- .withStart(new Start().withStateName("TestingForEach"))
- .withFunctions(new Functions(Arrays.asList(new FunctionDefinition("Test"))))
- .withStates(
- Arrays.asList(
- new ForEachState()
- .withName("TestingForEach")
- .withInputCollection("${ .archives }")
- .withIterationParam("archive")
- .withOutputCollection("${ .output}")
- .withActions(
- Arrays.asList(
- new Action()
- .withName("callFn")
- .withFunctionRef(new FunctionRef("DoesNotExist"))))
- .withEnd(new End())));
- final List validationErrors =
- new WorkflowValidatorImpl().setWorkflow(workflow).validate();
- Assertions.assertEquals(1, validationErrors.size());
- Assertions.assertEquals(
- "State action 'callFn' functionRef does not reference an existing workflow function definition",
- validationErrors.get(0).getMessage());
- }
-
- /**
- * @see Retry definition
- * validation doesn't work
- */
- @Test
- public void testValidateRetry() {
- WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
- List validationErrors =
- workflowValidator
- .setSource(
- "{\n"
- + " \"id\": \"workflow_1\",\n"
- + " \"name\": \"workflow_1\",\n"
- + " \"description\": \"workflow_1\",\n"
- + " \"version\": \"1.0\",\n"
- + " \"specVersion\": \"0.8\",\n"
- + " \"start\": \"Task1\",\n"
- + " \"functions\": [\n"
- + " {\n"
- + " \"name\": \"increment\",\n"
- + " \"type\": \"custom\",\n"
- + " \"operation\": \"worker\"\n"
- + " }\n"
- + " ],\n"
- + " \"retries\": [\n"
- + " {\n"
- + " \"maxAttempts\": 3\n"
- + " },\n"
- + " {\n"
- + " \"name\": \"testRetry\" \n"
- + " }\n"
- + " ],\n"
- + " \"states\": [\n"
- + " {\n"
- + " \"name\": \"Task1\",\n"
- + " \"type\": \"operation\",\n"
- + " \"actionMode\": \"sequential\",\n"
- + " \"actions\": [\n"
- + " {\n"
- + " \"functionRef\": {\n"
- + " \"refName\": \"increment\",\n"
- + " \"arguments\": {\n"
- + " \"input\": \"some text\"\n"
- + " }\n"
- + " },\n"
- + " \"retryRef\": \"const\",\n"
- + " \"actionDataFilter\": {\n"
- + " \"toStateData\": \"${ .result }\"\n"
- + " }\n"
- + " }\n"
- + " ],\n"
- + " \"end\": true\n"
- + " }\n"
- + " ]\n"
- + "}")
- .validate();
-
- Assertions.assertNotNull(validationErrors);
- Assertions.assertEquals(2, validationErrors.size());
- Assertions.assertEquals("Retry name should not be empty", validationErrors.get(0).getMessage());
- Assertions.assertEquals(
- "Operation State action 'null' retryRef does not reference an existing workflow retry definition",
- validationErrors.get(1).getMessage());
- }
-
- /**
- * @see WorkflowValidator
- * validate Wrokflow.tojson(workflow) failed
- */
- @Test
- void testErrorsArrayParsing() {
- final Workflow workflow =
- new Workflow()
- .withId("test-workflow")
- .withName("test-workflow")
- .withVersion("1.0")
- .withStart(new Start().withStateName("testingErrors"))
- .withErrors(new Errors(Arrays.asList(new ErrorDefinition())))
- .withStates(
- Arrays.asList(
- new InjectState()
- .withName("testingErrors")
- .withData(new ObjectMapper().createObjectNode().put("name", "Skywalker"))
- .withEnd(new End())));
- Assertions.assertTrue(
- new WorkflowValidatorImpl().setSource(Workflow.toJson(workflow)).isValid());
- }
-
- /**
- * @see Error parsing Oauth
- * properties in cncf spec using java sdk
- */
- @Test
- void testOAuthPropertiesDefinition() {
- final Workflow workflow =
- Workflow.fromSource(
- "{\n"
- + " \"version\": \"1.0.0\",\n"
- + " \"id\": \"greeting-workflow\", \n"
- + " \"specVersion\": \"0.8\",\n"
- + " \"name\": \"greeting-workflow\",\n"
- + " \"description\": \"Greet Someone\",\n"
- + " \"start\": \"greet\",\n"
- + " \"auth\": [\n"
- + " {\n"
- + " \"name\": \"serviceCloud\",\n"
- + " \"scheme\": \"oauth2\",\n"
- + " \"properties\": {\n"
- + " \"scopes\": [\"$$$$XXXMMMMM\"],\n"
- + " \"audiences\": [\"%%%XXXXXXX\"],\n"
- + " \"clientId\": \"whatever\",\n"
- + " \"grantType\": \"password\"\n"
- + " }\n"
- + " }\n"
- + " ],\n"
- + " \"functions\": [\n"
- + " {\n"
- + " \"name\": \"greeting-function\",\n"
- + " \"type\": \"rest\",\n"
- + " \"operation\": \"file://myapis/greetingapis.json#greeting\"\n"
- + " }\n"
- + " ],\n"
- + " \"states\": [\n"
- + " {\n"
- + " \"name\": \"greet\",\n"
- + " \"type\": \"operation\",\n"
- + " \"actions\": [\n"
- + " {\n"
- + " \"name\": \"greet-action\",\n"
- + " \"functionRef\": {\n"
- + " \"refName\": \"greeting-function\",\n"
- + " \"arguments\": {\n"
- + " \"name\": \"${ .person.name }\"\n"
- + " }\n"
- + " },\n"
- + " \"actionDataFilter\": {\n"
- + " \"results\": \"${ {greeting: .greeting} }\"\n"
- + " }\n"
- + " }\n"
- + " ],\n"
- + " \"end\": true\n"
- + " }\n"
- + " ]\n"
- + "}\n");
- final List validationErrors =
- new WorkflowValidatorImpl().setWorkflow(workflow).validate();
-
- Assertions.assertTrue(validationErrors.isEmpty());
- }
-}