diff --git a/api/src/main/java/io/github/sebastiantoepfer/jsonschema/JsonSchemas.java b/api/src/main/java/io/github/sebastiantoepfer/jsonschema/JsonSchemas.java index 68fecd04..88fde387 100644 --- a/api/src/main/java/io/github/sebastiantoepfer/jsonschema/JsonSchemas.java +++ b/api/src/main/java/io/github/sebastiantoepfer/jsonschema/JsonSchemas.java @@ -32,8 +32,7 @@ public final class JsonSchemas { - private static final JsonSchemaFactory JSONSCHEMA_FACTORY = ServiceLoader - .load(JsonSchemaFactory.class) + private static final JsonSchemaFactory JSONSCHEMA_FACTORY = ServiceLoader.load(JsonSchemaFactory.class) .findFirst() .orElseThrow(); diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonObjectSchema.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonObjectSchema.java index 433e3f4e..60d88282 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonObjectSchema.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonObjectSchema.java @@ -62,8 +62,7 @@ private Stream keywords() { @Override public Optional asSubSchema(final String name) { - return Optional - .ofNullable(asJsonObject().get(name)) + return Optional.ofNullable(asJsonObject().get(name)) .flatMap(new DefaultJsonSchemaFactory()::tryToCreateSchemaFrom) .map(subSchema -> new DefaultJsonSubSchema(this, subSchema)); } diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonSubSchema.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonSubSchema.java index 7747e81d..a147356a 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonSubSchema.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonSubSchema.java @@ -77,8 +77,10 @@ private Stream keywords() { final Stream result; if (isJsonObject()) { final Keywords keywords = new KeywordExtractor(schema).createKeywords(); - result = - asJsonObject().keySet().stream().map(propertyName -> keywords.createKeywordFor(this, propertyName)); + result = asJsonObject() + .keySet() + .stream() + .map(propertyName -> keywords.createKeywordFor(this, propertyName)); } else { result = Stream.empty(); } @@ -91,8 +93,7 @@ private boolean isJsonObject() { @Override public Optional asSubSchema(final String name) { - return Optional - .ofNullable(asJsonObject().get(name)) + return Optional.ofNullable(asJsonObject().get(name)) .flatMap(new DefaultJsonSchemaFactory()::tryToCreateSchemaFrom) .map(subSchema -> new DefaultJsonSubSchema(this, subSchema)); } diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordBasedValidator.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordBasedValidator.java index 7e7f4b0e..448aca65 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordBasedValidator.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordBasedValidator.java @@ -40,12 +40,11 @@ final class KeywordBasedValidator implements Validator { private final DefaultValidator validator; public KeywordBasedValidator(final Collection keywords) { - this.validator = - keywords - .stream() - .map(KeywordBasedValidator::asContraint) - .flatMap(Optional::stream) - .collect(collectingAndThen(toList(), constraints -> new DefaultValidator(new AllOf<>(constraints)))); + this.validator = keywords + .stream() + .map(KeywordBasedValidator::asContraint) + .flatMap(Optional::stream) + .collect(collectingAndThen(toList(), constraints -> new DefaultValidator(new AllOf<>(constraints)))); } @Override diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordExtractor.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordExtractor.java index 670ef102..e2502334 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordExtractor.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordExtractor.java @@ -44,11 +44,10 @@ public Keywords createKeywords() { if ( schema.getValueType() == JsonValue.ValueType.OBJECT && schema.asJsonObject().containsKey(keywordType.name()) ) { - result = - keywordType - .createKeyword(schema) - .definitions() - .collect(Collectors.collectingAndThen(Collectors.toList(), Keywords::new)); + result = keywordType + .createKeyword(schema) + .definitions() + .collect(Collectors.collectingAndThen(Collectors.toList(), Keywords::new)); } else { result = new Keywords(List.of()); } diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/Keywords.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/Keywords.java index e26f5aa5..8ee64c12 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/Keywords.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/Keywords.java @@ -50,11 +50,9 @@ final class Keywords { private static final Collection DEFAULT_VOCABS; static { - MANDANTORY_VOCABS = - List - .of(new BasicVocabulary(), new CoreVocabulary(JsonProvider.provider())) - .stream() - .collect(toMap(Vocabulary::id, Function.identity())); + MANDANTORY_VOCABS = List.of(new BasicVocabulary(), new CoreVocabulary(JsonProvider.provider())) + .stream() + .collect(toMap(Vocabulary::id, Function.identity())); DEFAULT_VOCABS = List.of(new ValidationVocabulary(JsonProvider.provider()), new ApplicatorVocabulary()); } @@ -70,19 +68,16 @@ public Keywords(final Collection vocabDefs) { ) { throw new IllegalArgumentException("can not be created without core vocabulary is requiered!"); } - vocabularies = - Stream - .concat( - Stream.concat(MANDANTORY_VOCABS.values().stream(), DEFAULT_VOCABS.stream()), - vocabDefs.stream().map(VocabularyDefinition::findVocabulary).flatMap(Optional::stream) - ) - .collect( - Collector.of( - ArrayDeque::new, - ArrayDeque::addFirst, - (first, last) -> null //pitest otherwise see mutants here :( - ) - ); + vocabularies = Stream.concat( + Stream.concat(MANDANTORY_VOCABS.values().stream(), DEFAULT_VOCABS.stream()), + vocabDefs.stream().map(VocabularyDefinition::findVocabulary).flatMap(Optional::stream) + ).collect( + Collector.of( + ArrayDeque::new, + ArrayDeque::addFirst, + (first, last) -> null //pitest otherwise see mutants here :( + ) + ); } public Keyword createKeywordFor(final JsonSchema schema, final String propertyName) { diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordType.java index 52c59a60..a08a0764 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordType.java @@ -65,8 +65,7 @@ private Keyword createKeyword(final JsonObject schema) { new JsonPropertyWhichFulfilThe( jsonContext.createPointer(String.format("/%s", name)), new PredicateCondition<>(InstanceType.BOOLEAN::isInstance) - ) - .isFulfilledBy(schema) + ).isFulfilledBy(schema) ) { return keywordCreator.apply(schema.getBoolean(name)); } else { diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordType.java index 47df5e5a..704443ae 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordType.java @@ -67,8 +67,7 @@ private Keyword createKeyword(final JsonObject asJsonObject) { new JsonPropertyWhichFulfilThe( createJsonPointer(), new PredicateCondition<>(InstanceType.INTEGER::isInstance) - ) - .isFulfilledBy(asJsonObject) + ).isFulfilledBy(asJsonObject) ) { return keywordCreator.apply(asJsonObject.getJsonNumber(name).bigIntegerValueExact()); } else { diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordType.java index 03a1d477..bc6f5d13 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordType.java @@ -66,8 +66,7 @@ private Keyword createKeyword(final JsonObject schema) { new JsonPropertyWhichFulfilThe( jsonContext.createPointer(String.format("/%s", name)), new PredicateCondition<>(InstanceType.NUMBER::isInstance) - ) - .isFulfilledBy(schema) + ).isFulfilledBy(schema) ) { return keywordCreator.apply(schema.getJsonNumber(name).bigDecimalValue()); } else { diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordType.java index 97c0a2e1..de873921 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordType.java @@ -82,8 +82,7 @@ private Keyword createKeyword(final JsonObject schema) { JsonValue::asJsonArray ) ) - ) - .isFulfilledBy(schema) + ).isFulfilledBy(schema) ) { return schema .getJsonArray(name) diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordType.java index ad79bc9a..64c2bc26 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordType.java @@ -66,8 +66,7 @@ private Keyword createKeyword(final JsonObject obj) { new JsonPropertyWhichFulfilThe( createJsonPointer(), new PredicateCondition<>(InstanceType.STRING::isInstance) - ) - .isFulfilledBy(obj) + ).isFulfilledBy(obj) ) { return keywordCreator.apply(obj.getString(name())); } else { diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/OfficialVocabularies.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/OfficialVocabularies.java index 10160e9b..306bde21 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/OfficialVocabularies.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/OfficialVocabularies.java @@ -44,16 +44,15 @@ public final class OfficialVocabularies implements LazyVocabularies { private static final Collection OFFICEAL_VOCABS; static { - OFFICEAL_VOCABS = - List.of( - new CoreVocabulary(JSONP), - new ApplicatorVocabulary(), - new ValidationVocabulary(JSONP), - new MetaDataVocabulary(), - new FormatVocabulary(), - new UnevaluatedVocabulary(), - new ContentVocabulary() - ); + OFFICEAL_VOCABS = List.of( + new CoreVocabulary(JSONP), + new ApplicatorVocabulary(), + new ValidationVocabulary(JSONP), + new MetaDataVocabulary(), + new FormatVocabulary(), + new UnevaluatedVocabulary(), + new ContentVocabulary() + ); } @Override diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/AdditionalPropertiesKeyword.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/AdditionalPropertiesKeyword.java index f4fdbc4e..85714078 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/AdditionalPropertiesKeyword.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/AdditionalPropertiesKeyword.java @@ -97,11 +97,10 @@ private Stream> findPropertiesForValidation(final J } private Collection findPropertyNamesAlreadyConveredByOthersIn(final JsonValue instance) { - return Stream - .of( - additionalPropertiesSchema.owner().keywordByName("properties"), - additionalPropertiesSchema.owner().keywordByName("patternProperties") - ) + return Stream.of( + additionalPropertiesSchema.owner().keywordByName("properties"), + additionalPropertiesSchema.owner().keywordByName("patternProperties") + ) .flatMap(Optional::stream) .map(Keyword::asAnnotation) .map(anno -> anno.valueFor(instance)) diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ApplicatorVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ApplicatorVocabulary.java index 7db9bf94..1690b2af 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ApplicatorVocabulary.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ApplicatorVocabulary.java @@ -44,15 +44,14 @@ public final class ApplicatorVocabulary implements Vocabulary { private final Vocabulary vocab; public ApplicatorVocabulary() { - this.vocab = - new DefaultVocabulary( - URI.create("https://json-schema.org/draft/2020-12/vocab/applicator"), - new NamedJsonSchemaKeywordType(PropertiesKeyword.NAME, PropertiesKeyword::new), - new SubSchemaKeywordType(AdditionalPropertiesKeyword.NAME, AdditionalPropertiesKeyword::new), - new NamedJsonSchemaKeywordType(PatternPropertiesKeyword.NAME, PatternPropertiesKeyword::new), - new SubSchemaKeywordType(ItemsKeyword.NAME, ItemsKeyword::new), - new ArraySubSchemaKeywordType(PrefixItemsKeyword.NAME, PrefixItemsKeyword::new) - ); + this.vocab = new DefaultVocabulary( + URI.create("https://json-schema.org/draft/2020-12/vocab/applicator"), + new NamedJsonSchemaKeywordType(PropertiesKeyword.NAME, PropertiesKeyword::new), + new SubSchemaKeywordType(AdditionalPropertiesKeyword.NAME, AdditionalPropertiesKeyword::new), + new NamedJsonSchemaKeywordType(PatternPropertiesKeyword.NAME, PatternPropertiesKeyword::new), + new SubSchemaKeywordType(ItemsKeyword.NAME, ItemsKeyword::new), + new ArraySubSchemaKeywordType(PrefixItemsKeyword.NAME, PrefixItemsKeyword::new) + ); } @Override diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeyword.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeyword.java index 93b86331..8cdb9ed5 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeyword.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeyword.java @@ -66,12 +66,11 @@ class PatternPropertiesKeyword implements Applicator, Annotation { private final Map properties; public PatternPropertiesKeyword(final NamedJsonSchemas properties) { - this.properties = - properties - .schemas() - .stream() - .map(e -> Map.entry(Pattern.compile(e.getKey()), e.getValue())) - .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); + this.properties = properties + .schemas() + .stream() + .map(e -> Map.entry(Pattern.compile(e.getKey()), e.getValue())) + .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); } @Override diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabulary.java index e7ec3822..26673186 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabulary.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabulary.java @@ -37,21 +37,20 @@ public final class CoreVocabulary implements Vocabulary { private final Vocabulary vocab; public CoreVocabulary(final JsonProvider jsonContext) { - this.vocab = - new DefaultVocabulary( - URI.create("https://json-schema.org/draft/2020-12/vocab/core"), - new StringKeywordType(jsonContext, SchemaKeyword.NAME, value -> new SchemaKeyword(URI.create(value))), - new StringKeywordType(jsonContext, IdKeyword.NAME, value -> new IdKeyword(URI.create(value))), - new RefKeywordType(jsonContext), - new NamedJsonSchemaKeywordType(DefsKeyword.NAME, DefsKeyword::new), - new StringKeywordType(jsonContext, CommentKeyword.NAME, CommentKeyword::new), - new VocabularyKeywordType(), - new StringKeywordType( - jsonContext, - DynamicRefKeyword.NAME, - value -> new DynamicRefKeyword(URI.create(value)) - ) - ); + this.vocab = new DefaultVocabulary( + URI.create("https://json-schema.org/draft/2020-12/vocab/core"), + new StringKeywordType(jsonContext, SchemaKeyword.NAME, value -> new SchemaKeyword(URI.create(value))), + new StringKeywordType(jsonContext, IdKeyword.NAME, value -> new IdKeyword(URI.create(value))), + new RefKeywordType(jsonContext), + new NamedJsonSchemaKeywordType(DefsKeyword.NAME, DefsKeyword::new), + new StringKeywordType(jsonContext, CommentKeyword.NAME, CommentKeyword::new), + new VocabularyKeywordType(), + new StringKeywordType( + jsonContext, + DynamicRefKeyword.NAME, + value -> new DynamicRefKeyword(URI.create(value)) + ) + ); } @Override diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/RefKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/RefKeywordType.java index b413ae57..dcff9353 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/RefKeywordType.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/RefKeywordType.java @@ -46,7 +46,10 @@ public String name() { @Override public Keyword createKeyword(final JsonSchema schema) { - return new StringKeywordType(jsonContext, RefKeyword.NAME, s -> new RefKeyword(schema, URI.create(s))) - .createKeyword(schema); + return new StringKeywordType( + jsonContext, + RefKeyword.NAME, + s -> new RefKeyword(schema, URI.create(s)) + ).createKeyword(schema); } } diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/EnumKeyword.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/EnumKeyword.java index 6e3acd81..7e531ae3 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/EnumKeyword.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/EnumKeyword.java @@ -64,14 +64,13 @@ public > T printOn(final T media) { public boolean isValidFor(final JsonValue instance) { final boolean result; if (InstanceType.NUMBER.isInstance(instance)) { - result = - allowedValues - .stream() - .filter(InstanceType.NUMBER::isInstance) - .map(JsonNumber.class::cast) - .map(JsonNumber::bigDecimalValue) - .map(BigDecimal::stripTrailingZeros) - .anyMatch(Predicate.isEqual(((JsonNumber) instance).bigDecimalValue().stripTrailingZeros())); + result = allowedValues + .stream() + .filter(InstanceType.NUMBER::isInstance) + .map(JsonNumber.class::cast) + .map(JsonNumber::bigDecimalValue) + .map(BigDecimal::stripTrailingZeros) + .anyMatch(Predicate.isEqual(((JsonNumber) instance).bigDecimalValue().stripTrailingZeros())); } else { result = allowedValues.stream().anyMatch(Predicate.isEqual(instance)); } diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ValidationVocabulary.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ValidationVocabulary.java index 4ddd52db..aaaa0bf7 100644 --- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ValidationVocabulary.java +++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ValidationVocabulary.java @@ -41,24 +41,23 @@ public final class ValidationVocabulary implements Vocabulary { private final Vocabulary vocab; public ValidationVocabulary(final JsonProvider jsonContext) { - this.vocab = - new DefaultVocabulary( - URI.create("https://json-schema.org/draft/2020-12/vocab/validation"), - new TypeKeywordType(), - new ArrayKeywordType(EnumKeyword.NAME, EnumKeyword::new), - new StringKeywordType(jsonContext, PatternKeyword.NAME, PatternKeyword::new), - new IntegerKeywordType(jsonContext, MinLengthKeyword.NAME, MinLengthKeyword::new), - new IntegerKeywordType(jsonContext, MaxLengthKeyword.NAME, MaxLengthKeyword::new), - new NumberKeywordType(jsonContext, ExclusiveMaximumKeyword.NAME, ExclusiveMaximumKeyword::new), - new NumberKeywordType(jsonContext, MultipleOfKeyword.NAME, MultipleOfKeyword::new), - new NumberKeywordType(jsonContext, ExclusiveMinimumKeyword.NAME, ExclusiveMinimumKeyword::new), - new NumberKeywordType(jsonContext, MaximumKeyword.NAME, MaximumKeyword::new), - new NumberKeywordType(jsonContext, MinimumKeyword.NAME, MinimumKeyword::new), - new StringArrayKeywordType(jsonContext, RequiredKeyword.NAME, RequiredKeyword::new), - new IntegerKeywordType(jsonContext, MaxItemsKeyword.NAME, MaxItemsKeyword::new), - new IntegerKeywordType(jsonContext, MinItemsKeyword.NAME, MinItemsKeyword::new), - new BooleanKeywordType(jsonContext, UniqueItemsKeyword.NAME, UniqueItemsKeyword::new) - ); + this.vocab = new DefaultVocabulary( + URI.create("https://json-schema.org/draft/2020-12/vocab/validation"), + new TypeKeywordType(), + new ArrayKeywordType(EnumKeyword.NAME, EnumKeyword::new), + new StringKeywordType(jsonContext, PatternKeyword.NAME, PatternKeyword::new), + new IntegerKeywordType(jsonContext, MinLengthKeyword.NAME, MinLengthKeyword::new), + new IntegerKeywordType(jsonContext, MaxLengthKeyword.NAME, MaxLengthKeyword::new), + new NumberKeywordType(jsonContext, ExclusiveMaximumKeyword.NAME, ExclusiveMaximumKeyword::new), + new NumberKeywordType(jsonContext, MultipleOfKeyword.NAME, MultipleOfKeyword::new), + new NumberKeywordType(jsonContext, ExclusiveMinimumKeyword.NAME, ExclusiveMinimumKeyword::new), + new NumberKeywordType(jsonContext, MaximumKeyword.NAME, MaximumKeyword::new), + new NumberKeywordType(jsonContext, MinimumKeyword.NAME, MinimumKeyword::new), + new StringArrayKeywordType(jsonContext, RequiredKeyword.NAME, RequiredKeyword::new), + new IntegerKeywordType(jsonContext, MaxItemsKeyword.NAME, MaxItemsKeyword::new), + new IntegerKeywordType(jsonContext, MinItemsKeyword.NAME, MinItemsKeyword::new), + new BooleanKeywordType(jsonContext, UniqueItemsKeyword.NAME, UniqueItemsKeyword::new) + ); } @Override diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/BasicVocabularyTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/BasicVocabularyTest.java index 8f5edbca..8088d908 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/BasicVocabularyTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/BasicVocabularyTest.java @@ -56,11 +56,12 @@ void should_return_the_custom_annotation_for_unknow_keyword() { assertThat( new BasicVocabulary() .findKeywordTypeByName("unknow") - .map(keywordType -> - keywordType.createKeyword( - new DefaultJsonSchemaFactory() - .create(Json.createObjectBuilder().add("unknow", JsonValue.FALSE).build()) - ) + .map( + keywordType -> + keywordType.createKeyword( + new DefaultJsonSchemaFactory() + .create(Json.createObjectBuilder().add("unknow", JsonValue.FALSE).build()) + ) ) .map(keyword -> keyword.hasName("unknow")), OptionalMatchers.isPresentAndIs(true) diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonObjectSchemaTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonObjectSchemaTest.java index 933ea289..dc638271 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonObjectSchemaTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonObjectSchemaTest.java @@ -41,8 +41,7 @@ class DefaultJsonObjectSchemaTest { private final DefaultJsonObjectSchema schema = new DefaultJsonObjectSchema( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("type", "array") .add("items", Json.createObjectBuilder().add("type", "integer")) .build() @@ -71,8 +70,7 @@ void should_be_invalid_for_object() { @Test void should_not_be_usable_without_mandantory_core_vocabulary() { final DefaultJsonObjectSchema invalidSchema = new DefaultJsonObjectSchema( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add( "$vocabulary", Json.createObjectBuilder().add("https://json-schema.org/draft/2020-12/vocab/core", false) @@ -87,15 +85,13 @@ void should_not_be_usable_without_mandantory_core_vocabulary() { void should_find_keyword_by_name() { assertThat( new DefaultJsonObjectSchema( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add( "$vocabulary", Json.createObjectBuilder().add("https://json-schema.org/draft/2020-12/vocab/core", true) ) .build() - ) - .keywordByName("$vocabulary"), + ).keywordByName("$vocabulary"), isPresent() ); } @@ -104,15 +100,13 @@ void should_find_keyword_by_name() { void should_return_empty_for_non_existing_keyword() { assertThat( new DefaultJsonObjectSchema( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add( "$vocabulary", Json.createObjectBuilder().add("https://json-schema.org/draft/2020-12/vocab/core", true) ) .build() - ) - .keywordByName("type"), + ).keywordByName("type"), isEmpty() ); } @@ -120,8 +114,9 @@ void should_return_empty_for_non_existing_keyword() { @Test void should_return_empty_if_non_subschema_exists_under_the_given_name() { assertThat( - new DefaultJsonObjectSchema(Json.createObjectBuilder().add("test", "hallo").build()) - .asSubSchema("properties"), + new DefaultJsonObjectSchema(Json.createObjectBuilder().add("test", "hallo").build()).asSubSchema( + "properties" + ), isEmpty() ); } @@ -129,8 +124,9 @@ void should_return_empty_if_non_subschema_exists_under_the_given_name() { @Test void should_return_subschema_if_subschema_exists_under_the_given_name() { assertThat( - new DefaultJsonObjectSchema(Json.createObjectBuilder().add("test", JsonValue.FALSE).build()) - .asSubSchema("test"), + new DefaultJsonObjectSchema(Json.createObjectBuilder().add("test", JsonValue.FALSE).build()).asSubSchema( + "test" + ), isPresent() ); } @@ -138,8 +134,9 @@ void should_return_subschema_if_subschema_exists_under_the_given_name() { @Test void should_return_empty_if_given_name_not_resolve_to_a_valid_schematype() { assertThat( - new DefaultJsonObjectSchema(Json.createObjectBuilder().add("test", JsonValue.EMPTY_JSON_ARRAY).build()) - .asSubSchema("test"), + new DefaultJsonObjectSchema( + Json.createObjectBuilder().add("test", JsonValue.EMPTY_JSON_ARRAY).build() + ).asSubSchema("test"), isEmpty() ); } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonSubSchemaTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonSubSchemaTest.java index 17b78ef4..73a9720d 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonSubSchemaTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/DefaultJsonSubSchemaTest.java @@ -57,8 +57,7 @@ void should_return_subschema() { new DefaultJsonSubSchema( owner, new DefaultJsonSchemaFactory().create(Json.createObjectBuilder().add("sub", JsonValue.TRUE).build()) - ) - .asSubSchema("sub"), + ).asSubSchema("sub"), isPresent() ); } @@ -73,8 +72,7 @@ void should_convertable_to_plain_jsonobject() { new DefaultJsonSubSchema( owner, new DefaultJsonSchemaFactory().create(Json.createObjectBuilder().add("sub", JsonValue.TRUE).build()) - ) - .asJsonObject(), + ).asJsonObject(), is(Json.createObjectBuilder().add("sub", JsonValue.TRUE).build()) ); } @@ -85,8 +83,7 @@ void should_return_empty_for_unknown_keyword() { new DefaultJsonSubSchema( new DefaultJsonSchemaFactory().create(Json.createObjectBuilder().add("test", JsonValue.TRUE).build()), new DefaultJsonSchemaFactory().create(Json.createObjectBuilder().add("type", "array").build()) - ) - .keywordByName("test"), + ).keywordByName("test"), isEmpty() ); } @@ -97,8 +94,7 @@ void should_return_known_keyword() { new DefaultJsonSubSchema( new DefaultJsonSchemaFactory().create(Json.createObjectBuilder().add("test", JsonValue.TRUE).build()), new DefaultJsonSchemaFactory().create(Json.createObjectBuilder().add("type", "array").build()) - ) - .keywordByName("type"), + ).keywordByName("type"), isPresent() ); } @@ -109,8 +105,7 @@ void should_be_printable() { new DefaultJsonSubSchema( new DefaultJsonSchemaFactory().create(Json.createObjectBuilder().add("test", JsonValue.TRUE).build()), new DefaultJsonSchemaFactory().create(Json.createObjectBuilder().add("type", "array").build()) - ) - .printOn(new HashMapMedia()), + ).printOn(new HashMapMedia()), hasEntry("type", "array") ); } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordTypeTest.java index 950a7fef..a02a6621 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordTypeTest.java @@ -67,8 +67,9 @@ static Stream invalidJsonValues() { @Test void should_create_keyword_from_strings() { assertThat( - new BooleanKeywordType(JsonProvider.provider(), "test", TestBooleanKeyword::new) - .createKeyword(JsonSchemas.load(Json.createObjectBuilder().add("test", true).build())), + new BooleanKeywordType(JsonProvider.provider(), "test", TestBooleanKeyword::new).createKeyword( + JsonSchemas.load(Json.createObjectBuilder().add("test", true).build()) + ), isA(TestBooleanKeyword.class) ); } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordTypeTest.java index 2f2d4b85..304350cf 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordTypeTest.java @@ -69,8 +69,9 @@ static Stream invalidJsonValues() { @Test void should_create_keyword_from_strings() { assertThat( - new IntegerKeywordType(JsonProvider.provider(), "test", TestIntegerKeyword::new) - .createKeyword(JsonSchemas.load(Json.createObjectBuilder().add("test", 12).build())), + new IntegerKeywordType(JsonProvider.provider(), "test", TestIntegerKeyword::new).createKeyword( + JsonSchemas.load(Json.createObjectBuilder().add("test", 12).build()) + ), isA(TestIntegerKeyword.class) ); } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordTypeTest.java index 4764eeae..27b11d59 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordTypeTest.java @@ -64,8 +64,9 @@ static Stream invalidJsonValues() { @Test void should_create_keyword_from_strings() { assertThat( - new NumberKeywordType(JsonProvider.provider(), "test", TestNumberKeyword::new) - .createKeyword(JsonSchemas.load(Json.createObjectBuilder().add("test", 12.1).build())), + new NumberKeywordType(JsonProvider.provider(), "test", TestNumberKeyword::new).createKeyword( + JsonSchemas.load(Json.createObjectBuilder().add("test", 12.1).build()) + ), isA(TestNumberKeyword.class) ); } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordTypeTest.java index 96c1b4ea..1e1642ea 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordTypeTest.java @@ -68,15 +68,11 @@ static Stream invalidJsonValues() { @Test void should_create_keyword_from_strings() { assertThat( - new StringArrayKeywordType(JsonProvider.provider(), "test", StringArrayKeyword::new) - .createKeyword( - JsonSchemas.load( - Json - .createObjectBuilder() - .add("test", Json.createArrayBuilder().add("test").add("hello")) - .build() - ) - ), + new StringArrayKeywordType(JsonProvider.provider(), "test", StringArrayKeyword::new).createKeyword( + JsonSchemas.load( + Json.createObjectBuilder().add("test", Json.createArrayBuilder().add("test").add("hello")).build() + ) + ), isA(StringArrayKeyword.class) ); } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordTypeTest.java index 9902e5b6..2145cc61 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordTypeTest.java @@ -64,8 +64,9 @@ static Stream invalidJsonValues() { @Test void should_create_keyword_from_strings() { assertThat( - new StringKeywordType(JsonProvider.provider(), "test", TestStringKeyword::new) - .createKeyword(JsonSchemas.load(Json.createObjectBuilder().add("test", "test").build())), + new StringKeywordType(JsonProvider.provider(), "test", TestStringKeyword::new).createKeyword( + JsonSchemas.load(Json.createObjectBuilder().add("test", "test").build()) + ), isA(TestStringKeyword.class) ); } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/DefaultSchemaLoadTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/DefaultSchemaLoadTest.java index 240bed97..2c149d11 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/DefaultSchemaLoadTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/DefaultSchemaLoadTest.java @@ -39,9 +39,9 @@ class DefaultSchemaLoadTest { void should_load_default_json_schema() throws Exception { assertThat( JsonSchemas.load( - Json - .createReader(URI.create("https://json-schema.org/draft/2020-12/schema").toURL().openStream()) - .readValue() + Json.createReader( + URI.create("https://json-schema.org/draft/2020-12/schema").toURL().openStream() + ).readValue() ), is(not(Matchers.nullValue())) ); diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/JsonTestSuiteTestCaseProvider.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/JsonTestSuiteTestCaseProvider.java index 4c1116bb..756b88b4 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/JsonTestSuiteTestCaseProvider.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/JsonTestSuiteTestCaseProvider.java @@ -59,13 +59,12 @@ Stream allTestCases() { final Stream result; final JsonParser parser = Json.createParser(jsonResource.content()); if (parser.next() == JsonParser.Event.START_ARRAY) { - result = - parser - .getArrayStream() - .onClose(() -> parser.close()) - .map(JsonValue::asJsonObject) - .map(JsonSchemaTestSuite::new) - .flatMap(JsonSchemaTestSuite::allTestCases); + result = parser + .getArrayStream() + .onClose(() -> parser.close()) + .map(JsonValue::asJsonObject) + .map(JsonSchemaTestSuite::new) + .flatMap(JsonSchemaTestSuite::allTestCases); } else { parser.close(); result = Stream.empty(); diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/Resources.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/Resources.java index 9a6b021f..11601611 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/Resources.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/testsuite/Resources.java @@ -46,14 +46,13 @@ public Resources(final String baseDir) { @com.google.errorprone.annotations.MustBeClosed Stream all() { try { - return StreamSupport - .stream( - Spliterators.spliteratorUnknownSize( - Resource.class.getClassLoader().getResources(baseDir).asIterator(), - Spliterator.ORDERED - ), - false - ) + return StreamSupport.stream( + Spliterators.spliteratorUnknownSize( + Resource.class.getClassLoader().getResources(baseDir).asIterator(), + Spliterator.ORDERED + ), + false + ) .map(url -> { try { return url.toURI(); diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/AdditionalPropertiesKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/AdditionalPropertiesKeywordTest.java index 5f78feb6..053791be 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/AdditionalPropertiesKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/AdditionalPropertiesKeywordTest.java @@ -54,8 +54,7 @@ void should_know_his_name() { void should_be_valid_for_non_objects() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("properties", Json.createObjectBuilder().add("test", JsonValue.TRUE)) .add("additionalProperties", JsonValue.FALSE) .build() @@ -70,8 +69,7 @@ void should_be_valid_for_non_objects() { void should_not_valid_if_no_additionals_are_allow() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("properties", Json.createObjectBuilder().add("test", JsonValue.TRUE)) .add("additionalProperties", JsonValue.FALSE) .build() @@ -86,8 +84,7 @@ void should_not_valid_if_no_additionals_are_allow() { void should_valid_if_additionals_are_allow() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("properties", Json.createObjectBuilder().add("test", JsonValue.TRUE)) .add("additionalProperties", JsonValue.TRUE) .build() @@ -102,8 +99,7 @@ void should_valid_if_additionals_are_allow() { void should_valid_if_no_additionals_are_allow_and_no_additionals_their() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("properties", Json.createObjectBuilder().add("test", JsonValue.TRUE)) .add("additionalProperties", JsonValue.FALSE) .build() @@ -117,8 +113,9 @@ void should_valid_if_no_additionals_are_allow_and_no_additionals_their() { @Test void should_be_an_applicator_and_an_annotation() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("additionalProperties", JsonValue.TRUE).build()) - .categories(), + createKeywordFrom( + Json.createObjectBuilder().add("additionalProperties", JsonValue.TRUE).build() + ).categories(), containsInAnyOrder(Keyword.KeywordCategory.APPLICATOR, Keyword.KeywordCategory.ANNOTATION) ); } @@ -127,8 +124,7 @@ void should_be_an_applicator_and_an_annotation() { void should_return_propertynames_which_will_be_validated() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("properties", Json.createObjectBuilder().add("test", JsonValue.TRUE)) .add("additionalProperties", JsonValue.TRUE) .build() @@ -145,14 +141,14 @@ void should_be_printable() { assertThat( createKeywordFrom( Json.createObjectBuilder().add("additionalProperties", JsonValue.EMPTY_JSON_OBJECT).build() - ) - .printOn(new HashMapMedia()), + ).printOn(new HashMapMedia()), (Matcher) hasEntry(is("additionalProperties"), anEmptyMap()) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new SubSchemaKeywordType("additionalProperties", AdditionalPropertiesKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new SubSchemaKeywordType("additionalProperties", AdditionalPropertiesKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ItemsKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ItemsKeywordTest.java index e98a8ce1..a346d3c0 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ItemsKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/ItemsKeywordTest.java @@ -74,8 +74,9 @@ void should_be_valid_if_all_items_match_schema() { @Test void should_be_applicator_and_annotation() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("items", JsonValue.EMPTY_JSON_OBJECT).build()) - .categories(), + createKeywordFrom( + Json.createObjectBuilder().add("items", JsonValue.EMPTY_JSON_OBJECT).build() + ).categories(), contains(Keyword.KeywordCategory.APPLICATOR, Keyword.KeywordCategory.ANNOTATION) ); } @@ -94,8 +95,7 @@ void should_produces_true_if_is_applied_to_any_instance() { void should_return_false_if_not_applies_to_any_item() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("prefixItems", Json.createArrayBuilder().add(true)) .add("items", JsonValue.FALSE) .build() @@ -110,8 +110,7 @@ void should_return_false_if_not_applies_to_any_item() { void should_be_valid_if_invaliditem_is_already_checked_by_prefixItems() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("prefixItems", Json.createArrayBuilder().add(true).add(true)) .add("items", Json.createObjectBuilder().add("type", "integer")) .build() @@ -126,8 +125,7 @@ void should_be_valid_if_invaliditem_is_already_checked_by_prefixItems() { void should_be_invalid_if_invaliditem_is_not_already_checked_by_prefixItems() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("prefixItems", Json.createArrayBuilder().add(true)) .add("items", Json.createObjectBuilder().add("type", "integer")) .build() @@ -139,7 +137,8 @@ void should_be_invalid_if_invaliditem_is_not_already_checked_by_prefixItems() { } private static Keyword createKeywordFrom(final JsonObject json) { - return new SubSchemaKeywordType("items", ItemsKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new SubSchemaKeywordType("items", ItemsKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordTest.java index cdf56a8e..9d8dc219 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PatternPropertiesKeywordTest.java @@ -57,8 +57,9 @@ void should_know_his_name() { @Test void should_be_an_applicator_and_an_annotation() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("patternProperties", JsonValue.EMPTY_JSON_OBJECT).build()) - .categories(), + createKeywordFrom( + Json.createObjectBuilder().add("patternProperties", JsonValue.EMPTY_JSON_OBJECT).build() + ).categories(), containsInAnyOrder(Keyword.KeywordCategory.APPLICATOR, Keyword.KeywordCategory.ANNOTATION) ); } @@ -87,8 +88,7 @@ void should_be_valid_for_empty_object() { void should_be_valid_if_properties_applies_to_his_schema() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("patternProperties", Json.createObjectBuilder().add("t.st", JsonValue.TRUE)) .build() ) @@ -102,8 +102,7 @@ void should_be_valid_if_properties_applies_to_his_schema() { void should_be_invalid_if_properties_not_applies_to_his_schema() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("patternProperties", Json.createObjectBuilder().add("t.st", JsonValue.FALSE)) .build() ) @@ -122,8 +121,7 @@ void should_be_invalid_if_properties_not_applies_to_his_schema() { void should_be_invalid_if_one_schema_doesn_apply() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add( "patternProperties", Json.createObjectBuilder().add("t.st", JsonValue.TRUE).add("t.*", JsonValue.FALSE) @@ -140,8 +138,7 @@ void should_be_invalid_if_one_schema_doesn_apply() { void should_be_valid_if_properties_not_covered() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("patternProperties", Json.createObjectBuilder().add("t.st", JsonValue.FALSE)) .build() ) @@ -155,15 +152,13 @@ void should_be_valid_if_properties_not_covered() { void should_return_the_matching_property_names() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("patternProperties", Json.createObjectBuilder().add("f.o", JsonValue.TRUE)) .build() ) .asAnnotation() .valueFor( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("foo", BigDecimal.ONE) .add("test", BigDecimal.ONE) .add("fao", 1) @@ -182,18 +177,17 @@ void should_return_the_matching_property_names() { void should_be_printable() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("patternProperties", Json.createObjectBuilder().add("f.o", JsonValue.TRUE)) .build() - ) - .printOn(new HashMapMedia()), + ).printOn(new HashMapMedia()), (Matcher) hasEntry(is("patternProperties"), hasEntry(is("f.o"), anEmptyMap())) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new NamedJsonSchemaKeywordType("patternProperties", PatternPropertiesKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new NamedJsonSchemaKeywordType("patternProperties", PatternPropertiesKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PrefixItemsKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PrefixItemsKeywordTest.java index f65cf541..b625575e 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PrefixItemsKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PrefixItemsKeywordTest.java @@ -68,8 +68,7 @@ void should_return_zero_as_value() { void should_retrun_true_if_is_applies_to_all_values() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("prefixItems", Json.createArrayBuilder().add(JsonValue.TRUE).add(JsonValue.TRUE)) .build() ) @@ -107,8 +106,7 @@ void should_be_valid_if_first_item_match_schema() { void should_be_invalid_if_second_item_does_not_match_schema() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("prefixItems", Json.createArrayBuilder().add(JsonValue.TRUE).add(JsonValue.FALSE)) .build() ) @@ -121,8 +119,9 @@ void should_be_invalid_if_second_item_does_not_match_schema() { @Test void should_be_applicator_and_annotation() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("prefixItems", JsonValue.EMPTY_JSON_ARRAY).build()) - .categories(), + createKeywordFrom( + Json.createObjectBuilder().add("prefixItems", JsonValue.EMPTY_JSON_ARRAY).build() + ).categories(), containsInAnyOrder(Keyword.KeywordCategory.APPLICATOR, Keyword.KeywordCategory.ANNOTATION) ); } @@ -132,14 +131,14 @@ void should_be_printable() { assertThat( createKeywordFrom( Json.createObjectBuilder().add("prefixItems", Json.createArrayBuilder().add(JsonValue.TRUE)).build() - ) - .printOn(new HashMapMedia()), + ).printOn(new HashMapMedia()), (Matcher) hasEntry(is("prefixItems"), contains(anEmptyMap())) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new ArraySubSchemaKeywordType("prefixItems", PrefixItemsKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new ArraySubSchemaKeywordType("prefixItems", PrefixItemsKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PropertiesKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PropertiesKeywordTest.java index 471b2371..f3e88790 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PropertiesKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/applicator/PropertiesKeywordTest.java @@ -55,8 +55,9 @@ void should_be_know_his_name() { @Test void should_be_an_applicator_and_annotation() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("properties", JsonValue.EMPTY_JSON_OBJECT).build()) - .categories(), + createKeywordFrom( + Json.createObjectBuilder().add("properties", JsonValue.EMPTY_JSON_OBJECT).build() + ).categories(), containsInAnyOrder(Keyword.KeywordCategory.APPLICATOR, Keyword.KeywordCategory.ANNOTATION) ); } @@ -75,8 +76,7 @@ void should_be_valid_for_non_objects() { void should_be_valid_if_properties_applies_to_his_schema() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("properties", Json.createObjectBuilder().add("test", JsonValue.TRUE)) .build() ) @@ -90,8 +90,7 @@ void should_be_valid_if_properties_applies_to_his_schema() { void should_be_invalid_if_properties_not_applies_to_his_schema() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("properties", Json.createObjectBuilder().add("test", JsonValue.FALSE)) .build() ) @@ -105,8 +104,7 @@ void should_be_invalid_if_properties_not_applies_to_his_schema() { void should_be_valid_for_empty_objects() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("properties", Json.createObjectBuilder().add("test", JsonValue.FALSE)) .build() ) @@ -120,8 +118,7 @@ void should_be_valid_for_empty_objects() { void should_return_all_matched_propertynames() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("properties", Json.createObjectBuilder().add("test", true).add("foo", true)) .build() ) @@ -138,8 +135,7 @@ void should_return_all_matched_propertynames() { void should_be_printable() { assertThat( ((Map) createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("properties", Json.createObjectBuilder().add("test", JsonValue.TRUE)) .build() ) @@ -150,7 +146,8 @@ void should_be_printable() { } private static Keyword createKeywordFrom(final JsonObject json) { - return new NamedJsonSchemaKeywordType("properties", PropertiesKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new NamedJsonSchemaKeywordType("properties", PropertiesKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CommentKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CommentKeywordTest.java index eb85e5a3..a853cda2 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CommentKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CommentKeywordTest.java @@ -51,14 +51,16 @@ void should_know_her_name() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("$comment", Json.createValue("comment")).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("$comment", Json.createValue("comment")).build()).printOn( + new HashMapMedia() + ), hasEntry("$comment", "comment") ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new StringKeywordType(JsonProvider.provider(), "$comment", CommentKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new StringKeywordType(JsonProvider.provider(), "$comment", CommentKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabularyTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabularyTest.java index e460123b..f6bff2b0 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabularyTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/CoreVocabularyTest.java @@ -68,8 +68,11 @@ void should_create_dynamicRef_keyword_because_pitest_means_we_need_to_checkit() assertThat( coreVocabulary .findKeywordTypeByName("$dynamicRef") - .map(kt -> - kt.createKeyword(JsonSchemas.load(Json.createObjectBuilder().add("$dynamicRef", "test").build())) + .map( + kt -> + kt.createKeyword( + JsonSchemas.load(Json.createObjectBuilder().add("$dynamicRef", "test").build()) + ) ), isPresentAnd(isA(DynamicRefKeyword.class)) ); diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/DefsKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/DefsKeywordTest.java index 00d9829b..4dd22189 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/DefsKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/DefsKeywordTest.java @@ -53,14 +53,16 @@ void should_know_his_name() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("$defs", JsonValue.EMPTY_JSON_OBJECT).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("$defs", JsonValue.EMPTY_JSON_OBJECT).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("$defs"), anEmptyMap()) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new NamedJsonSchemaKeywordType(DefsKeyword.NAME, DefsKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new NamedJsonSchemaKeywordType(DefsKeyword.NAME, DefsKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/DynamicRefKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/DynamicRefKeywordTest.java index c26a400c..d909a1a9 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/DynamicRefKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/DynamicRefKeywordTest.java @@ -62,8 +62,9 @@ void notFinischedYet() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("$dynamicRef", "test").build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("$dynamicRef", "test").build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("$dynamicRef"), is("test")) ); } @@ -73,7 +74,6 @@ private static Keyword createKeywordFrom(final JsonObject json) { JsonProvider.provider(), DynamicRefKeyword.NAME, s -> new DynamicRefKeyword(URI.create(s)) - ) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + ).createKeyword(new DefaultJsonSchemaFactory().create(json)); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/IdKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/IdKeywordTest.java index cf2159bc..0e23f507 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/IdKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/IdKeywordTest.java @@ -52,8 +52,7 @@ void should_know_his_name() { void should_retun_his_uri() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("$id", Json.createValue("https://json-schema.org/draft/2020-12/schema")) .build() ) @@ -67,18 +66,17 @@ void should_retun_his_uri() { void should_be_printable() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("$id", Json.createValue("https://json-schema.org/draft/2020-12/schema")) .build() - ) - .printOn(new HashMapMedia()), + ).printOn(new HashMapMedia()), (Matcher) hasEntry(is("$id"), is("https://json-schema.org/draft/2020-12/schema")) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new StringKeywordType(JsonProvider.provider(), "$id", s -> new IdKeyword(URI.create(s))) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new StringKeywordType(JsonProvider.provider(), "$id", s -> new IdKeyword(URI.create(s))).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/RefKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/RefKeywordTest.java index 959fc6a2..dc34c53c 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/RefKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/RefKeywordTest.java @@ -53,11 +53,9 @@ void should_be_not_createable_from_non_string() { @Test void should_know_his_name() { - final Keyword ref = new RefKeywordType(JsonProvider.provider()) - .createKeyword( - new DefaultJsonSchemaFactory() - .create(Json.createObjectBuilder().add("$ref", Json.createValue("#")).build()) - ); + final Keyword ref = new RefKeywordType(JsonProvider.provider()).createKeyword( + new DefaultJsonSchemaFactory().create(Json.createObjectBuilder().add("$ref", Json.createValue("#")).build()) + ); assertThat(ref.hasName("$ref"), is(true)); assertThat(ref.hasName("test"), is(false)); @@ -65,22 +63,19 @@ void should_know_his_name() { @Test void should_use_local_referenced_schema_for_validation() { - final Keyword keyword = new RefKeywordType(JsonProvider.provider()) - .createKeyword( - new DefaultJsonSchemaFactory() - .create( - Json - .createObjectBuilder() - .add( - "$defs", - Json - .createObjectBuilder() - .add("positiveInteger", Json.createObjectBuilder().add("type", "integer")) - ) - .add("$ref", Json.createValue("#/$defs/positiveInteger")) - .build() - ) - ); + final Keyword keyword = new RefKeywordType(JsonProvider.provider()).createKeyword( + new DefaultJsonSchemaFactory() + .create( + Json.createObjectBuilder() + .add( + "$defs", + Json.createObjectBuilder() + .add("positiveInteger", Json.createObjectBuilder().add("type", "integer")) + ) + .add("$ref", Json.createValue("#/$defs/positiveInteger")) + .build() + ) + ); assertThat(keyword.asApplicator().applyTo(Json.createValue(1L)), is(true)); assertThat(keyword.asApplicator().applyTo(Json.createValue("invalid")), is(false)); @@ -88,22 +83,19 @@ void should_use_local_referenced_schema_for_validation() { @Test void should_use_remote_referenced_schema_for_validation() { - final Keyword keyword = new RefKeywordType(JsonProvider.provider()) - .createKeyword( - new DefaultJsonSchemaFactory() - .create( - Json - .createObjectBuilder() - .add( - "$defs", - Json - .createObjectBuilder() - .add("positiveInteger", Json.createObjectBuilder().add("type", "integer")) - ) - .add("$ref", Json.createValue("#/$defs/positiveInteger")) - .build() - ) - ); + final Keyword keyword = new RefKeywordType(JsonProvider.provider()).createKeyword( + new DefaultJsonSchemaFactory() + .create( + Json.createObjectBuilder() + .add( + "$defs", + Json.createObjectBuilder() + .add("positiveInteger", Json.createObjectBuilder().add("type", "integer")) + ) + .add("$ref", Json.createValue("#/$defs/positiveInteger")) + .build() + ) + ); assertThat(keyword.asApplicator().applyTo(Json.createValue(1L)), is(true)); } @@ -123,7 +115,10 @@ void should_be_printable() { private static Keyword createKeywordFrom(final JsonObject json) { final JsonSchema schema = new DefaultJsonSchemaFactory().create(json); - return new StringKeywordType(JsonProvider.provider(), "$ref", s -> new RefKeyword(schema, URI.create(s))) - .createKeyword(schema); + return new StringKeywordType( + JsonProvider.provider(), + "$ref", + s -> new RefKeyword(schema, URI.create(s)) + ).createKeyword(schema); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/SchemaKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/SchemaKeywordTest.java index 0f60431c..e2ff6c7f 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/SchemaKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/SchemaKeywordTest.java @@ -54,8 +54,7 @@ void should_know_his_name() { void should_retun_his_uri() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("$schema", Json.createValue("https://json-schema.org/draft/2020-12/schema")) .build() ) @@ -69,18 +68,19 @@ void should_retun_his_uri() { void should_be_printable() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("$schema", Json.createValue("https://json-schema.org/draft/2020-12/schema")) .build() - ) - .printOn(new HashMapMedia()), + ).printOn(new HashMapMedia()), (Matcher) hasEntry(is("$schema"), is("https://json-schema.org/draft/2020-12/schema")) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new StringKeywordType(JsonProvider.provider(), "$schema", s -> new SchemaKeyword(URI.create(s))) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new StringKeywordType( + JsonProvider.provider(), + "$schema", + s -> new SchemaKeyword(URI.create(s)) + ).createKeyword(new DefaultJsonSchemaFactory().create(json)); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/VocabularyKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/VocabularyKeywordTypeTest.java index 429645bf..3ee97e25 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/VocabularyKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/core/VocabularyKeywordTypeTest.java @@ -61,12 +61,10 @@ void should_create_definitions() { .createKeyword( new DefaultJsonSchemaFactory() .create( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add( "$vocabulary", - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("https://json-schema.org/draft/2020-12/vocab/core", true) .add("http://openapi.org/test", false) ) @@ -88,12 +86,10 @@ void should_be_printable() { .createKeyword( new DefaultJsonSchemaFactory() .create( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add( "$vocabulary", - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("https://json-schema.org/draft/2020-12/vocab/core", true) .add("http://openapi.org/test", false) ) diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/EnumKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/EnumKeywordTest.java index 30e44c95..cb7c6890 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/EnumKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/EnumKeywordTest.java @@ -89,14 +89,14 @@ void should_be_printable() { assertThat( createKeywordFrom( Json.createObjectBuilder().add("enum", Json.createArrayBuilder().add("TEST").add("VALID")).build() - ) - .printOn(new HashMapMedia()), + ).printOn(new HashMapMedia()), (Matcher) hasEntry(is("enum"), containsInAnyOrder("TEST", "VALID")) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new ArrayKeywordType("enum", EnumKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new ArrayKeywordType("enum", EnumKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMaximumKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMaximumKeywordTest.java index 6882af12..9242c0a2 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMaximumKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMaximumKeywordTest.java @@ -94,14 +94,18 @@ void shhould_be_valid_for_smaller_numbers() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("exclusiveMaximum", Json.createValue(10)).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("exclusiveMaximum", Json.createValue(10)).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("exclusiveMaximum"), is(BigDecimal.valueOf(10))) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new NumberKeywordType(JsonProvider.provider(), "exclusiveMaximum", ExclusiveMaximumKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new NumberKeywordType( + JsonProvider.provider(), + "exclusiveMaximum", + ExclusiveMaximumKeyword::new + ).createKeyword(new DefaultJsonSchemaFactory().create(json)); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMinimumKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMinimumKeywordTest.java index 63282376..c6ca0db8 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMinimumKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/ExclusiveMinimumKeywordTest.java @@ -94,14 +94,18 @@ void shhould_be_valid_for_greater_numbers() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("exclusiveMinimum", Json.createValue(0)).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("exclusiveMinimum", Json.createValue(0)).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("exclusiveMinimum"), is(BigDecimal.valueOf(0))) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new NumberKeywordType(JsonProvider.provider(), "exclusiveMinimum", ExclusiveMinimumKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new NumberKeywordType( + JsonProvider.provider(), + "exclusiveMinimum", + ExclusiveMinimumKeyword::new + ).createKeyword(new DefaultJsonSchemaFactory().create(json)); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxItemsKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxItemsKeywordTest.java index e255fb87..182a3360 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxItemsKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxItemsKeywordTest.java @@ -94,14 +94,16 @@ void should_be_invalid_for_array_with_greather_size() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("maxItems", Json.createValue(2)).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("maxItems", Json.createValue(2)).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("maxItems"), is(BigInteger.valueOf(2))) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new IntegerKeywordType(JsonProvider.provider(), "maxItems", MaxItemsKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new IntegerKeywordType(JsonProvider.provider(), "maxItems", MaxItemsKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxLengthKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxLengthKeywordTest.java index 7b3ec8f4..886a2ef8 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxLengthKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaxLengthKeywordTest.java @@ -92,14 +92,16 @@ void should_ne_valid_for_string_with_is_shorter() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("maxLength", Json.createValue(2)).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("maxLength", Json.createValue(2)).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("maxLength"), is(BigInteger.valueOf(2L))) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new IntegerKeywordType(JsonProvider.provider(), "maxLength", MaxLengthKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new IntegerKeywordType(JsonProvider.provider(), "maxLength", MaxLengthKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaximumKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaximumKeywordTest.java index d5fcdfb1..10bbd699 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaximumKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MaximumKeywordTest.java @@ -94,14 +94,16 @@ void shhould_be_valid_for_smaller_numbers() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("maximum", Json.createValue(10)).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("maximum", Json.createValue(10)).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("maximum"), is(BigDecimal.valueOf(10))) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new NumberKeywordType(JsonProvider.provider(), "maximum", MaximumKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new NumberKeywordType(JsonProvider.provider(), "maximum", MaximumKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinItemsKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinItemsKeywordTest.java index c3acef7e..1af26aa0 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinItemsKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinItemsKeywordTest.java @@ -94,14 +94,16 @@ void should_be_invalid_for_arrays_with_smaller_size() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("minItems", Json.createValue(1)).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("minItems", Json.createValue(1)).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("minItems"), is(BigInteger.valueOf(1))) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new IntegerKeywordType(JsonProvider.provider(), "minItems", MinItemsKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new IntegerKeywordType(JsonProvider.provider(), "minItems", MinItemsKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinLengthKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinLengthKeywordTest.java index 09e80e34..798ca931 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinLengthKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinLengthKeywordTest.java @@ -94,14 +94,16 @@ void should_be_valid_for_non_string_values() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("minLength", Json.createValue(2)).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("minLength", Json.createValue(2)).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("minLength"), is(BigInteger.valueOf(2L))) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new IntegerKeywordType(JsonProvider.provider(), "minLength", MinLengthKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new IntegerKeywordType(JsonProvider.provider(), "minLength", MinLengthKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinimumKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinimumKeywordTest.java index 403d7329..456a9784 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinimumKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MinimumKeywordTest.java @@ -94,14 +94,16 @@ void shhould_be_valid_for_greater_numbers() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("minimum", Json.createValue(0)).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("minimum", Json.createValue(0)).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("minimum"), is(BigDecimal.valueOf(0))) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new NumberKeywordType(JsonProvider.provider(), "minimum", MinimumKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new NumberKeywordType(JsonProvider.provider(), "minimum", MinimumKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MultipleOfKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MultipleOfKeywordTest.java index 0b3b18f9..ee677364 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MultipleOfKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/MultipleOfKeywordTest.java @@ -96,14 +96,16 @@ void should_be_valid_for_any_int_if_multipleOf_is_1en8() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("multipleOf", Json.createValue(2)).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("multipleOf", Json.createValue(2)).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("multipleOf"), is(new BigDecimal(2))) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new NumberKeywordType(JsonProvider.provider(), "multipleOf", MultipleOfKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new NumberKeywordType(JsonProvider.provider(), "multipleOf", MultipleOfKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/PatternKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/PatternKeywordTest.java index 2be54194..817ff41a 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/PatternKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/PatternKeywordTest.java @@ -64,8 +64,7 @@ void should_be_valid_for_non_string_value() { void should_be_invalid_for_non_matching_value() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("pattern", Json.createValue("^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$")) .build() ) @@ -79,8 +78,7 @@ void should_be_invalid_for_non_matching_value() { void should_be_valid_matching_value() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("pattern", Json.createValue("^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$")) .build() ) @@ -94,18 +92,17 @@ void should_be_valid_matching_value() { void should_be_printable() { assertThat( createKeywordFrom( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add("pattern", Json.createValue("^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$")) .build() - ) - .printOn(new HashMapMedia()), + ).printOn(new HashMapMedia()), (Matcher) hasEntry(is("pattern"), is("^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$")) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new StringKeywordType(JsonProvider.provider(), "pattern", PatternKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new StringKeywordType(JsonProvider.provider(), "pattern", PatternKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/RequiredKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/RequiredKeywordTest.java index ea4afdea..f832e374 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/RequiredKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/RequiredKeywordTest.java @@ -93,14 +93,14 @@ void should_be_printable() { assertThat( createKeywordFrom( Json.createObjectBuilder().add("required", Json.createArrayBuilder().add("foo").add("bar")).build() - ) - .printOn(new HashMapMedia()), + ).printOn(new HashMapMedia()), (Matcher) hasEntry(is("required"), containsInAnyOrder("foo", "bar")) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new StringArrayKeywordType(JsonProvider.provider(), "required", RequiredKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new StringArrayKeywordType(JsonProvider.provider(), "required", RequiredKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/TypeKeywordTypeTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/TypeKeywordTypeTest.java index fdc406aa..49d9d243 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/TypeKeywordTypeTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/TypeKeywordTypeTest.java @@ -81,12 +81,10 @@ void should_use_arrayvalue_to_validate_type() { .createKeyword( new DefaultJsonSchemaFactory() .create( - Json - .createObjectBuilder() + Json.createObjectBuilder() .add( "type", - Json - .createArrayBuilder() + Json.createArrayBuilder() .add(Json.createValue("string")) .add(Json.createValue("object")) ) diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/UniqueItemsKeywordTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/UniqueItemsKeywordTest.java index 702aedcf..86db461c 100644 --- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/UniqueItemsKeywordTest.java +++ b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/vocab/validation/UniqueItemsKeywordTest.java @@ -126,14 +126,16 @@ void pitests_say_i_must_write_this_tests() { @Test void should_be_printable() { assertThat( - createKeywordFrom(Json.createObjectBuilder().add("uniqueItems", JsonValue.TRUE).build()) - .printOn(new HashMapMedia()), + createKeywordFrom(Json.createObjectBuilder().add("uniqueItems", JsonValue.TRUE).build()).printOn( + new HashMapMedia() + ), (Matcher) hasEntry(is("uniqueItems"), is(true)) ); } private static Keyword createKeywordFrom(final JsonObject json) { - return new BooleanKeywordType(JsonProvider.provider(), "uniqueItems", UniqueItemsKeyword::new) - .createKeyword(new DefaultJsonSchemaFactory().create(json)); + return new BooleanKeywordType(JsonProvider.provider(), "uniqueItems", UniqueItemsKeyword::new).createKeyword( + new DefaultJsonSchemaFactory().create(json) + ); } } diff --git a/pom.xml b/pom.xml index af58b120..123e719c 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ io.github.sebastian-toepfer.oss oss-parent - 0.4.0 + 0.5.0 io.github.sebastian-toepfer.json-schema diff --git a/vocabulary-spi/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/VocabularyDefinition.java b/vocabulary-spi/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/VocabularyDefinition.java index 0d4ab838..a14c7d61 100644 --- a/vocabulary-spi/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/VocabularyDefinition.java +++ b/vocabulary-spi/src/main/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/VocabularyDefinition.java @@ -30,8 +30,7 @@ public record VocabularyDefinition(URI id, boolean required) { public Optional findVocabulary() { - final Optional result = ServiceLoader - .load(LazyVocabularies.class) + final Optional result = ServiceLoader.load(LazyVocabularies.class) .stream() .map(ServiceLoader.Provider::get) .map(loader -> loader.loadVocabularyWithId(id)) diff --git a/vocabulary-spi/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/DefaultVocabularyTest.java b/vocabulary-spi/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/DefaultVocabularyTest.java index df0f58ea..bcc681e4 100644 --- a/vocabulary-spi/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/DefaultVocabularyTest.java +++ b/vocabulary-spi/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/DefaultVocabularyTest.java @@ -47,8 +47,10 @@ void should_return_the_id() { @Test void should_return_empty_if_requested_keyword_is_unknown() { assertThat( - new DefaultVocabulary(URI.create("http://localhost"), new SimpleTestKeywordType("name")) - .findKeywordTypeByName("test"), + new DefaultVocabulary( + URI.create("http://localhost"), + new SimpleTestKeywordType("name") + ).findKeywordTypeByName("test"), isEmpty() ); } diff --git a/vocabulary-spi/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/LazyVocabulariesTest.java b/vocabulary-spi/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/LazyVocabulariesTest.java index fb7f777b..20b28ca9 100644 --- a/vocabulary-spi/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/LazyVocabulariesTest.java +++ b/vocabulary-spi/src/test/java/io/github/sebastiantoepfer/jsonschema/vocabulary/spi/LazyVocabulariesTest.java @@ -45,20 +45,19 @@ void should_know_which_vocabularies_are_supported() { public Optional loadVocabularyWithId(final URI id) { final Optional result; if (Objects.equals(URI.create("http://github.com/sebastian-toepfer/json-schema/basic"), id)) { - result = - Optional.of( - new Vocabulary() { - @Override - public URI id() { - throw new UnsupportedOperationException("Not supported yet."); - } + result = Optional.of( + new Vocabulary() { + @Override + public URI id() { + throw new UnsupportedOperationException("Not supported yet."); + } - @Override - public Optional findKeywordTypeByName(String name) { - throw new UnsupportedOperationException("Not supported yet."); - } + @Override + public Optional findKeywordTypeByName(String name) { + throw new UnsupportedOperationException("Not supported yet."); } - ); + } + ); } else { result = Optional.empty(); }