private Processor<SchemaContext, ValidatorList> buildProcessor() { final RefResolver resolver = new RefResolver(loader); final Map<JsonRef, Library> libraries = validationCfg.getLibraries(); final Library defaultLibrary = validationCfg.getDefaultLibrary(); final ValidationChain defaultChain = new ValidationChain(resolver, defaultLibrary, validationCfg); final ProcessorMap<JsonRef, SchemaContext, ValidatorList> map = new ProcessorMap<JsonRef, SchemaContext, ValidatorList>(FUNCTION); map.setDefaultProcessor(defaultChain); JsonRef ref; ValidationChain chain; for (final Map.Entry<JsonRef, Library> entry: libraries.entrySet()) { ref = entry.getKey(); chain = new ValidationChain(resolver, entry.getValue(), validationCfg); map.addEntry(ref, chain); } final Processor<SchemaContext, ValidatorList> processor = map.getProcessor(); return new CachingProcessor<SchemaContext, ValidatorList>(processor, SchemaContextEquivalence.getInstance(), validationCfg.getCacheSize()); } }
ref = nodeAsRef(node); if (ref == null) break;
@Test public void refLoopsAreReported() { final ObjectNode node = JacksonUtils.nodeFactory().objectNode(); node.put("$ref", "#"); final SchemaTree tree = new CanonicalSchemaTree(SchemaKey.anonymousKey(), node); final ValueHolder<SchemaTree> holder = ValueHolder.hold("schema", tree); try { processor.process(report, holder); fail("No exception thrown!"); } catch (ProcessingException e) { assertMessage(e.getProcessingMessage()) .hasMessage(BUNDLE.printf("refProcessing.refLoop", "#")); } }
ref = nodeAsRef(node); if (ref == null) break;
@Test public void danglingRefsAreReported() { final ObjectNode node = JacksonUtils.nodeFactory().objectNode(); node.put("$ref", "#/a"); final SchemaTree tree = new CanonicalSchemaTree(SchemaKey.anonymousKey(), node); final ValueHolder<SchemaTree> holder = ValueHolder.hold("schema", tree); try { processor.process(report, holder); fail("No exception thrown!"); } catch (ProcessingException e) { assertMessage(e.getProcessingMessage()) .hasMessage(BUNDLE.printf("refProcessing.danglingRef", "#/a")); } } }
ref = nodeAsRef(node); if (ref == null) break;