From b8c49fd30e2e660198d29e599a0ccecf184b2071 Mon Sep 17 00:00:00 2001 From: "adheli.tavares" Date: Fri, 19 Jul 2024 11:51:37 +0100 Subject: Uplift of json schema validator library Issue-ID: POLICY-5084 Change-Id: Ie24719570c43a9f7b0fdac28973cc50d8eb7ed2c Signed-off-by: adheli.tavares --- .../context/schema/json/JsonSchemaHelperMarshalTest.java | 4 +--- .../context/schema/json/JsonSchemaHelperUnmarshalTest.java | 10 ++++------ 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java') diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java index b129330ce..413037b97 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java @@ -26,7 +26,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.worldturner.medeia.api.ValidationFailedException; import java.util.ArrayList; import java.util.Map; import org.junit.jupiter.api.Test; @@ -103,8 +102,7 @@ class JsonSchemaHelperMarshalTest extends CommonTestData { var dataAsObject = coder.decode(COMMONHEADER, Map.class); dataAsObject.remove(TEST_ID); assertThatThrownBy(() -> validateAndMarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject, true)) - .isInstanceOf(ValidationFailedException.class) - .hasMessageContaining("Required property testId is missing from object"); + .hasMessageContaining("required property 'testId' not found"); } /** diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java index d0059f26f..f633b2d0f 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java @@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import com.google.gson.JsonObject; -import com.worldturner.medeia.api.ValidationFailedException; import java.util.ArrayList; import java.util.Map; import org.junit.jupiter.api.Test; @@ -74,7 +73,8 @@ class JsonSchemaHelperUnmarshalTest extends CommonTestData { new AxContextSchema(new AxArtifactKey("JsonObject", VERSION), JSON, schemaDef); var jsonSchemaHelper = new JsonSchemaHelper(); assertThatThrownBy(() -> jsonSchemaHelper.init(testKey, jsonSchema)) - .isInstanceOf(ContextRuntimeException.class).hasMessageContaining("schema is invalid"); + .isInstanceOf(ContextRuntimeException.class) + .hasMessageContaining("schema is invalid"); } /** @@ -111,8 +111,7 @@ class JsonSchemaHelperUnmarshalTest extends CommonTestData { var dataAsObject = coder.decode(COMMONHEADER, JsonObject.class); dataAsObject.addProperty("requestId", "abcd"); assertThatThrownBy(() -> validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject)) - .isInstanceOf(ValidationFailedException.class) - .hasMessageContaining("Pattern ^[0-9]*-[0-9]*$ is not contained in text"); + .hasMessageContaining("does not match the regex pattern ^[0-9]*-[0-9]*$"); } /** @@ -137,8 +136,7 @@ class JsonSchemaHelperUnmarshalTest extends CommonTestData { var dataAsObject = coder.decode(COMMONHEADER, JsonObject.class); dataAsObject.remove(TEST_ID); assertThatThrownBy(() -> validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject)) - .isInstanceOf(ValidationFailedException.class) - .hasMessageContaining("Required property testId is missing from object"); + .hasMessageContaining("required property 'testId' not found"); } /** -- cgit