@Override public ProcessingMessage newMessage() { return context.newMessage(); } }
/** * Return a new full data with another schema * * @param schema the schema * @return a new full data instance */ public FullData withSchema(final SchemaTree schema) { return new FullData(schema, instance, deepCheck); }
@Override protected boolean doEquivalent(final SchemaContext a, final SchemaContext b) { return a.getSchema().equals(b.getSchema()) && a.getInstanceType() == b.getInstanceType(); }
public SchemaContext(final FullData data) { schema = data.getSchema(); final JsonTree tree = data.getInstance(); instanceType = tree != null ? NodeType.getNodeType(tree.getNode()) : null; }
@Override public SchemaDigest process(final ProcessingReport report, final SchemaContext input) throws ProcessingException { final JsonNode schema = input.getSchema().getNode(); final NodeType type = input.getInstanceType(); final Map<String, JsonNode> map = Maps.newHashMap(buildDigests(schema)); map.keySet().retainAll(typeMap.get(type)); return new SchemaDigest(input, map); }
@Override public FullData process(final ProcessingReport report, final FullData input) throws ProcessingException { final JsonNode schema = input.getSchema().getNode(); final JsonPointer ptr = schema == sub1 ? ptr1 : ptr2; assertEquals(input.getSchema().getPointer(), ptr, "schema pointer differs from expectations"); final WantedState wanted = schema == sub1 ? wanted1 : wanted2; wanted.doIt(report); return input; } }
/** * Return a new message for this format attribute * * @param data the validation context * @param key key in the format bundle message * @return a new message */ protected final ProcessingMessage newMsg(final FullData data, final MessageBundle bundle, final String key) { return data.newMessage().put("domain", "validation") .put("keyword", "format").put("attribute", fmt) .setMessage(bundle.getMessage(key)) .put("value", data.getInstance().getNode()); } }
@Test public void attributeIsBeingAskedWhatIsSupports() throws ProcessingException { final ObjectNode schema = FACTORY.objectNode(); schema.put("format", FMT); final SchemaTree tree = new CanonicalSchemaTree(SchemaKey.anonymousKey(), schema); final SchemaContext context = new SchemaContext(tree, NodeType.NULL); final ValidatorList in = new ValidatorList(context, Collections.<KeywordValidator>emptyList()); processor.process(report, in); verify(attribute).supportedTypes(); }
@Override public final void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final JsonNode instance = data.getInstance().getNode(); if (valueIsLong(instance) && isLong) validateLong(report, bundle, data); else validateDecimal(report, bundle, data); }
protected final ProcessingMessage newMsg(final FullData data) { return data.newMessage().put("domain", "validation") .put("keyword", keyword) .setExceptionProvider(EXCEPTION_PROVIDER); }
@Override public JsonRef apply(final SchemaContext input) { return input.getSchema().getDollarSchema(); } };
@Override public FullData process(final ProcessingReport report, final FullData input) throws ProcessingException { assertEquals(input.getSchema().getPointer(), PTR); wanted.doIt(report, message); return input; } }
/** * Return a new full data with another instance * * @param instance the new instance * @return a new full data instance */ public FullData withInstance(final JsonTree instance) { return new FullData(schema, instance, deepCheck); }
@Override protected int doHash(final SchemaContext t) { return t.getSchema().hashCode() ^ t.getInstanceType().hashCode(); } }
@Override public ProcessingMessage newMessage() { return context.newMessage(); } }
protected final ProcessingMessage newMsg(final FullData data, final MessageBundle bundle, final String key) { return data.newMessage().put("domain", "validation") .put("keyword", keyword).setMessage(bundle.getMessage(key)) .setExceptionProvider(EXCEPTION_PROVIDER); }
@Override public FullData process(final ProcessingReport report, final FullData input) throws ProcessingException { assertEquals(input.getSchema().getPointer(), PTR); wanted.doIt(report); return input; } }
private FullData buildData(final JsonNode schema, final JsonNode instance, final boolean deepCheck) { BUNDLE.checkNotNull(schema, "nullSchema"); BUNDLE.checkNotNull(instance, "nullInstance"); final SchemaTree schemaTree = loader.load(schema); final JsonTree tree = new SimpleJsonTree(instance); return new FullData(schemaTree, tree, deepCheck); } }
private ProcessingReport doValidateUnchecked(final JsonNode node, final boolean deepCheck) { final FullData data = new FullData(schema, new SimpleJsonTree(node), deepCheck); final ProcessingReport report = reportProvider.newReport(); final ProcessingResult<FullData> result = ProcessingResult.uncheckedResult(processor, report, data); return result.getReport(); }
private ProcessingReport doValidate(final JsonNode node, final boolean deepCheck) throws ProcessingException { final FullData data = new FullData(schema, new SimpleJsonTree(node), deepCheck); final ProcessingReport report = reportProvider.newReport(); final ProcessingResult<FullData> result = ProcessingResult.of(processor, report, data); return result.getReport(); }