use of org.leadpony.justify.api.JsonValidatingException in project selenium_java by sergueik.
the class Validate method validateSchemaAt.
/**
* Reads and validates a JSON schema.
*
* @param location the location of the JSON schema to be read and validated.
* @return the schema read if successful, or {@code null} if errors occcured.
*/
private JsonSchema validateSchemaAt(Location location) {
JsonSchemaReaderFactory factory = createSchemaReaderFactory();
try (JsonSchemaReader reader = factory.createSchemaReader(openSchema(location))) {
JsonSchema schema = reader.read();
console.withColor(Color.SUCCESS).print(SCHEMA_VALID, location);
return schema;
} catch (JsonValidatingException e) {
List<Problem> problems = e.getProblems();
problemPrinter.handleProblems(problems);
console.withColor(Color.DANGER).print(SCHEMA_INVALID, location, Problems.countLeast(problems));
setStatus(Status.INVALID);
return null;
} catch (JsonParsingException e) {
console.withColor(Color.DANGER).print(SCHEMA_MALFORMED, e);
setStatus(Status.INVALID);
return null;
} catch (JsonException e) {
throw new CommandException(e);
}
}
Aggregations