use of org.leadpony.justify.api.JsonSchema in project tcases by Cornutum.
the class GeneratorSetJsonReader method getGeneratorSet.
/**
* Returns a {@link IGeneratorSet} instance.
*/
@Override
public IGeneratorSet getGeneratorSet() {
JsonValidationService service = JsonValidationService.newInstance();
JsonSchema schema = service.readSchema(getClass().getResourceAsStream("/schema/generators-schema.json"));
ProblemHandler handler = ProblemHandler.throwing();
try (JsonReader reader = service.createReader(stream_, schema, handler)) {
JsonObject json;
try {
json = reader.readObject();
} catch (Exception e) {
throw new GeneratorSetException("Invalid generator set definition", e);
}
return GeneratorSetJson.asGeneratorSet(json);
}
}
use of org.leadpony.justify.api.JsonSchema in project tcases by Cornutum.
the class SystemTestJsonReader method getSystemTestDef.
/**
* Returns a {@link SystemTestDef} instance.
*/
@Override
public SystemTestDef getSystemTestDef() {
JsonValidationService service = JsonValidationService.newInstance();
JsonSchema schema = service.readSchema(getClass().getResourceAsStream("/schema/system-test-schema.json"));
ProblemHandler handler = ProblemHandler.throwing();
try (JsonReader reader = service.createReader(stream_, schema, handler)) {
JsonObject json;
try {
json = reader.readObject();
} catch (Exception e) {
throw new SystemTestException("Invalid system test definition", e);
}
return SystemTestJson.asSystemTestDef(json);
}
}
Aggregations