public ValidatorBuilder( final Dictionary<KeywordValidatorFactory> dict) { factories = dict.entries(); }
/** * No-arg constructor providing an empty library builder */ LibraryBuilder() { syntaxCheckers = Dictionary.newBuilder(); digesters = Dictionary.newBuilder(); validators = Dictionary.newBuilder(); formatAttributes = Dictionary.newBuilder(); }
/** * 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(); }
/** * Build an immutable dictionary out of this builder * * @return a new {@link Dictionary} with all elements from this builder */ @Override public Dictionary<T> freeze() { return new Dictionary<T>(this); } }
/** * Build an immutable dictionary out of this builder * * @return a new {@link Dictionary} with all elements from this builder */ @Override public Dictionary<T> freeze() { return new Dictionary<T>(this); } }
@VisibleForTesting FormatProcessor(final Dictionary<FormatAttribute> dict) { attributes = dict.entries(); bundle = MessageBundles.getBundle(JsonSchemaValidationBundle.class); }
/** * Build an immutable dictionary out of this builder * * @return a new {@link Dictionary} with all elements from this builder */ @Override public Dictionary<T> freeze() { return new Dictionary<T>(this); } }
@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); }
public SchemaDigester(final Dictionary<Digester> dict) { String keyword; Digester digester; final Map<String, Digester> map = dict.entries(); for (final Map.Entry<String, Digester> entry: map.entrySet()) { keyword = entry.getKey(); digester = entry.getValue(); digesterMap.put(keyword, digester); for (final NodeType type: digester.supportedTypes()) typeMap.put(type, keyword); } }
@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()); }
public ValidatorBuilder(final Library library) { factories = library.getValidators().entries(); }
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()); }
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; }
@BeforeMethod public void createBuilder() { builder = Dictionary.newBuilder(); }
public FormatProcessor(final Library library, final ValidationConfiguration cfg) { attributes = library.getFormatAttributes().entries(); bundle = cfg.getValidationMessages(); }
@BeforeMethod public void initialize() { report = spy(new TestProcessingReport()); final DictionaryBuilder<SyntaxChecker> builder = Dictionary.newBuilder(); checker = mock(SyntaxChecker.class); builder.addEntry(K1, checker); builder.addEntry(K2, new SyntaxChecker() { @Override public EnumSet<NodeType> getValidTypes() { return EnumSet.noneOf(NodeType.class); } @Override public void checkSyntax(final Collection<JsonPointer> pointers, final MessageBundle bundle, final ProcessingReport report, final SchemaTree tree) throws ProcessingException { report.error(new ProcessingMessage().setMessage(ERRMSG)); } }); processor = new SyntaxProcessor(BUNDLE, builder.freeze()); }
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); }
protected AbstractDigesterTest(final Dictionary<Digester> dict, final String prefix, final String keyword, final NodeType first, final NodeType... other) throws IOException { digester = dict.entries().get(keyword); types = EnumSet.of(first, other); this.keyword = keyword; final String resourceName = String.format("/keyword/digest/%s/%s.json", prefix, keyword); data = JsonLoader.fromResource(resourceName); }
public PatternKeywordTest() throws IOException { factory = CommonValidatorDictionary.get().entries().get("pattern"); testData = JsonLoader.fromResource("/keyword/special/pattern.json"); }