diff options
Diffstat (limited to 'src/test/java/org/onap/dcae/restapi/EventValidatorTest.java')
-rw-r--r-- | src/test/java/org/onap/dcae/restapi/EventValidatorTest.java | 18 |
1 files changed, 9 insertions, 9 deletions
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<ResponseEntity<String>> generateResponseOptional(ApiException schemaValidationFailed) { |