From e7839705f6847bba2eb6923685c2f87edfe6982a Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Tue, 30 Apr 2024 19:08:54 +0200 Subject: [PATCH] [Fix #3475] Adding end metadata usage example --- .../main/resources/errorWithMetadata.sw.json | 18 ++++++++++++++++ .../org/kie/kogito/examples/ErrorRestIT.java | 21 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 serverless-workflow-examples/serverless-workflow-error-quarkus/src/main/resources/errorWithMetadata.sw.json 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); + } }