diff --git a/serverless-workflow-examples/serverless-workflow-error-quarkus/src/main/resources/errorWithMetadata.sw.json b/serverless-workflow-examples/serverless-workflow-error-quarkus/src/main/resources/errorWithMetadata.sw.json new file mode 100644 index 0000000000..7a7a9551e9 --- /dev/null +++ b/serverless-workflow-examples/serverless-workflow-error-quarkus/src/main/resources/errorWithMetadata.sw.json @@ -0,0 +1,18 @@ +{ + "id": "errorWithMetadata", + "version": "1.0", + "name": "Workflow Error example with metadata", + "description": "An example of how to abort a workflow with error given a condition", + "start": "checkEven", + "states": [ + { + "name": "checkEven", + "type": "operation", + "actions": [], + "end" : true, + "metadata": { + "errorMessage": "if .number % 2 != 0 then \"Is Odd number!!!!\" else null end" + } + } + ] +} diff --git a/serverless-workflow-examples/serverless-workflow-error-quarkus/src/test/java/org/kie/kogito/examples/ErrorRestIT.java b/serverless-workflow-examples/serverless-workflow-error-quarkus/src/test/java/org/kie/kogito/examples/ErrorRestIT.java index a1225c0962..099437d6c3 100644 --- a/serverless-workflow-examples/serverless-workflow-error-quarkus/src/test/java/org/kie/kogito/examples/ErrorRestIT.java +++ b/serverless-workflow-examples/serverless-workflow-error-quarkus/src/test/java/org/kie/kogito/examples/ErrorRestIT.java @@ -56,4 +56,25 @@ public void testErrorRest() { .statusCode(201) .body("workflowdata.numberType", is("even")); } + + @Test + public void testErrorWithMetadata() { + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body("{\"number\" : 12342}") + .when() + .post("/errorWithMetadata") + .then() + .statusCode(201); + + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body("{\"number\" : 12341}") + .when() + .post("/errorWithMetadata") + .then() + .statusCode(400); + } }