### Question:
JsonValidationServiceImpl implements IJsonValidationService { @Override public Set<ValidationMessage> validate(JsonNode schema, JsonNode toValidate) { try { return getFactory() .getSchema(schema) .validate(toValidate); } catch (JsonSchemaException e) { throw new ServerErrorException( String.format("Error creating json validation schema from json object: %s", schema), e); } }  @Override Set<ValidationMessage> validate(JsonNode schema, JsonNode toValidate);  }### Answer:
@Test void shouldValidateObjectByProvidedSchema() throws Exception { JsonNode schema = objectMapper.readTree(getResource(DRAFT_07_SCHEMA_PATH)); JsonNode object = objectMapper.readTree("{}"); Throwable thrown = catchThrowable(() -> jsonValidationService.validate(schema, object)); then(thrown).isNull(); }
@Test void shouldThrownExceptionWhenUnableToValidateBySchema() throws Exception { JsonNode schema = objectMapper.readTree(getResource(DRAFT_06_SCHEMA_PATH)); JsonNode object = objectMapper.readTree("{}"); Throwable thrown = catchThrowable(() -> jsonValidationService.validate(schema, object)); then(thrown) .isInstanceOf(ServerErrorException.class) .hasMessageMatching("Error creating json validation schema from json object: (.*)"); }