/** * Tell whether a schema is valid * * @param schema the schema * @return true if the schema is valid */ public boolean schemaIsValid(final JsonNode schema) { final ProcessingReport report = new DevNullProcessingReport(); return getResult(schema, report).isSuccess(); }
@Test public void successIsCorrectlyReported() throws ProcessingException { when(report.isSuccess()).thenReturn(true); final ProcessingResult<Out> result = ProcessingResult.of(processor, report, null); assertTrue(result.isSuccess()); }
@Test public void failureIsCorrectlyReported() throws ProcessingException { when(report.isSuccess()).thenReturn(false); final ProcessingResult<Out> result = ProcessingResult.of(processor, report, null); assertFalse(result.isSuccess()); }
@Test public void uncheckedReportCorrectlyReportsException() throws ProcessingException { final ProcessingException exception = new ProcessingException(MSG); when(processor.process(anyReport(), any(In.class))) .thenThrow(exception); when(report.iterator()) .thenReturn(Iterators.<ProcessingMessage>emptyIterator()); final ProcessingResult<Out> result = ProcessingResult.uncheckedResult(processor, report, input); assertFalse(result.isSuccess()); final ProcessingReport r = result.getReport(); final List<ProcessingMessage> list = Lists.newArrayList(r); assertFalse(list.isEmpty()); final ProcessingMessage message = list.get(0); assertMessage(message).hasMessage(MSG).hasLevel(LogLevel.FATAL); }