@Override public ProcessingMessage newMessage() { final ProcessingMessage ret = new ProcessingMessage(); if (schema != null) ret.put("schema", schema); if (instance != null) ret.put("instance", instance); return ret; } }
protected final ProcessingMessage newMsg(final FullData data) { return data.newMessage().put("domain", "validation") .put("keyword", keyword) .setExceptionProvider(EXCEPTION_PROVIDER); }
@Override void doIt(final ProcessingReport report, final ProcessingMessage message) throws ProcessingException { report.error(message); } },
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final SchemaTree tree = data.getSchema(); final ProcessingReport subReport = new ListProcessingReport(report.getLogLevel(), LogLevel.FATAL); processor.process(subReport, data.withSchema(tree.append(PTR))); if (subReport.isSuccess()) report.error(newMsg(data, bundle, "err.draftv4.not.fail")); }
/** * {@inheritDoc} */ @Override public boolean validInstanceUnchecked(final JsonNode instance) { return doValidateUnchecked(instance, false).isSuccess(); } }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final int size = data.getInstance().getNode().size(); if (size > intValue) report.error(newMsg(data, bundle, "err.draftv4.maxProperties.tooManyMembers") .putArgument("found", size).putArgument("required", intValue)); } }
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); }
public void describeTo(Description description) { if (report != null) { description.appendText("The content to match the given JSON schema.\n"); List<ProcessingMessage> messages = Lists.newArrayList(report); if (!messages.isEmpty()) { for (final ProcessingMessage message : messages) description.appendText(message.toString()); } } }
/** * {@inheritDoc} */ @Override public boolean validInstance(final JsonNode instance) throws ProcessingException { return doValidate(instance, false).isSuccess(); }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final int size = data.getInstance().getNode().size(); if (size > intValue) report.error(newMsg(data, bundle, "err.common.maxItems.arrayTooLarge") .putArgument(keyword, intValue).putArgument("found", size)); } }
@Override void doIt(final ProcessingReport report) throws ProcessingException { report.error(MSG); } },
@Override public ProcessingMessage newMessage() { return new ProcessingMessage().put("schema", schema); } }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final int size = data.getInstance().getNode().size(); if (size < intValue) report.error(newMsg(data, bundle, "err.common.minItems.arrayTooShort") .putArgument(keyword, intValue).putArgument("found", size)); } }
@Override void doIt(final ProcessingReport report) throws ProcessingException { report.error(MSG); } },
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final JsonNode node = data.getInstance().getNode(); for (final JsonNode enumValue: values) if (EQUIVALENCE.equivalent(enumValue, node)) return; report.error(newMsg(data, bundle, "err.common.enum.notInEnum") .putArgument("value", node).putArgument(keyword, values)); }
@Override protected void checkKoKo(final ProcessingReport report) throws ProcessingException { verify(report, times(2)).error(same(MSG)); }
@Override protected void checkOkOk(final ProcessingReport report) throws ProcessingException { verify(report, never()).error(anyMessage()); }
@Override protected void checkOkOk(final ProcessingReport report) throws ProcessingException { verify(report, never()).error(anyMessage()); }
@Override protected void checkKoKo(final ProcessingReport report) throws ProcessingException { verify(report, never()).error(anyMessage()); }
@Override protected void checkOkKo(final ProcessingReport report) throws ProcessingException { verify(report, onlyOnce()).error(anyMessage()); }