From 92c756717cacf458874e5699e5b9856fd875c128 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Thu, 24 Aug 2023 18:37:09 +0200 Subject: [PATCH] Helbers comments Co-authored-by: Helber Belmiro --- .../serverless/workflow/parser/JsonSchemaReader.java | 5 ++--- .../serverless/workflow/io/URIContentLoaderTest.java | 7 +++---- .../workflow/executor/OpenAPIWorkflowApplicationTest.java | 3 +-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java index 2766430e38d..81025966de1 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java @@ -27,7 +27,6 @@ import org.kie.kogito.serverless.workflow.io.URIContentLoaderFactory; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import static org.kie.kogito.serverless.workflow.utils.ServerlessWorkflowUtils.DEFS_PREFIX; @@ -56,7 +55,7 @@ public JsonSchema(ObjectNode node, Counter counter) { private static String getId(JsonNode schemaContent, Counter counter) { JsonNode title = schemaContent.get("title"); - return title != null ? title.asText() + "_" + Integer.toString(counter.next()) : "nested_" + Integer.toString(counter.next()); + return title != null ? title.asText() + "_" + counter.next() : "nested_" + counter.next(); } } @@ -88,7 +87,7 @@ private static JsonNode fillDefs(Map schemas) { private static void replaceRefsWithDefs(JsonNode node, URI baseURI, Map schemas, Counter counter) { if (node.isArray()) { - ((ArrayNode) node).elements().forEachRemaining(n -> replaceRefsWithDefs(n, baseURI, schemas, counter)); + node.elements().forEachRemaining(n -> replaceRefsWithDefs(n, baseURI, schemas, counter)); } else if (node.isObject()) { ObjectNode objectNode = (ObjectNode) node; JsonNode refNode = objectNode.get("$ref"); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java index 5650fc21628..7cda2d978b1 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java @@ -15,7 +15,6 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.io.IOException; import java.io.UncheckedIOException; import java.net.URI; import java.net.URISyntaxException; @@ -33,13 +32,13 @@ class URIContentLoaderTest { @Test - void testExistingFile() throws IOException, URISyntaxException { + void testExistingFile() throws URISyntaxException { assertThat(readString(builder(Thread.currentThread().getContextClassLoader().getResource("pepe.txt").toURI()))).isEqualTo("my name is javierito"); } @Test - void testExistingClasspath() throws IOException { - assertThat(new String(readString(builder("classpath:pepe.txt")))).isEqualTo("my name is javierito"); + void testExistingClasspath() { + assertThat(readString(builder("classpath:pepe.txt"))).isEqualTo("my name is javierito"); } @Test diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-executor-tests/src/test/java/org/kie/kogito/serverless/workflow/executor/OpenAPIWorkflowApplicationTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-executor-tests/src/test/java/org/kie/kogito/serverless/workflow/executor/OpenAPIWorkflowApplicationTest.java index 3cc4c396859..d501b0aeb4a 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-executor-tests/src/test/java/org/kie/kogito/serverless/workflow/executor/OpenAPIWorkflowApplicationTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-executor-tests/src/test/java/org/kie/kogito/serverless/workflow/executor/OpenAPIWorkflowApplicationTest.java @@ -16,7 +16,6 @@ package org.kie.kogito.serverless.workflow.executor; import java.io.IOException; -import java.net.URISyntaxException; import java.net.URL; import java.util.Collections; @@ -57,7 +56,7 @@ static void cleanup() { } @Test - void openAPIInvocation() throws IOException, URISyntaxException { + void openAPIInvocation() throws IOException { final double fahrenheit = 100; final double difference = fahrenheit - 32.0; final double product = difference * 0.5556;