/** * Validate the given resource is a valid json schema. * * @param schemaResourceName * @throws ProcessingException * @throws IOException */ public void validateSchema(String schemaResourceName) throws ProcessingException, IOException { JsonUtils.loadSchema(schemaResourceName); }
/** * Validate the given resource is a valid json schema. * * @param schemaResourceName * @throws ProcessingException * @throws IOException */ public void validateSchema(String schemaResourceName) throws ProcessingException, IOException { JsonUtils.loadSchema(schemaResourceName); }
/** * Validate the given resource is a valid json schema. * * @param schemaResourceName * @throws ProcessingException * @throws IOException */ public void validateSchema(String schemaResourceName) throws ProcessingException, IOException { JsonUtils.loadSchema(schemaResourceName); }
/** * Registers a translation * * @param clazz The POJO class that will be returned when a JSON * document of this type is parsed * @param fromJson The implementation of FromJson interface that * performs the actual parsing * @param resource The resource name in class path containing the schema */ public void registerTranslation(Class clazz,FromJson fromJson, String resource) { try { registerTranslation(clazz,fromJson,JsonUtils.loadSchema(resource)); } catch (Exception e) { throw new IllegalArgumentException(resource,e); } }
/** * Registers a translation * * @param clazz The POJO class that will be returned when a JSON document of * this type is parsed * @param fromJson The implementation of FromJson interface that performs * the actual parsing * @param resource The resource name in class path containing the schema */ public void registerTranslation(Class clazz, FromJson fromJson, String resource) { try { registerTranslation(clazz, fromJson, JsonUtils.loadSchema(resource)); } catch (Exception e) { throw new IllegalArgumentException(resource, e); } }
/** * Registers a translation * * @param clazz The POJO class that will be returned when a JSON document of * this type is parsed * @param fromJson The implementation of FromJson interface that performs * the actual parsing * @param resource The resource name in class path containing the schema */ public void registerTranslation(Class clazz, FromJson fromJson, String resource) { try { registerTranslation(clazz, fromJson, JsonUtils.loadSchema(resource)); } catch (Exception e) { throw new IllegalArgumentException(resource, e); } }
/** * Verify the given document validates against the given schema. * * @param schemaResourceName * @param documentResourceName * @throws IOException * @throws ProcessingException */ public void runValidJsonTest(String schemaResourceName, String documentResourceName) throws IOException, ProcessingException { JsonSchema schema = JsonUtils.loadSchema(schemaResourceName); JsonNode instance = loadJsonNode(documentResourceName); // if report isn't null it's a failure and the value of report is the detail of why String report = JsonUtils.jsonSchemaValidation(schema, instance); if (report != null) { Assert.fail("Expected validation to succeed! Resource: " + documentResourceName + " Messages: " + report.replaceAll("\n", " ")); } } }
/** * Verify the given document validates against the given schema. * * @param schemaResourceName * @param documentResourceName * @throws IOException * @throws ProcessingException */ public void runValidJsonTest(String schemaResourceName, String documentResourceName) throws IOException, ProcessingException { JsonSchema schema = JsonUtils.loadSchema(schemaResourceName); JsonNode instance = loadJsonNode(documentResourceName); // if report isn't null it's a failure and the value of report is the detail of why String report = JsonUtils.jsonSchemaValidation(schema, instance); if (report != null) { Assert.fail("Expected validation to succeed! Resource: " + documentResourceName + " Messages: " + report.replaceAll("\n", " ")); } } }
/** * Verify the given document validates against the given schema. * * @param schemaResourceName * @param documentResourceName * @throws IOException * @throws ProcessingException */ public void runValidJsonTest(String schemaResourceName, String documentResourceName) throws IOException, ProcessingException { JsonSchema schema = JsonUtils.loadSchema(schemaResourceName); JsonNode instance = loadJsonNode(documentResourceName); // if report isn't null it's a failure and the value of report is the detail of why String report = JsonUtils.jsonSchemaValidation(schema, instance); Assert.assertTrue("Expected validation to succeed!\nResource: " + documentResourceName + "\nMessages:\n" + report, report == null); } }
/** * Verify the given document does not validate against the given schema. * * @param schemaResourceName * @param documentResourceName * @throws IOException * @throws ProcessingException */ public void runInvalidJsonTest(String schemaResourceName, String documentResourceName) throws IOException, ProcessingException { JsonSchema schema = JsonUtils.loadSchema(schemaResourceName); JsonNode instance = loadJsonNode(documentResourceName); ProcessingReport report = schema.validate(instance); Assert.assertFalse("Expected validation to fail!", report.isSuccess()); }
/** * Verify the given document does not validate against the given schema. * * @param schemaResourceName * @param documentResourceName * @throws IOException * @throws ProcessingException */ public void runInvalidJsonTest(String schemaResourceName, String documentResourceName) throws IOException, ProcessingException { JsonSchema schema = JsonUtils.loadSchema(schemaResourceName); JsonNode instance = loadJsonNode(documentResourceName); ProcessingReport report = schema.validate(instance); Assert.assertFalse("Expected validation to fail!", report.isSuccess()); }
/** * Verify the given document does not validate against the given schema. * * @param schemaResourceName * @param documentResourceName * @throws IOException * @throws ProcessingException */ public void runInvalidJsonTest(String schemaResourceName, String documentResourceName) throws IOException, ProcessingException { JsonSchema schema = JsonUtils.loadSchema(schemaResourceName); JsonNode instance = loadJsonNode(documentResourceName); ProcessingReport report = schema.validate(instance); Assert.assertFalse("Expected validation to fail!", report.isSuccess()); }