From d316319e38ce45a3010030c23d2fc537dde09a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Moraes=20Lopes?= Date: Thu, 22 Aug 2024 19:40:49 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20Use=20extra=20single=20value=20enum=20wh?= =?UTF-8?q?ere=20const=20is=20used=20due=20to=20lack=20of=20support=20from?= =?UTF-8?q?=20jsonschema2pojo=20Signed-off-by:=20Vin=C3=ADcius=20Moraes=20?= =?UTF-8?q?Lopes=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/src/main/resources/schema/workflow.yaml | 8 ++++++-- .../io/serverlessworkflow/api/ApiTest.java | 19 +++++++++++++++++++ .../test/resources/features/callFunction.yaml | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 api/src/test/resources/features/callFunction.yaml diff --git a/api/src/main/resources/schema/workflow.yaml b/api/src/main/resources/schema/workflow.yaml index 86e33868..bba84e95 100644 --- a/api/src/main/resources/schema/workflow.yaml +++ b/api/src/main/resources/schema/workflow.yaml @@ -202,6 +202,7 @@ $defs: call: type: string const: asyncapi + enum: [asyncapi] with: type: object title: AsyncApiArguments @@ -247,6 +248,7 @@ $defs: call: type: string const: grpc + enum: [grpc] with: type: object title: GRPCArguments @@ -301,7 +303,8 @@ $defs: properties: call: type: string - const: http + const: http + enum: [http] with: type: object title: HTTPArguments @@ -350,6 +353,7 @@ $defs: call: type: string const: openapi + enum: [openapi] with: type: object title: OpenAPIArguments @@ -1351,4 +1355,4 @@ $defs: type: string title: RuntimeExpression description: A runtime expression. - pattern: "^\\s*\\$\\{.+\\}\\s*$" \ No newline at end of file + pattern: "^\\s*\\$\\{.+\\}\\s*$" diff --git a/api/src/test/java/io/serverlessworkflow/api/ApiTest.java b/api/src/test/java/io/serverlessworkflow/api/ApiTest.java index ac5f7532..0a32173d 100644 --- a/api/src/test/java/io/serverlessworkflow/api/ApiTest.java +++ b/api/src/test/java/io/serverlessworkflow/api/ApiTest.java @@ -18,6 +18,7 @@ import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath; import static org.assertj.core.api.Assertions.assertThat; +import io.serverlessworkflow.api.types.CallFunction; import io.serverlessworkflow.api.types.CallHTTP; import io.serverlessworkflow.api.types.CallTask; import io.serverlessworkflow.api.types.Task; @@ -27,6 +28,24 @@ public class ApiTest { + @Test + void testCallFunctionAPIWithoutArguments() throws IOException { + Workflow workflow = readWorkflowFromClasspath("features/callFunction.yaml"); + assertThat(workflow.getDo()).isNotEmpty(); + assertThat(workflow.getDo().get(0).getName()).isNotNull(); + assertThat(workflow.getDo().get(0).getTask()).isNotNull(); + Task task = workflow.getDo().get(0).getTask(); + CallTask callTask = task.getCallTask(); + assertThat(callTask).isNotNull(); + assertThat(callTask.get()).isInstanceOf(CallFunction.class); + if (callTask.get() instanceof CallFunction) { + CallFunction functionCall = callTask.getCallFunction(); + assertThat(functionCall).isNotNull(); + assertThat(callTask.getCallAsyncAPI()).isNull(); + assertThat(functionCall.getWith()).isNull(); + } + } + @Test void testCallHTTPAPI() throws IOException { Workflow workflow = readWorkflowFromClasspath("features/callHttp.yaml"); diff --git a/api/src/test/resources/features/callFunction.yaml b/api/src/test/resources/features/callFunction.yaml new file mode 100644 index 00000000..695ad25c --- /dev/null +++ b/api/src/test/resources/features/callFunction.yaml @@ -0,0 +1,18 @@ +document: + dsl: 1.0.0-alpha1 + namespace: default + name: http-call-with-response-output + +use: + functions: + getPet: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} + output: response + +do: + - getPetFunctionCall: + call: getPet