/** * No-arg constructor providing an empty library builder */ LibraryBuilder() { syntaxCheckers = Dictionary.newBuilder(); digesters = Dictionary.newBuilder(); validators = Dictionary.newBuilder(); formatAttributes = Dictionary.newBuilder(); }
public ValidatorBuilder( final Dictionary<KeywordValidatorFactory> dict) { factories = dict.entries(); }
/** * Constructor from an already existing library * * @param library the library * @see Library#thaw() */ LibraryBuilder(final Library library) { syntaxCheckers = library.syntaxCheckers.thaw(); digesters = library.digesters.thaw(); validators = library.validators.thaw(); formatAttributes = library.formatAttributes.thaw(); }
public ValidatorBuilderTest() throws NoSuchMethodException { final DictionaryBuilder<KeywordValidatorFactory> builder = Dictionary.newBuilder(); KeywordValidatorFactory factory; factory = new ReflectionKeywordValidatorFactory(K1, Keyword1.class); builder.addEntry(K1, factory); factory = new ReflectionKeywordValidatorFactory(K2, Keyword2.class); builder.addEntry(K2, factory); factory = new ReflectionKeywordValidatorFactory(CHALLENGED, Challenged.class); builder.addEntry(CHALLENGED, factory); validatorBuilder = new ValidatorBuilder(builder.freeze()); }
private static String getCwd() throws IOException { final File cwd = new File(System.getProperty("user.dir", ".")) .getCanonicalFile(); return URIUtils.normalizeURI(cwd.toURI()).toString(); } }
private static ValueHolder<SchemaTree> holder(final JsonNode node) { return ValueHolder.<SchemaTree>hold("schema", new CanonicalSchemaTree(SchemaKey.anonymousKey(), node)); } }
/** * Remove a keyword by its name * * @param name the name * @return this * @throws NullPointerException name is null */ public LibraryBuilder removeKeyword(final String name) { BUNDLE.checkNotNull(name, "nullName"); syntaxCheckers.removeEntry(name); digesters.removeEntry(name); validators.removeEntry(name); return this; }
/** * Constructor from a library builder * * @param builder the builder * @see LibraryBuilder#freeze() */ Library(final LibraryBuilder builder) { syntaxCheckers = builder.syntaxCheckers.freeze(); digesters = builder.digesters.freeze(); validators = builder.validators.freeze(); formatAttributes = builder.formatAttributes.freeze(); }
public ValidatorBuilder(final Library library) { factories = library.getValidators().entries(); }
@BeforeMethod public void init() { attribute = mock(FormatAttribute.class); when(attribute.supportedTypes()).thenReturn(SUPPORTED); report = mock(ProcessingReport.class); final Dictionary<FormatAttribute> dictionary = Dictionary.<FormatAttribute>newBuilder().addEntry(FMT, attribute) .freeze(); processor = new FormatProcessor(dictionary); }
@Override protected int doHash(final ValueHolder<SchemaTree> t) { return t.getValue().hashCode(); } }
/** * Remove a format attribute by its name * * @param name the format attribute name * @return this * @throws NullPointerException name is null */ public LibraryBuilder removeFormatAttribute(final String name) { BUNDLE.checkNotNull(name, "nullFormat"); formatAttributes.removeEntry(name); return this; }
@VisibleForTesting FormatProcessor(final Dictionary<FormatAttribute> dict) { attributes = dict.entries(); bundle = MessageBundles.getBundle(JsonSchemaValidationBundle.class); }
@BeforeMethod public void setupDigesters() { final DictionaryBuilder<Digester> builder = Dictionary.newBuilder(); digester1 = mock(Digester.class); when(digester1.digest(any(JsonNode.class))).thenReturn(digest1); when(digester1.supportedTypes()).thenReturn(TYPES1); builder.addEntry(K1, digester1); digester2 = mock(Digester.class); when(digester2.digest(any(JsonNode.class))).thenReturn(digest2); when(digester2.supportedTypes()).thenReturn(TYPES2); builder.addEntry(K2, digester2); schemaDigester = new SchemaDigester(builder.freeze()); }
@Override public JsonRef apply(final ValueHolder<SchemaTree> input) { return input.getValue().getDollarSchema(); } };
protected CallbackValidatorTest( final Dictionary<KeywordValidatorFactory> dict, final String keyword, final JsonPointer ptr1, final JsonPointer ptr2) { this.keyword = keyword; factory = dict.entries().get(keyword); this.ptr1 = ptr1; this.ptr2 = ptr2; }
public FormatProcessor(final Library library, final ValidationConfiguration cfg) { attributes = library.getFormatAttributes().entries(); bundle = cfg.getValidationMessages(); }
protected AbstractKeywordValidatorTest( final Dictionary<KeywordValidatorFactory> dict, final String prefix, final String keyword) throws IOException { this.keyword = keyword; factory = dict.entries().get(keyword); final String resourceName = String.format("/keyword/validators/%s/%s.json", prefix, keyword); testNode = JsonLoader.fromResource(resourceName); }
protected AbstractFormatAttributeTest( final Dictionary<FormatAttribute> dict, final String prefix, final String fmt) throws IOException { final String resourceName = String.format("/format/%s/%s.json", prefix, fmt); this.fmt = fmt; testNode = JsonLoader.fromResource(resourceName); attribute = dict.entries().get(fmt); }