From 7e5a7d1d8cd74e42c8549e02724ec2df589e4117 Mon Sep 17 00:00:00 2001 From: Pawel Date: Fri, 20 Dec 2019 09:56:29 +0100 Subject: updated jackson-databind and changed json schema validator library Issue-ID: DCAEGEN2-1825 Signed-off-by: Pawel Change-Id: Ia4c9c6286adcf84631a58f9d5bfef124fed1cee6 --- .../java/org/onap/dcae/restapi/EventValidatorTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/test/java/org/onap/dcae/restapi') diff --git a/src/test/java/org/onap/dcae/restapi/EventValidatorTest.java b/src/test/java/org/onap/dcae/restapi/EventValidatorTest.java index 5bacd31c..4ac3c487 100644 --- a/src/test/java/org/onap/dcae/restapi/EventValidatorTest.java +++ b/src/test/java/org/onap/dcae/restapi/EventValidatorTest.java @@ -20,9 +20,8 @@ package org.onap.dcae.restapi; -import com.github.fge.jackson.JsonLoader; -import com.github.fge.jsonschema.core.exceptions.ProcessingException; -import com.github.fge.jsonschema.main.JsonSchemaFactory; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaFactory; import org.json.JSONObject; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -84,7 +83,7 @@ public class EventValidatorTest { } @Test - public void shouldReturnSchemaValidationFailedErrorOnInvalidJsonObjectSchema() throws ProcessingException, IOException { + public void shouldReturnSchemaValidationFailedErrorOnInvalidJsonObjectSchema() throws IOException { //given String schemaRejectingEverything = "{\"not\":{}}"; mockJsonSchema(schemaRejectingEverything); @@ -98,7 +97,7 @@ public class EventValidatorTest { } @Test - public void shouldReturnEmptyOptionalOnValidJsonObjectSchema() throws ProcessingException, IOException { + public void shouldReturnEmptyOptionalOnValidJsonObjectSchema() throws IOException { //given String schemaAcceptingEverything = "{}"; mockJsonSchema(schemaAcceptingEverything); @@ -111,10 +110,11 @@ public class EventValidatorTest { assertEquals(Optional.empty(), result); } - private void mockJsonSchema(String jsonSchema) throws IOException, ProcessingException { - when(settings.jsonSchema(any())).thenReturn( - JsonSchemaFactory.byDefault() - .getJsonSchema(JsonLoader.fromString(jsonSchema))); + private void mockJsonSchema(String jsonSchemaContent) { + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(); + + JsonSchema schema = factory.getSchema(jsonSchemaContent); + when(settings.jsonSchema(any())).thenReturn(schema); } private Optional> generateResponseOptional(ApiException schemaValidationFailed) { -- cgit 1.2.3-korg