From d4d0bb3ddeef3981dc162bd6834e3948fb7949f3 Mon Sep 17 00:00:00 2001 From: "J. Koster" Date: Tue, 12 Nov 2024 15:07:28 +0100 Subject: [PATCH] Test Code Cleanup (#1128) * Clean up test code * Remove unnecessary 'public' keyword on unit tests (and some unnecessary throws) --- .../schema/AbstractJsonSchemaTest.java | 2 +- .../schema/AbstractJsonSchemaTestSuite.java | 2 +- .../AdditionalPropertiesValidatorTest.java | 2 +- .../networknt/schema/AllOfValidatorTest.java | 2 +- .../networknt/schema/AnyOfValidatorTest.java | 2 +- .../schema/CollectorContextTest.java | 18 ++-- .../schema/ContentSchemaValidatorTest.java | 2 +- .../networknt/schema/CustomMessageTest.java | 2 +- .../schema/CustomMetaSchemaTest.java | 9 +- .../com/networknt/schema/CustomUriTest.java | 4 +- .../schema/CyclicDependencyTest.java | 4 +- .../com/networknt/schema/DateTimeDSTTest.java | 4 +- .../DefaultJsonSchemaIdValidatorTest.java | 2 +- .../schema/DependentRequiredTest.java | 2 +- .../schema/DiscriminatorValidatorTest.java | 2 +- .../schema/DurationFormatValidatorTest.java | 4 +- .../com/networknt/schema/ExampleTest.java | 6 +- .../schema/ExclusiveMinimumValidatorTest.java | 2 +- .../schema/FormatKeywordFactoryTest.java | 2 +- .../networknt/schema/FormatValidatorTest.java | 6 +- .../networknt/schema/HTTPServiceSupport.java | 6 +- .../com/networknt/schema/Issue1091Test.java | 2 +- .../com/networknt/schema/Issue255Test.java | 4 +- .../com/networknt/schema/Issue285Test.java | 18 ++-- .../com/networknt/schema/Issue295Test.java | 4 +- .../com/networknt/schema/Issue313Test.java | 6 +- .../com/networknt/schema/Issue314Test.java | 4 +- .../com/networknt/schema/Issue327Test.java | 4 +- .../com/networknt/schema/Issue342Test.java | 4 +- .../com/networknt/schema/Issue347Test.java | 4 +- .../schema/Issue366FailFastTest.java | 12 +-- .../schema/Issue366FailSlowTest.java | 17 ++-- .../com/networknt/schema/Issue375Test.java | 4 +- .../com/networknt/schema/Issue383Test.java | 4 +- .../com/networknt/schema/Issue396Test.java | 4 +- .../com/networknt/schema/Issue404Test.java | 4 +- .../com/networknt/schema/Issue406Test.java | 8 +- .../com/networknt/schema/Issue426Test.java | 4 +- .../com/networknt/schema/Issue428Test.java | 6 +- .../com/networknt/schema/Issue451Test.java | 8 +- .../com/networknt/schema/Issue456Test.java | 6 +- .../com/networknt/schema/Issue461Test.java | 5 +- .../com/networknt/schema/Issue467Test.java | 10 +-- .../com/networknt/schema/Issue475Test.java | 12 +-- .../com/networknt/schema/Issue493Test.java | 4 +- .../com/networknt/schema/Issue518Test.java | 4 +- .../com/networknt/schema/Issue532Test.java | 4 +- .../com/networknt/schema/Issue550Test.java | 2 +- .../com/networknt/schema/Issue575Test.java | 8 +- .../com/networknt/schema/Issue604Test.java | 4 +- .../com/networknt/schema/Issue606Test.java | 4 +- .../com/networknt/schema/Issue619Test.java | 32 +++---- .../com/networknt/schema/Issue650Test.java | 4 +- .../com/networknt/schema/Issue662Test.java | 2 +- .../com/networknt/schema/Issue665Test.java | 2 +- .../com/networknt/schema/Issue686Test.java | 2 +- .../com/networknt/schema/Issue687Test.java | 10 +-- .../com/networknt/schema/Issue784Test.java | 6 +- .../java/com/networknt/schema/Issue792.java | 2 +- .../com/networknt/schema/Issue824Test.java | 2 +- .../com/networknt/schema/Issue832Test.java | 4 +- .../com/networknt/schema/Issue857Test.java | 2 +- .../com/networknt/schema/Issue877Test.java | 4 +- .../com/networknt/schema/Issue927Test.java | 5 +- .../com/networknt/schema/Issue928Test.java | 10 +-- .../com/networknt/schema/Issue935Test.java | 2 +- .../com/networknt/schema/Issue936Test.java | 2 +- .../com/networknt/schema/Issue939Test.java | 2 +- .../com/networknt/schema/Issue940Test.java | 2 +- .../com/networknt/schema/Issue943Test.java | 2 +- .../com/networknt/schema/Issue994Test.java | 5 +- .../schema/ItemsValidator202012Test.java | 2 +- .../networknt/schema/ItemsValidatorTest.java | 7 +- .../schema/JsonSchemaFactoryTest.java | 2 +- .../schema/JsonSchemaFactoryUriCacheTest.java | 8 +- .../schema/JsonSchemaPreloadTest.java | 2 +- .../schema/JsonSchemaTestSuiteTest.java | 2 +- .../com/networknt/schema/JsonWalkTest.java | 12 +-- .../java/com/networknt/schema/LocaleTest.java | 2 +- .../schema/MaximumValidatorPerfTest.java | 8 +- .../schema/MaximumValidatorTest.java | 28 +++---- .../com/networknt/schema/MessageTest.java | 17 ++-- .../schema/MetaSchemaValidationTest.java | 2 +- .../schema/MinimumValidatorTest.java | 24 +++--- .../schema/MultipleOfValidatorTest.java | 2 +- .../networknt/schema/OneOfValidatorTest.java | 6 +- .../schema/OpenAPI30JsonSchemaTest.java | 8 +- .../networknt/schema/OutputFormatTest.java | 4 +- .../com/networknt/schema/OutputUnitTest.java | 2 +- .../schema/OverrideValidatorTest.java | 4 +- .../OverwritingCustomMessageBugTest.java | 4 +- .../PatternPropertiesValidatorTest.java | 6 +- .../schema/PrefixItemsValidatorTest.java | 5 +- .../com/networknt/schema/PropertiesTest.java | 2 +- .../schema/PropertiesValidatorTest.java | 4 +- .../schema/PropertyNamesValidatorTest.java | 2 +- .../java/com/networknt/schema/RefTest.java | 7 +- .../networknt/schema/RefValidatorTest.java | 2 +- .../java/com/networknt/schema/SampleTest.java | 13 ++- .../com/networknt/schema/SelfRefTest.java | 4 +- .../networknt/schema/SharedConfigTest.java | 6 +- .../networknt/schema/StringCheckerTest.java | 2 +- .../schema/ThresholdMixinPerfTest.java | 83 +++++++++---------- .../com/networknt/schema/TypeFactoryTest.java | 4 +- .../networknt/schema/TypeValidatorTest.java | 2 +- .../schema/UnevaluatedItemsTest.java | 2 +- .../schema/UnevaluatedItemsValidatorTest.java | 2 +- .../schema/UnevaluatedPropertiesTest.java | 2 +- .../UnevaluatedPropertiesValidatorTest.java | 2 +- .../schema/UnknownMetaSchemaTest.java | 18 ++-- .../com/networknt/schema/UriMappingTest.java | 16 ++-- .../java/com/networknt/schema/UrnTest.java | 4 +- .../networknt/schema/V4JsonSchemaTest.java | 12 +-- .../schema/ValidationMessageTest.java | 2 +- .../schema/ValidatorTypeCodeTest.java | 10 +-- .../com/networknt/schema/VocabularyTest.java | 2 +- .../networknt/schema/oas/OpenApi30Test.java | 6 +- .../AllowRegularExpressionFactoryTest.java | 2 +- .../regex/GraalJSRegularExpressionTest.java | 2 +- .../regex/JoniRegularExpressionTest.java | 4 +- .../schema/resource/MapSchemaLoaderTest.java | 6 +- .../DefaultJsonNodeReaderTest.java | 3 +- .../networknt/schema/suite/TestSource.java | 4 +- .../com/networknt/schema/suite/TestSpec.java | 3 +- .../networknt/schema/utils/JsonNodesTest.java | 8 +- .../walk/JsonSchemaWalkListenerTest.java | 16 ++-- 126 files changed, 383 insertions(+), 402 deletions(-) diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java index 7df7b310b..197e8871f 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTest.java @@ -18,7 +18,7 @@ * @see Issue769ContainsTest * @author vwuilbea */ -public abstract class AbstractJsonSchemaTest { +abstract class AbstractJsonSchemaTest { private static final String SCHEMA = "$schema"; private static final SpecVersion.VersionFlag DEFAULT_VERSION_FLAG = SpecVersion.VersionFlag.V202012; diff --git a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java index 2b0577f54..0a97a93c2 100644 --- a/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java +++ b/src/test/java/com/networknt/schema/AbstractJsonSchemaTestSuite.java @@ -44,7 +44,7 @@ import static org.junit.jupiter.api.DynamicContainer.dynamicContainer; import static org.junit.jupiter.api.DynamicTest.dynamicTest; -public abstract class AbstractJsonSchemaTestSuite extends HTTPServiceSupport { +abstract class AbstractJsonSchemaTestSuite extends HTTPServiceSupport { private static String toForwardSlashPath(Path file) { return file.toString().replace('\\', '/'); diff --git a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java index 0bb20407f..23bf922c6 100644 --- a/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/AdditionalPropertiesValidatorTest.java @@ -28,7 +28,7 @@ /** * AdditionalPropertiesValidatorTest. */ -public class AdditionalPropertiesValidatorTest { +class AdditionalPropertiesValidatorTest { /** * Tests that the message contains the correct values when additional properties * schema is false. diff --git a/src/test/java/com/networknt/schema/AllOfValidatorTest.java b/src/test/java/com/networknt/schema/AllOfValidatorTest.java index 97d047665..c56066e35 100644 --- a/src/test/java/com/networknt/schema/AllOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AllOfValidatorTest.java @@ -22,7 +22,7 @@ import com.networknt.schema.SpecVersion.VersionFlag; -public class AllOfValidatorTest { +class AllOfValidatorTest { @Test void invalidTypeShouldThrowJsonSchemaException() { String schemaData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java index 25ee04bef..ffbb68330 100644 --- a/src/test/java/com/networknt/schema/AnyOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/AnyOfValidatorTest.java @@ -22,7 +22,7 @@ import com.networknt.schema.SpecVersion.VersionFlag; -public class AnyOfValidatorTest { +class AnyOfValidatorTest { @Test void invalidTypeShouldThrowJsonSchemaException() { String schemaData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index a91eb5f74..c19d6294c 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -35,7 +35,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; -public class CollectorContextTest { +class CollectorContextTest { private static final String SAMPLE_COLLECTOR = "sampleCollector"; @@ -46,13 +46,13 @@ public class CollectorContextTest { private JsonSchema jsonSchemaForCombine; @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { setupSchema(); } @SuppressWarnings("unchecked") @Test - public void testCollectorContextWithKeyword() throws Exception { + void testCollectorContextWithKeyword() throws Exception { ValidationResult validationResult = validate("{\"test-property1\":\"sample1\",\"test-property2\":\"sample2\"}"); Assertions.assertEquals(0, validationResult.getValidationMessages().size()); List contextValues = (List) validationResult.getCollectorContext().get(SAMPLE_COLLECTOR); @@ -65,7 +65,7 @@ public void testCollectorContextWithKeyword() throws Exception { @SuppressWarnings("unchecked") @Test - public void testCollectorContextWithMultipleThreads() throws Exception { + void testCollectorContextWithMultipleThreads() throws Exception { ValidationThread validationRunnable1 = new ValidationThread("{\"test-property1\":\"sample1\" }", "thread1"); ValidationThread validationRunnable2 = new ValidationThread("{\"test-property1\":\"sample2\" }", "thread2"); @@ -105,7 +105,7 @@ public void testCollectorContextWithMultipleThreads() throws Exception { @SuppressWarnings("unchecked") @Test - public void testCollectorGetAll() throws JsonMappingException, JsonProcessingException, IOException { + void testCollectorGetAll() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); ExecutionContext executionContext = jsonSchemaForCombine.createExecutionContext(); executionContext.getExecutionConfig().setFormatAssertionsEnabled(true); @@ -218,9 +218,9 @@ private String getSchemaStringMultipleProperties() { private class ValidationThread implements Runnable { - private String data; + private final String data; - private String name; + private final String name; private ValidationResult validationResult; @@ -379,7 +379,7 @@ public Set walk(ExecutionContext executionContext, JsonNode n } } - private ValidationResult validate(String jsonData) throws JsonMappingException, JsonProcessingException, Exception { + private ValidationResult validate(String jsonData) throws Exception { ObjectMapper objectMapper = new ObjectMapper(); ExecutionContext executionContext = this.jsonSchema.createExecutionContext(); Set messages = this.jsonSchema.validate(executionContext, objectMapper.readTree(jsonData)); @@ -427,7 +427,7 @@ public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath ev } private class CollectValidator extends AbstractJsonValidator { - public CollectValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { + CollectValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { super(schemaLocation, evaluationPath, new CollectKeyword(), schemaNode); } diff --git a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java index 187f51a9b..fa41fc703 100644 --- a/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java +++ b/src/test/java/com/networknt/schema/ContentSchemaValidatorTest.java @@ -27,7 +27,7 @@ /** * ContentSchemaValidatorTest. */ -public class ContentSchemaValidatorTest { +class ContentSchemaValidatorTest { @Test void annotationCollection() throws JsonProcessingException { String schemaData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/CustomMessageTest.java b/src/test/java/com/networknt/schema/CustomMessageTest.java index 64d7e2956..79f41b473 100644 --- a/src/test/java/com/networknt/schema/CustomMessageTest.java +++ b/src/test/java/com/networknt/schema/CustomMessageTest.java @@ -9,7 +9,7 @@ import java.util.stream.Stream; @DisplayName("Custom Messages") -public class CustomMessageTest extends AbstractJsonSchemaTestSuite { +class CustomMessageTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09 - Custom Messages Enabled") diff --git a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java index d26ea8c61..22b57ffbe 100644 --- a/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/CustomMetaSchemaTest.java @@ -16,7 +16,6 @@ package com.networknt.schema; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; @@ -29,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class CustomMetaSchemaTest { +class CustomMetaSchemaTest { /** * Introduces the keyword "enumNames". @@ -41,7 +40,7 @@ public class CustomMetaSchemaTest { * * @author klaskalass */ - public static class EnumNamesKeyword extends AbstractKeyword { + static class EnumNamesKeyword extends AbstractKeyword { private static final class Validator extends AbstractJsonValidator { private final List enumValues; @@ -79,7 +78,7 @@ public Set validate(ExecutionContext executionContext, JsonNo } - public EnumNamesKeyword() { + EnumNamesKeyword() { super("enumNames"); } @@ -115,7 +114,7 @@ private List readStringList(JsonNode node) { } @Test - public void customMetaSchemaWithIgnoredKeyword() throws JsonProcessingException, IOException { + void customMetaSchemaWithIgnoredKeyword() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); final JsonMetaSchema metaSchema = JsonMetaSchema .builder("https://github.com/networknt/json-schema-validator/tests/schemas/example01", JsonMetaSchema.getV4()) diff --git a/src/test/java/com/networknt/schema/CustomUriTest.java b/src/test/java/com/networknt/schema/CustomUriTest.java index a39e15810..191fdaa83 100644 --- a/src/test/java/com/networknt/schema/CustomUriTest.java +++ b/src/test/java/com/networknt/schema/CustomUriTest.java @@ -13,9 +13,9 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public class CustomUriTest { +class CustomUriTest { @Test - public void customUri() throws Exception { + void customUri() throws Exception { /* Given */ final JsonSchemaFactory factory = buildJsonSchemaFactory(); final JsonSchema schema = factory.getSchema( diff --git a/src/test/java/com/networknt/schema/CyclicDependencyTest.java b/src/test/java/com/networknt/schema/CyclicDependencyTest.java index 5b6a356db..c6bb016fa 100644 --- a/src/test/java/com/networknt/schema/CyclicDependencyTest.java +++ b/src/test/java/com/networknt/schema/CyclicDependencyTest.java @@ -5,10 +5,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class CyclicDependencyTest { +class CyclicDependencyTest { @Test - public void whenDependencyBetweenSchemaThenValidationSuccessful() throws Exception { + void whenDependencyBetweenSchemaThenValidationSuccessful() throws Exception { JsonSchemaFactory schemaFactory = JsonSchemaFactory .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)) diff --git a/src/test/java/com/networknt/schema/DateTimeDSTTest.java b/src/test/java/com/networknt/schema/DateTimeDSTTest.java index 035d1a3a7..200035562 100644 --- a/src/test/java/com/networknt/schema/DateTimeDSTTest.java +++ b/src/test/java/com/networknt/schema/DateTimeDSTTest.java @@ -8,7 +8,7 @@ import java.io.InputStream; import java.util.Set; -public class DateTimeDSTTest { +class DateTimeDSTTest { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -21,7 +21,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void shouldWorkV7() throws Exception { + void shouldWorkV7() throws Exception { String schemaPath = "/schema/dateTimeArray.json"; String dataPath = "/data/dstTimes.json"; // Contains 2020 DST changes for various countries InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java index 43b56ecfb..e2326132f 100644 --- a/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java +++ b/src/test/java/com/networknt/schema/DefaultJsonSchemaIdValidatorTest.java @@ -26,7 +26,7 @@ /** * Tests for the non-standard DefaultJsonSchemaIdValidator. */ -public class DefaultJsonSchemaIdValidatorTest { +class DefaultJsonSchemaIdValidatorTest { @Test void givenRelativeIdShouldThrowInvalidSchemaException() { String schema = "{\r\n" + " \"$id\": \"0\",\r\n" diff --git a/src/test/java/com/networknt/schema/DependentRequiredTest.java b/src/test/java/com/networknt/schema/DependentRequiredTest.java index bbc3a95ab..ffa346b4f 100644 --- a/src/test/java/com/networknt/schema/DependentRequiredTest.java +++ b/src/test/java/com/networknt/schema/DependentRequiredTest.java @@ -14,7 +14,7 @@ class DependentRequiredTest { - public static final String SCHEMA = + static final String SCHEMA = "{ " + " \"$schema\":\"https://json-schema.org/draft/2019-09/schema\"," + " \"type\": \"object\"," + diff --git a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java index 816aaf0ae..7106053fe 100644 --- a/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java +++ b/src/test/java/com/networknt/schema/DiscriminatorValidatorTest.java @@ -29,7 +29,7 @@ /** * Test for discriminator. */ -public class DiscriminatorValidatorTest { +class DiscriminatorValidatorTest { /** * Issue 609. */ diff --git a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java index bcf80d342..bd1609593 100644 --- a/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/DurationFormatValidatorTest.java @@ -26,10 +26,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class DurationFormatValidatorTest { +class DurationFormatValidatorTest { @Test - public void durationFormatValidatorTest() throws JsonProcessingException, IOException { + void durationFormatValidatorTest() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); final String schema = "{\"type\": \"string\", \"format\": \"duration\"}\n"; final JsonNode validTargetNode = objectMapper.readTree("\"P1D\""); diff --git a/src/test/java/com/networknt/schema/ExampleTest.java b/src/test/java/com/networknt/schema/ExampleTest.java index 17c9925e8..efbdb9886 100644 --- a/src/test/java/com/networknt/schema/ExampleTest.java +++ b/src/test/java/com/networknt/schema/ExampleTest.java @@ -23,9 +23,9 @@ import com.networknt.schema.SpecVersion.VersionFlag; -public class ExampleTest { +class ExampleTest { @Test - public void exampleSchemaLocation() throws Exception { + void exampleSchemaLocation() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder.schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://www.example.org/", "classpath:schema/")) @@ -50,7 +50,7 @@ public void exampleSchemaLocation() throws Exception { } @Test - public void exampleClasspath() throws Exception { + void exampleClasspath() { // This creates a schema factory that will use Draft 2012-12 as the default if $schema is not specified in the initial schema JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); diff --git a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java index 331bdf144..e30bb28ca 100644 --- a/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java @@ -27,7 +27,7 @@ /** * Test ExclusiveMinimumValidator validator. */ -public class ExclusiveMinimumValidatorTest { +class ExclusiveMinimumValidatorTest { @Test void draftV4ShouldHaveExclusiveMinimum() { String schemaData = "{" + diff --git a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java index fb645c40c..c709b874a 100644 --- a/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java +++ b/src/test/java/com/networknt/schema/FormatKeywordFactoryTest.java @@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.SpecVersion.VersionFlag; -public class FormatKeywordFactoryTest { +class FormatKeywordFactoryTest { public static class CustomFormatKeyword extends FormatKeyword { public CustomFormatKeyword(Map formats) { diff --git a/src/test/java/com/networknt/schema/FormatValidatorTest.java b/src/test/java/com/networknt/schema/FormatValidatorTest.java index 25e4e8856..acd15af58 100644 --- a/src/test/java/com/networknt/schema/FormatValidatorTest.java +++ b/src/test/java/com/networknt/schema/FormatValidatorTest.java @@ -35,7 +35,7 @@ /** * Test for format validator. */ -public class FormatValidatorTest { +class FormatValidatorTest { @Test void unknownFormatNoVocab() { String schemaData = "{\r\n" @@ -180,10 +180,10 @@ void patternFormatDeprecated() { assertEquals(": does not match the custom pattern must be test", messages.iterator().next().getMessage()); } - public static class CustomNumberFormat implements Format { + static class CustomNumberFormat implements Format { private final BigDecimal compare; - public CustomNumberFormat(BigDecimal compare) { + CustomNumberFormat(BigDecimal compare) { this.compare = compare; } diff --git a/src/test/java/com/networknt/schema/HTTPServiceSupport.java b/src/test/java/com/networknt/schema/HTTPServiceSupport.java index bf1e826b0..cdfd052cb 100644 --- a/src/test/java/com/networknt/schema/HTTPServiceSupport.java +++ b/src/test/java/com/networknt/schema/HTTPServiceSupport.java @@ -26,12 +26,12 @@ import static io.undertow.Handlers.*; -public abstract class HTTPServiceSupport { +abstract class HTTPServiceSupport { protected static Undertow server = null; @BeforeAll - public static void setUp() { + static void setUp() { if (server == null) { PathHandler pathHandler = path(resource( new FileResourceManager( @@ -70,7 +70,7 @@ public static void setUp() { } @AfterAll - public static void tearDown() throws Exception { + static void tearDown() throws Exception { if (server != null) { try { Thread.sleep(100); diff --git a/src/test/java/com/networknt/schema/Issue1091Test.java b/src/test/java/com/networknt/schema/Issue1091Test.java index ef3cdbbf0..2f11b5c53 100644 --- a/src/test/java/com/networknt/schema/Issue1091Test.java +++ b/src/test/java/com/networknt/schema/Issue1091Test.java @@ -27,7 +27,7 @@ import com.networknt.schema.SpecVersion.VersionFlag; import com.networknt.schema.serialization.JsonMapperFactory; -public class Issue1091Test { +class Issue1091Test { @Test @Disabled // Disabled as this test takes quite long to run for ci void testHasAdjacentKeywordInEvaluationPath() throws Exception { diff --git a/src/test/java/com/networknt/schema/Issue255Test.java b/src/test/java/com/networknt/schema/Issue255Test.java index e79b4032e..7755784f1 100644 --- a/src/test/java/com/networknt/schema/Issue255Test.java +++ b/src/test/java/com/networknt/schema/Issue255Test.java @@ -23,7 +23,7 @@ import java.io.InputStream; import java.util.Set; -public class Issue255Test { +class Issue255Test { protected JsonSchema getJsonSchemaFromStreamContent(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -36,7 +36,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void shouldFailWhenRequiredPropertiesDoNotExistInReferencedSubSchema() throws Exception { + void shouldFailWhenRequiredPropertiesDoNotExistInReferencedSubSchema() throws Exception { String schemaPath = "/draft2019-09/issue255.json"; String dataPath = "/data/issue255.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue285Test.java b/src/test/java/com/networknt/schema/Issue285Test.java index a5d98a2bf..c9782b7ca 100644 --- a/src/test/java/com/networknt/schema/Issue285Test.java +++ b/src/test/java/com/networknt/schema/Issue285Test.java @@ -11,9 +11,9 @@ import static org.junit.jupiter.api.Assertions.assertFalse; -public class Issue285Test { - private ObjectMapper mapper = new ObjectMapper(); - private JsonSchemaFactory schemaFactory = JsonSchemaFactory +class Issue285Test { + private final ObjectMapper mapper = new ObjectMapper(); + private final JsonSchemaFactory schemaFactory = JsonSchemaFactory .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)) .schemaMappers(schemaMappers -> schemaMappers .mapPrefix("http://json-schema.org", "resource:") @@ -54,9 +54,9 @@ public class Issue285Test { // This checks the that the validation checks the type of the nested attribute. // In this case the "lastName" should be a string. - // The result is as expected and we get an validation error. + // The result is as expected, and we get a validation error. @Test - public void nestedValidation() throws IOException { + void nestedValidation() throws IOException { JsonSchema jsonSchema = schemaFactory.getSchema(schemaStr); Set validationMessages = jsonSchema.validate(mapper.readTree(person)); @@ -94,9 +94,9 @@ public void nestedValidation() throws IOException { // This checks the that the validation checks the type of the nested attribute. // Based on the meta-schema found on https://json-schema.org/draft/2019-09/schema. // In this case a nested type declaration isn't valid and should raise an error. - // The result is not as expected and we get no validation error. + // The result is not as expected, and we get no validation error. @Test - public void nestedTypeValidation() throws IOException, URISyntaxException { + void nestedTypeValidation() throws IOException { SchemaLocation uri = SchemaLocation.of("https://json-schema.org/draft/2019-09/schema"); JsonSchema jsonSchema = schemaFactory.getSchema(uri); Set validationMessages = jsonSchema.validate(mapper.readTree(invalidNestedSchema)); @@ -117,9 +117,9 @@ public void nestedTypeValidation() throws IOException, URISyntaxException { // This checks the that the validation checks the type of the JSON. // Based on the meta-schema found on https://json-schema.org/draft/2019-09/schema. // In this case the toplevel type declaration isn't valid and should raise an error. - // The result is as expected and we get no validation error: '[$.type: does not have a value in the enumeration [array, boolean, integer, null, number, object, string], $.type: should be valid to any of the schemas array]'. + // The result is as expected, and we get no validation error: '[$.type: does not have a value in the enumeration [array, boolean, integer, null, number, object, string], $.type: should be valid to any of the schemas array]'. @Test - public void typeValidation() throws IOException, URISyntaxException { + void typeValidation() throws IOException { SchemaLocation uri = SchemaLocation.of("https://json-schema.org/draft/2019-09/schema"); JsonSchema jsonSchema = schemaFactory.getSchema(uri); Set validationMessages = jsonSchema.validate(mapper.readTree(invalidSchema)); diff --git a/src/test/java/com/networknt/schema/Issue295Test.java b/src/test/java/com/networknt/schema/Issue295Test.java index f59627750..487a77a58 100644 --- a/src/test/java/com/networknt/schema/Issue295Test.java +++ b/src/test/java/com/networknt/schema/Issue295Test.java @@ -8,7 +8,7 @@ import java.io.InputStream; import java.util.Set; -public class Issue295Test { +class Issue295Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -21,7 +21,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void shouldWorkV7() throws Exception { + void shouldWorkV7() throws Exception { String schemaPath = "/schema/issue295-v7.json"; String dataPath = "/data/issue295.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue313Test.java b/src/test/java/com/networknt/schema/Issue313Test.java index 867e85edf..a6eb2ba5c 100644 --- a/src/test/java/com/networknt/schema/Issue313Test.java +++ b/src/test/java/com/networknt/schema/Issue313Test.java @@ -9,7 +9,7 @@ import java.io.InputStream; import java.util.Set; -public class Issue313Test { +class Issue313Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -28,7 +28,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce @Test @Disabled - public void shouldFailV201909() throws Exception { + void shouldFailV201909() throws Exception { String schemaPath = "/schema/issue313-2019-09.json"; String dataPath = "/data/issue313.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); @@ -40,7 +40,7 @@ public void shouldFailV201909() throws Exception { } @Test - public void shouldFailV7() throws Exception { + void shouldFailV7() throws Exception { String schemaPath = "/schema/issue313-v7.json"; String dataPath = "/data/issue313.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue314Test.java b/src/test/java/com/networknt/schema/Issue314Test.java index 66e688e80..21fe077ac 100644 --- a/src/test/java/com/networknt/schema/Issue314Test.java +++ b/src/test/java/com/networknt/schema/Issue314Test.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class Issue314Test { +class Issue314Test { private static final JsonSchemaFactory FACTORY = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)) .metaSchema( @@ -15,7 +15,7 @@ public class Issue314Test { .build(); @Test - public void testNormalizeHttpOnly() { + void testNormalizeHttpOnly() { String schemaPath = "/schema/issue314-v7.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); JsonSchema schema = FACTORY.getSchema(schemaInputStream); diff --git a/src/test/java/com/networknt/schema/Issue327Test.java b/src/test/java/com/networknt/schema/Issue327Test.java index e2fe17fe0..a53fb2461 100644 --- a/src/test/java/com/networknt/schema/Issue327Test.java +++ b/src/test/java/com/networknt/schema/Issue327Test.java @@ -8,7 +8,7 @@ import java.io.InputStream; import java.util.Set; -public class Issue327Test { +class Issue327Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -21,7 +21,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void shouldWorkV7() throws Exception { + void shouldWorkV7() throws Exception { String schemaPath = "/schema/issue327-v7.json"; String dataPath = "/data/issue327.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue342Test.java b/src/test/java/com/networknt/schema/Issue342Test.java index 6f86f502a..bf14d125d 100644 --- a/src/test/java/com/networknt/schema/Issue342Test.java +++ b/src/test/java/com/networknt/schema/Issue342Test.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -public class Issue342Test { +class Issue342Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -22,7 +22,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void propertyNameEnumShouldFailV7() throws Exception { + void propertyNameEnumShouldFailV7() throws Exception { String schemaPath = "/schema/issue342-v7.json"; String dataPath = "/data/issue342.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue347Test.java b/src/test/java/com/networknt/schema/Issue347Test.java index 20e099106..c5e47c386 100644 --- a/src/test/java/com/networknt/schema/Issue347Test.java +++ b/src/test/java/com/networknt/schema/Issue347Test.java @@ -7,10 +7,10 @@ import org.junit.jupiter.api.Test; -public class Issue347Test { +class Issue347Test { @Test - public void failure() { + void failure() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); assertThrows(JsonSchemaException.class, () -> factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json"))); try { diff --git a/src/test/java/com/networknt/schema/Issue366FailFastTest.java b/src/test/java/com/networknt/schema/Issue366FailFastTest.java index 0bd37e036..701b6ebfb 100644 --- a/src/test/java/com/networknt/schema/Issue366FailFastTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailFastTest.java @@ -12,10 +12,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class Issue366FailFastTest { +class Issue366FailFastTest { @BeforeEach - public void setup() throws IOException { + void setup() throws IOException { setupSchema(); } @@ -43,7 +43,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void firstOneValid() throws Exception { + void firstOneValid() throws Exception { String dataPath = "/data/issue366.json"; InputStream dataInputStream = getClass().getResourceAsStream(dataPath); @@ -56,7 +56,7 @@ public void firstOneValid() throws Exception { } @Test - public void secondOneValid() throws Exception { + void secondOneValid() throws Exception { String dataPath = "/data/issue366.json"; InputStream dataInputStream = getClass().getResourceAsStream(dataPath); @@ -69,7 +69,7 @@ public void secondOneValid() throws Exception { } @Test - public void bothValid() throws Exception { + void bothValid() throws Exception { String dataPath = "/data/issue366.json"; InputStream dataInputStream = getClass().getResourceAsStream(dataPath); @@ -81,7 +81,7 @@ public void bothValid() throws Exception { } @Test - public void neitherValid() throws Exception { + void neitherValid() throws Exception { String dataPath = "/data/issue366.json"; InputStream dataInputStream = getClass().getResourceAsStream(dataPath); diff --git a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java index 862591cb2..65c06e6d5 100644 --- a/src/test/java/com/networknt/schema/Issue366FailSlowTest.java +++ b/src/test/java/com/networknt/schema/Issue366FailSlowTest.java @@ -1,6 +1,7 @@ package com.networknt.schema; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import com.fasterxml.jackson.databind.JsonNode; @@ -12,10 +13,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class Issue366FailSlowTest { +class Issue366FailSlowTest { @BeforeEach - public void setup() throws IOException { + void setup() throws IOException { setupSchema(); } @@ -43,7 +44,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void firstOneValid() throws Exception { + void firstOneValid() throws Exception { String dataPath = "/data/issue366.json"; InputStream dataInputStream = getClass().getResourceAsStream(dataPath); @@ -56,7 +57,7 @@ public void firstOneValid() throws Exception { } @Test - public void secondOneValid() throws Exception { + void secondOneValid() throws Exception { String dataPath = "/data/issue366.json"; InputStream dataInputStream = getClass().getResourceAsStream(dataPath); @@ -69,7 +70,7 @@ public void secondOneValid() throws Exception { } @Test - public void bothValid() throws Exception { + void bothValid() throws Exception { String dataPath = "/data/issue366.json"; InputStream dataInputStream = getClass().getResourceAsStream(dataPath); @@ -78,12 +79,12 @@ public void bothValid() throws Exception { JsonNode testNode = testNodes.get(0).get(2); JsonNode dataNode = testNode.get("data"); Set errors = jsonSchema.validate(dataNode); - assertTrue(!errors.isEmpty()); + assertFalse(errors.isEmpty()); assertEquals(errors.size(), 1); } @Test - public void neitherValid() throws Exception { + void neitherValid() throws Exception { String dataPath = "/data/issue366.json"; InputStream dataInputStream = getClass().getResourceAsStream(dataPath); @@ -92,7 +93,7 @@ public void neitherValid() throws Exception { JsonNode testNode = testNodes.get(0).get(3); JsonNode dataNode = testNode.get("data"); Set errors = jsonSchema.validate(dataNode); - assertTrue(!errors.isEmpty()); + assertFalse(errors.isEmpty()); assertEquals(errors.size(), 3); } diff --git a/src/test/java/com/networknt/schema/Issue375Test.java b/src/test/java/com/networknt/schema/Issue375Test.java index 51353394b..7711ba32b 100644 --- a/src/test/java/com/networknt/schema/Issue375Test.java +++ b/src/test/java/com/networknt/schema/Issue375Test.java @@ -27,7 +27,7 @@ import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; -public class Issue375Test { +class Issue375Test { protected JsonSchema getJsonSchemaFromStreamContent(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909); return factory.getSchema(schemaContent); @@ -39,7 +39,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void shouldFailAndShowValidationValuesWithError() throws Exception { + void shouldFailAndShowValidationValuesWithError() throws Exception { String schemaPath = "/draft2019-09/issue375.json"; String dataPath = "/data/issue375.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue383Test.java b/src/test/java/com/networknt/schema/Issue383Test.java index fc4dd876b..083810907 100644 --- a/src/test/java/com/networknt/schema/Issue383Test.java +++ b/src/test/java/com/networknt/schema/Issue383Test.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -public class Issue383Test { +class Issue383Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -22,7 +22,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void nestedOneOfsShouldStillMatchV7() throws Exception { + void nestedOneOfsShouldStillMatchV7() throws Exception { String schemaPath = "/schema/issue383-v7.json"; String dataPath = "/data/issue383.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue396Test.java b/src/test/java/com/networknt/schema/Issue396Test.java index 81a4c08aa..3e41d821f 100644 --- a/src/test/java/com/networknt/schema/Issue396Test.java +++ b/src/test/java/com/networknt/schema/Issue396Test.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -public class Issue396Test { +class Issue396Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -24,7 +24,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void testComplexPropertyNamesV7() throws Exception { + void testComplexPropertyNamesV7() throws Exception { String schemaPath = "/schema/issue396-v7.json"; String dataPath = "/data/issue396.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue404Test.java b/src/test/java/com/networknt/schema/Issue404Test.java index 07b306892..23d434d6c 100644 --- a/src/test/java/com/networknt/schema/Issue404Test.java +++ b/src/test/java/com/networknt/schema/Issue404Test.java @@ -8,7 +8,7 @@ import java.io.InputStream; import java.util.Set; -public class Issue404Test { +class Issue404Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -21,7 +21,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void expectObjectNotIntegerV7() throws Exception { + void expectObjectNotIntegerV7() throws Exception { String schemaPath = "/schema/issue404-v7.json"; String dataPath = "/data/issue404.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue406Test.java b/src/test/java/com/networknt/schema/Issue406Test.java index b4f0533e0..e05da6a83 100644 --- a/src/test/java/com/networknt/schema/Issue406Test.java +++ b/src/test/java/com/networknt/schema/Issue406Test.java @@ -7,13 +7,13 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; -public class Issue406Test { +class Issue406Test { protected static final String INVALID_$REF_SCHEMA = "{\"$ref\":\"urn:unresolved\"}"; protected static final String CIRCULAR_$REF_SCHEMA = "{\"$ref\":\"#/nestedSchema\"," + "\"nestedSchema\":{\"$ref\":\"#/nestedSchema\"}}"; @Test - public void testPreloadingNotHappening() { + void testPreloadingNotHappening() { final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); final JsonSchema schema = factory.getSchema(INVALID_$REF_SCHEMA); // not breaking - pass @@ -21,7 +21,7 @@ public void testPreloadingNotHappening() { } @Test - public void testPreloadingHappening() { + void testPreloadingHappening() { final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); final JsonSchema schema = factory.getSchema(INVALID_$REF_SCHEMA); Assertions.assertThrows(JsonSchemaException.class, @@ -35,7 +35,7 @@ public void execute() { } @Test - public void testPreloadingHappeningForCircularDependency() { + void testPreloadingHappeningForCircularDependency() { final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); final JsonSchema schema = factory.getSchema(CIRCULAR_$REF_SCHEMA); schema.initializeValidators(); diff --git a/src/test/java/com/networknt/schema/Issue426Test.java b/src/test/java/com/networknt/schema/Issue426Test.java index 07c76c393..1bd93952c 100644 --- a/src/test/java/com/networknt/schema/Issue426Test.java +++ b/src/test/java/com/networknt/schema/Issue426Test.java @@ -11,7 +11,7 @@ /** * Validating custom message */ -public class Issue426Test { +class Issue426Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -23,7 +23,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void shouldWorkV7() throws Exception { + void shouldWorkV7() throws Exception { String schemaPath = "/schema/issue426-v7.json"; String dataPath = "/data/issue426.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue428Test.java b/src/test/java/com/networknt/schema/Issue428Test.java index 03f2eac00..f2cd886f1 100644 --- a/src/test/java/com/networknt/schema/Issue428Test.java +++ b/src/test/java/com/networknt/schema/Issue428Test.java @@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -public class Issue428Test extends HTTPServiceSupport { +class Issue428Test extends HTTPServiceSupport { protected ObjectMapper mapper = new ObjectMapper(); protected JsonSchemaFactory validatorFactory = JsonSchemaFactory .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)).build(); @@ -45,7 +45,7 @@ private void runTestFile(String testCaseFile) throws Exception { if (test.get("valid").asBoolean()) { if (!errors.isEmpty()) { System.out.println("---- test case failed ----"); - System.out.println("schema: " + schema.toString()); + System.out.println("schema: " + schema); System.out.println("data: " + test.get("data")); System.out.println("errors:"); for (ValidationMessage error : errors) { @@ -84,7 +84,7 @@ private void runTestFile(String testCaseFile) throws Exception { } @Test - public void testNullableOneOf() throws Exception { + void testNullableOneOf() throws Exception { runTestFile("data/issue428.json"); } } diff --git a/src/test/java/com/networknt/schema/Issue451Test.java b/src/test/java/com/networknt/schema/Issue451Test.java index 760e51d6f..a59591229 100644 --- a/src/test/java/com/networknt/schema/Issue451Test.java +++ b/src/test/java/com/networknt/schema/Issue451Test.java @@ -16,7 +16,7 @@ /** * Validating anyOf walker */ -public class Issue451Test { +class Issue451Test { private static final String COLLECTOR_ID = "collector-451"; @@ -34,19 +34,19 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void shouldWalkAnyOfProperties() { + void shouldWalkAnyOfProperties() { walk(null, false); } @Test - public void shouldWalkAnyOfPropertiesWithWithPayloadAndValidation() throws Exception { + void shouldWalkAnyOfPropertiesWithWithPayloadAndValidation() throws Exception { JsonNode data = getJsonNodeFromStreamContent(Issue451Test.class.getResourceAsStream( "/data/issue451.json")); walk(data,true); } @Test - public void shouldWalkAnyOfPropertiesWithWithPayload() throws Exception { + void shouldWalkAnyOfPropertiesWithWithPayload() throws Exception { JsonNode data = getJsonNodeFromStreamContent(Issue451Test.class.getResourceAsStream( "/data/issue451.json")); walk(data, false); diff --git a/src/test/java/com/networknt/schema/Issue456Test.java b/src/test/java/com/networknt/schema/Issue456Test.java index 723637fd8..d7c1f99a0 100644 --- a/src/test/java/com/networknt/schema/Issue456Test.java +++ b/src/test/java/com/networknt/schema/Issue456Test.java @@ -8,7 +8,7 @@ import java.io.InputStream; import java.util.Set; -public class Issue456Test { +class Issue456Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); @@ -21,7 +21,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void shouldWorkT2() throws Exception { + void shouldWorkT2() throws Exception { String schemaPath = "/schema/issue456-v7.json"; String dataPath = "/data/issue456-T2.json"; // String dataT3Path = "/data/issue456-T3.json"; @@ -34,7 +34,7 @@ public void shouldWorkT2() throws Exception { } @Test - public void shouldWorkT3() throws Exception { + void shouldWorkT3() throws Exception { String schemaPath = "/schema/issue456-v7.json"; String dataPath = "/data/issue456-T3.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue461Test.java b/src/test/java/com/networknt/schema/Issue461Test.java index a3d06c550..3f9159341 100644 --- a/src/test/java/com/networknt/schema/Issue461Test.java +++ b/src/test/java/com/networknt/schema/Issue461Test.java @@ -10,10 +10,9 @@ import org.junit.jupiter.api.Test; import java.io.IOException; -import java.net.URISyntaxException; import java.util.Set; -public class Issue461Test { +class Issue461Test { protected ObjectMapper mapper = JsonMapperFactory.getInstance(); protected JsonSchema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) { @@ -25,7 +24,7 @@ protected JsonSchema getJsonSchemaFromStreamContentV7(SchemaLocation schemaUri) } @Test - public void shouldWalkWithValidation() throws URISyntaxException, IOException { + void shouldWalkWithValidation() throws IOException { JsonSchema schema = getJsonSchemaFromStreamContentV7(SchemaLocation.of("resource:/draft-07/schema#")); JsonNode data = mapper.readTree(Issue461Test.class.getResource("/data/issue461-v7.json")); ValidationResult result = schema.walk(data, true); diff --git a/src/test/java/com/networknt/schema/Issue467Test.java b/src/test/java/com/networknt/schema/Issue467Test.java index d5aa396f3..280208b82 100644 --- a/src/test/java/com/networknt/schema/Issue467Test.java +++ b/src/test/java/com/networknt/schema/Issue467Test.java @@ -34,14 +34,14 @@ import com.networknt.schema.walk.WalkEvent; import com.networknt.schema.walk.WalkFlow; -public class Issue467Test { - private static JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); - private static String schemaPath = "/schema/issue467.json"; +class Issue467Test { + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); + private static final String schemaPath = "/schema/issue467.json"; protected ObjectMapper mapper = new ObjectMapper(); @Test - public void shouldWalkKeywordWithValidation() throws URISyntaxException, IOException { + void shouldWalkKeywordWithValidation() throws URISyntaxException, IOException { InputStream schemaInputStream = Issue467Test.class.getResourceAsStream(schemaPath); final Set properties = new LinkedHashSet<>(); final SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() @@ -66,7 +66,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set set) { } @Test - public void shouldWalkPropertiesWithValidation() throws URISyntaxException, IOException { + void shouldWalkPropertiesWithValidation() throws URISyntaxException, IOException { InputStream schemaInputStream = Issue467Test.class.getResourceAsStream(schemaPath); final Set properties = new LinkedHashSet<>(); final SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() diff --git a/src/test/java/com/networknt/schema/Issue475Test.java b/src/test/java/com/networknt/schema/Issue475Test.java index 0f3d59f63..0c4d53e9c 100644 --- a/src/test/java/com/networknt/schema/Issue475Test.java +++ b/src/test/java/com/networknt/schema/Issue475Test.java @@ -27,7 +27,7 @@ /** * Tests for validation of schema against meta schema. */ -public class Issue475Test { +class Issue475Test { private static final String VALID_INPUT = "{ \n" + " \"type\": \"object\", \n" + " \"properties\": { \n" @@ -49,7 +49,7 @@ public class Issue475Test { + "}"; @Test - public void draft4() throws Exception { + void draft4() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V4, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); @@ -63,7 +63,7 @@ public void draft4() throws Exception { } @Test - public void draft6() throws Exception { + void draft6() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V6, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); @@ -77,7 +77,7 @@ public void draft6() throws Exception { } @Test - public void draft7() throws Exception { + void draft7() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V7, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("http://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); @@ -91,7 +91,7 @@ public void draft7() throws Exception { } @Test - public void draft201909() throws Exception { + void draft201909() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V201909, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); @@ -105,7 +105,7 @@ public void draft201909() throws Exception { } @Test - public void draft202012() throws Exception { + void draft202012() throws Exception { JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder .schemaMappers(schemaMappers -> schemaMappers.mapPrefix("https://json-schema.org", "classpath:"))); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); diff --git a/src/test/java/com/networknt/schema/Issue493Test.java b/src/test/java/com/networknt/schema/Issue493Test.java index c6e2f50ba..7d84368b9 100644 --- a/src/test/java/com/networknt/schema/Issue493Test.java +++ b/src/test/java/com/networknt/schema/Issue493Test.java @@ -17,8 +17,8 @@ class Issue493Test { - private static JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); - private static String schemaPath1 = "/schema/issue493.json"; + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); + private static final String schemaPath1 = "/schema/issue493.json"; private JsonNode getJsonNodeFromJsonData (String jsonFilePath) throws Exception diff --git a/src/test/java/com/networknt/schema/Issue518Test.java b/src/test/java/com/networknt/schema/Issue518Test.java index 984d7bb92..541a9312f 100644 --- a/src/test/java/com/networknt/schema/Issue518Test.java +++ b/src/test/java/com/networknt/schema/Issue518Test.java @@ -5,7 +5,7 @@ import java.io.InputStream; -public class Issue518Test { +class Issue518Test { private static final JsonMetaSchema igluMetaSchema = JsonMetaSchema .builder("http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", JsonMetaSchema.getV7()) @@ -18,7 +18,7 @@ public class Issue518Test { .build(); @Test - public void testPreservingEmptyFragmentSuffix() { + void testPreservingEmptyFragmentSuffix() { String schemaPath = "/schema/issue518-v7.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); JsonSchema schema = FACTORY.getSchema(schemaInputStream); diff --git a/src/test/java/com/networknt/schema/Issue532Test.java b/src/test/java/com/networknt/schema/Issue532Test.java index bb380cd5c..eb49b68da 100644 --- a/src/test/java/com/networknt/schema/Issue532Test.java +++ b/src/test/java/com/networknt/schema/Issue532Test.java @@ -4,9 +4,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -public class Issue532Test { +class Issue532Test { @Test - public void failure() { + void failure() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> { factory.getSchema("{ \"$schema\": true }"); diff --git a/src/test/java/com/networknt/schema/Issue550Test.java b/src/test/java/com/networknt/schema/Issue550Test.java index 741b2747f..d52986110 100644 --- a/src/test/java/com/networknt/schema/Issue550Test.java +++ b/src/test/java/com/networknt/schema/Issue550Test.java @@ -9,7 +9,7 @@ import java.util.Set; -public class Issue550Test { +class Issue550Test { protected JsonSchema getJsonSchemaFromStreamContentV7(String schemaPath) { InputStream schemaContent = getClass().getResourceAsStream(schemaPath); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); diff --git a/src/test/java/com/networknt/schema/Issue575Test.java b/src/test/java/com/networknt/schema/Issue575Test.java index dd22d379c..1b07b9ff5 100644 --- a/src/test/java/com/networknt/schema/Issue575Test.java +++ b/src/test/java/com/networknt/schema/Issue575Test.java @@ -16,11 +16,11 @@ * This project uses a dependency (com.ethlo.time:itu) to validate time representations. Version 1.51 of this library * has a problem dealing with certain time zones having a negative offset; for example "-2:30" (Newfoundland time, NDT). * Moving to version 1.7.0 of this library resolves the issue. - * + *

* This test class confirms that valid negative offsets do not result in a JSON validation error if the ITU library is * updated to version 1.7.0 or later. */ -public class Issue575Test { +class Issue575Test { private static JsonSchema schema; @BeforeAll @@ -31,7 +31,7 @@ static void init() { schema = factory.getSchema(schemaInputStream); } - public static Stream validTimeZoneOffsets() { + static Stream validTimeZoneOffsets() { String json1 = "{\"testDateTime\":\"2022-05-18T08:27:53-05:00\"}"; // America/New_York String json2 = "{\"testDateTime\":\"2022-05-18T08:27:53-04:00\"}"; // America/New_York (DST) String json3 = "{\"testDateTime\":\"2022-05-18T08:27:53-03:30\"}"; // America/St_Johns @@ -83,7 +83,7 @@ void testValidTimeZoneOffsets(String jsonObject) throws JsonProcessingException Assertions.assertTrue(errors.isEmpty()); } - public static Stream invalidTimeRepresentations() { + static Stream invalidTimeRepresentations() { // Invalid JSON payload: 30 days in April String json1 = "{\"testDateTime\":\"2022-04-31T08:27:53+05:00\"}"; // Invalid JSON payload: Invalid date/time separator diff --git a/src/test/java/com/networknt/schema/Issue604Test.java b/src/test/java/com/networknt/schema/Issue604Test.java index 183aef221..920f7a791 100644 --- a/src/test/java/com/networknt/schema/Issue604Test.java +++ b/src/test/java/com/networknt/schema/Issue604Test.java @@ -5,9 +5,9 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -public class Issue604Test { +class Issue604Test { @Test - public void failure() { + void failure() { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)) .build(); diff --git a/src/test/java/com/networknt/schema/Issue606Test.java b/src/test/java/com/networknt/schema/Issue606Test.java index d018f172b..5efae90cc 100644 --- a/src/test/java/com/networknt/schema/Issue606Test.java +++ b/src/test/java/com/networknt/schema/Issue606Test.java @@ -8,7 +8,7 @@ import java.io.InputStream; import java.util.Set; -public class Issue606Test { +class Issue606Test { protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); return factory.getSchema(schemaContent); @@ -21,7 +21,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce } @Test - public void shouldWorkV7() throws Exception { + void shouldWorkV7() throws Exception { String schemaPath = "/schema/issue606-v7.json"; String dataPath = "/data/issue606.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue619Test.java b/src/test/java/com/networknt/schema/Issue619Test.java index a743b7d17..d4a90e92b 100644 --- a/src/test/java/com/networknt/schema/Issue619Test.java +++ b/src/test/java/com/networknt/schema/Issue619Test.java @@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -public class Issue619Test extends HTTPServiceSupport { +class Issue619Test extends HTTPServiceSupport { private JsonSchemaFactory factory; private JsonNode one; @@ -34,7 +34,7 @@ public class Issue619Test extends HTTPServiceSupport { private JsonNode three; @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); one = getJsonNodeFromStringContent("1"); two = getJsonNodeFromStringContent("2"); @@ -42,7 +42,7 @@ public void setup() throws Exception { } @Test - public void bundledSchemaLoadsAndValidatesCorrectly_Ref() { + void bundledSchemaLoadsAndValidatesCorrectly_Ref() { JsonSchema referencingRootSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json\" }"); assertTrue(referencingRootSchema.validate(one).isEmpty()); @@ -51,7 +51,7 @@ public void bundledSchemaLoadsAndValidatesCorrectly_Ref() { } @Test - public void bundledSchemaLoadsAndValidatesCorrectly_Uri() throws Exception { + void bundledSchemaLoadsAndValidatesCorrectly_Uri() throws Exception { JsonSchema rootSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json")); assertTrue(rootSchema.validate(one).isEmpty()); @@ -60,7 +60,7 @@ public void bundledSchemaLoadsAndValidatesCorrectly_Uri() throws Exception { } @Test - public void uriWithEmptyFragment_Ref() { + void uriWithEmptyFragment_Ref() { JsonSchema referencingRootSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#\" }"); assertTrue(referencingRootSchema.validate(one).isEmpty()); @@ -69,7 +69,7 @@ public void uriWithEmptyFragment_Ref() { } @Test - public void uriWithEmptyFragment_Uri() throws Exception { + void uriWithEmptyFragment_Uri() throws Exception { JsonSchema rootSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#")); assertTrue(rootSchema.validate(one).isEmpty()); @@ -78,7 +78,7 @@ public void uriWithEmptyFragment_Uri() throws Exception { } @Test - public void uriThatPointsToTwoShouldOnlyValidateTwo_Ref() { + void uriThatPointsToTwoShouldOnlyValidateTwo_Ref() { JsonSchema referencingTwoSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#/definitions/two\" }"); assertFalse(referencingTwoSchema.validate(one).isEmpty()); @@ -87,7 +87,7 @@ public void uriThatPointsToTwoShouldOnlyValidateTwo_Ref() { } @Test - public void uriThatPointsToOneShouldOnlyValidateOne_Uri() throws Exception { + void uriThatPointsToOneShouldOnlyValidateOne_Uri() throws Exception { JsonSchema oneSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#/definitions/one")); assertTrue(oneSchema.validate(one).isEmpty()); @@ -96,7 +96,7 @@ public void uriThatPointsToOneShouldOnlyValidateOne_Uri() throws Exception { } @Test - public void uriThatPointsToNodeThatInTurnReferencesOneShouldOnlyValidateOne_Ref() { + void uriThatPointsToNodeThatInTurnReferencesOneShouldOnlyValidateOne_Ref() { JsonSchema referencingTwoSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#/definitions/refToOne\" }"); assertTrue(referencingTwoSchema.validate(one).isEmpty()); @@ -105,7 +105,7 @@ public void uriThatPointsToNodeThatInTurnReferencesOneShouldOnlyValidateOne_Ref( } @Test - public void uriThatPointsToNodeThatInTurnReferencesOneShouldOnlyValidateOne_Uri() throws Exception { + void uriThatPointsToNodeThatInTurnReferencesOneShouldOnlyValidateOne_Uri() throws Exception { JsonSchema oneSchema = factory.getSchema(SchemaLocation.of("resource:schema/issue619.json#/definitions/refToOne")); assertTrue(oneSchema.validate(one).isEmpty()); @@ -114,7 +114,7 @@ public void uriThatPointsToNodeThatInTurnReferencesOneShouldOnlyValidateOne_Uri( } @Test - public void uriThatPointsToSchemaWithIdThatHasDifferentUri_Ref() throws Exception { + void uriThatPointsToSchemaWithIdThatHasDifferentUri_Ref() throws Exception { JsonNode oneArray = getJsonNodeFromStringContent("[[1]]"); JsonNode textArray = getJsonNodeFromStringContent("[[\"a\"]]"); @@ -124,7 +124,7 @@ public void uriThatPointsToSchemaWithIdThatHasDifferentUri_Ref() throws Exceptio } @Test - public void uriThatPointsToSchemaWithIdThatHasDifferentUri_Uri() throws Exception { + void uriThatPointsToSchemaWithIdThatHasDifferentUri_Uri() throws Exception { JsonNode oneArray = getJsonNodeFromStringContent("[[1]]"); JsonNode textArray = getJsonNodeFromStringContent("[[\"a\"]]"); @@ -134,26 +134,26 @@ public void uriThatPointsToSchemaWithIdThatHasDifferentUri_Uri() throws Exceptio } @Test - public void uriThatPointsToSchemaThatDoesNotExistShouldFail_Ref() { + void uriThatPointsToSchemaThatDoesNotExistShouldFail_Ref() { JsonSchema referencingNonexistentSchema = factory.getSchema("{ \"$ref\": \"resource:data/schema-that-does-not-exist.json#/definitions/something\" }"); assertThrows(JsonSchemaException.class, () -> referencingNonexistentSchema.validate(one)); } @Test - public void uriThatPointsToSchemaThatDoesNotExistShouldFail_Uri() { + void uriThatPointsToSchemaThatDoesNotExistShouldFail_Uri() { assertThrows(JsonSchemaException.class, () -> factory.getSchema(SchemaLocation.of("resource:data/schema-that-does-not-exist.json#/definitions/something"))); } @Test - public void uriThatPointsToNodeThatDoesNotExistShouldFail_Ref() { + void uriThatPointsToNodeThatDoesNotExistShouldFail_Ref() { JsonSchema referencingNonexistentSchema = factory.getSchema("{ \"$ref\": \"resource:schema/issue619.json#/definitions/node-that-does-not-exist\" }"); assertThrows(JsonSchemaException.class, () -> referencingNonexistentSchema.validate(one)); } @Test - public void uriThatPointsToNodeThatDoesNotExistShouldFail_Uri() { + void uriThatPointsToNodeThatDoesNotExistShouldFail_Uri() { // This test failed before adding the 10-millisecond sleep. IllegalStateException is returned with recursive update error. This only happens on my faster desktop // computer during 'maven clean install'. It passes within the IDE on the same computer. It passes on my slower laptop. It passes on Travis CI. try { diff --git a/src/test/java/com/networknt/schema/Issue650Test.java b/src/test/java/com/networknt/schema/Issue650Test.java index dabbd7c5e..888e740d8 100644 --- a/src/test/java/com/networknt/schema/Issue650Test.java +++ b/src/test/java/com/networknt/schema/Issue650Test.java @@ -18,7 +18,7 @@ * @author k-oliver * @since 1.0.77 */ -public class Issue650Test { +class Issue650Test { /** * Test using a Java model with a byte[] property which jackson converts to a BASE64 encoded string automatically. Then convert into @@ -29,7 +29,7 @@ public class Issue650Test { * @since 1.0.77 */ @Test - public void testBinaryNode() throws Exception { + void testBinaryNode() throws Exception { final ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); diff --git a/src/test/java/com/networknt/schema/Issue662Test.java b/src/test/java/com/networknt/schema/Issue662Test.java index 25fcb1fe5..9290118a9 100644 --- a/src/test/java/com/networknt/schema/Issue662Test.java +++ b/src/test/java/com/networknt/schema/Issue662Test.java @@ -11,7 +11,7 @@ import static java.util.stream.Collectors.toList; import static org.junit.jupiter.api.Assertions.assertTrue; -public class Issue662Test extends BaseJsonSchemaValidatorTest { +class Issue662Test extends BaseJsonSchemaValidatorTest { private static final String RESOURCE_PREFIX = "issues/662/"; private static JsonSchema schema; diff --git a/src/test/java/com/networknt/schema/Issue665Test.java b/src/test/java/com/networknt/schema/Issue665Test.java index 23044c0a2..38f9f4235 100644 --- a/src/test/java/com/networknt/schema/Issue665Test.java +++ b/src/test/java/com/networknt/schema/Issue665Test.java @@ -9,7 +9,7 @@ import java.util.Collections; import java.util.Set; -public class Issue665Test extends BaseJsonSchemaValidatorTest { +class Issue665Test extends BaseJsonSchemaValidatorTest { @Test void testUrnUriAsLocalRef() throws IOException { diff --git a/src/test/java/com/networknt/schema/Issue686Test.java b/src/test/java/com/networknt/schema/Issue686Test.java index 0148dfac5..af2ba2f28 100644 --- a/src/test/java/com/networknt/schema/Issue686Test.java +++ b/src/test/java/com/networknt/schema/Issue686Test.java @@ -14,7 +14,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class Issue686Test { +class Issue686Test { @Test void testDefaults() { diff --git a/src/test/java/com/networknt/schema/Issue687Test.java b/src/test/java/com/networknt/schema/Issue687Test.java index fb4d6e0f4..0789acd54 100644 --- a/src/test/java/com/networknt/schema/Issue687Test.java +++ b/src/test/java/com/networknt/schema/Issue687Test.java @@ -13,7 +13,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -public class Issue687Test { +class Issue687Test { @Test void testRoot() { @@ -27,7 +27,7 @@ void testDefault() { assertEquals(PathType.LEGACY, PathType.DEFAULT); } - public static Stream appendTokens() { + static Stream appendTokens() { return Stream.of( Arguments.of(PathType.LEGACY, "$.foo", "bar", "$.foo.bar"), Arguments.of(PathType.LEGACY, "$.foo", "b.ar", "$.foo.b.ar"), @@ -46,7 +46,7 @@ public static Stream appendTokens() { ); } - public static Stream appendIndexes() { + static Stream appendIndexes() { return Stream.of( Arguments.of(PathType.LEGACY, "$.foo", 0, "$.foo[0]"), Arguments.of(PathType.JSON_PATH, "$.foo", 0, "$.foo[0]"), @@ -54,7 +54,7 @@ public static Stream appendIndexes() { ); } - public static Stream validationMessages() { + static Stream validationMessages() { String schemaPath = "/schema/issue687.json"; String content = "{ \"foo\": \"a\", \"b.ar\": 1, \"children\": [ { \"childFoo\": \"a\", \"c/hildBar\": 1 } ] }"; return Stream.of( @@ -90,7 +90,7 @@ void testValidationMessage(PathType pathType, String schemaPath, String content, } } - public static Stream specialCharacterTests() { + static Stream specialCharacterTests() { return Stream.of( Arguments.of(PathType.JSON_PATH, "'", "$['\\'']"), Arguments.of(PathType.JSON_PATH, "\\\"", "$['\"']"), diff --git a/src/test/java/com/networknt/schema/Issue784Test.java b/src/test/java/com/networknt/schema/Issue784Test.java index 4f8dbdcf6..0e5f79b8a 100644 --- a/src/test/java/com/networknt/schema/Issue784Test.java +++ b/src/test/java/com/networknt/schema/Issue784Test.java @@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class Issue784Test { +class Issue784Test { private static final String FOO_BAR = "foo-bar"; private static final String SOMETHING_ELSE = "something-else"; @@ -34,7 +34,7 @@ public String getErrorMessageDescription() { } @Test - public void allowToOverrideDataTime() throws IOException { + void allowToOverrideDataTime() throws IOException { JsonSchema jsonSchema = createSchema(true); // Custom validator checks for FOO_BAR @@ -45,7 +45,7 @@ public void allowToOverrideDataTime() throws IOException { } @Test - public void useDefaultValidatorIfNotOverriden() throws IOException { + void useDefaultValidatorIfNotOverriden() throws IOException { JsonSchema jsonSchema = createSchema(false); // Default validator fails with FOO_BAR diff --git a/src/test/java/com/networknt/schema/Issue792.java b/src/test/java/com/networknt/schema/Issue792.java index c76c12873..44c9a047f 100644 --- a/src/test/java/com/networknt/schema/Issue792.java +++ b/src/test/java/com/networknt/schema/Issue792.java @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test; -public class Issue792 { +class Issue792 { @Test void test() throws JsonProcessingException { diff --git a/src/test/java/com/networknt/schema/Issue824Test.java b/src/test/java/com/networknt/schema/Issue824Test.java index fe8babb7d..ef4ee4ba2 100644 --- a/src/test/java/com/networknt/schema/Issue824Test.java +++ b/src/test/java/com/networknt/schema/Issue824Test.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -public class Issue824Test { +class Issue824Test { @Test void validate() throws JsonProcessingException { final JsonSchema v201909SpecSchema = JsonSchemaFactory diff --git a/src/test/java/com/networknt/schema/Issue832Test.java b/src/test/java/com/networknt/schema/Issue832Test.java index 151896886..02c776304 100644 --- a/src/test/java/com/networknt/schema/Issue832Test.java +++ b/src/test/java/com/networknt/schema/Issue832Test.java @@ -11,7 +11,7 @@ import java.util.List; import java.util.Set; -public class Issue832Test { +class Issue832Test { private class NoMatchFormat implements Format { @Override public boolean matches(ExecutionContext executionContext, String value) { @@ -48,7 +48,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws IOEx } @Test - public void testV7WithNonMatchingCustomFormat() throws IOException { + void testV7WithNonMatchingCustomFormat() throws IOException { String schemaPath = "/schema/issue832-v7.json"; String dataPath = "/data/issue832.json"; InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); diff --git a/src/test/java/com/networknt/schema/Issue857Test.java b/src/test/java/com/networknt/schema/Issue857Test.java index 045ce23f7..51115765d 100644 --- a/src/test/java/com/networknt/schema/Issue857Test.java +++ b/src/test/java/com/networknt/schema/Issue857Test.java @@ -23,7 +23,7 @@ import com.networknt.schema.SpecVersion.VersionFlag; -public class Issue857Test { +class Issue857Test { @Test void test() { String schema = "{\r\n" diff --git a/src/test/java/com/networknt/schema/Issue877Test.java b/src/test/java/com/networknt/schema/Issue877Test.java index ab5740457..899723d24 100644 --- a/src/test/java/com/networknt/schema/Issue877Test.java +++ b/src/test/java/com/networknt/schema/Issue877Test.java @@ -22,9 +22,9 @@ import com.networknt.schema.SpecVersion.VersionFlag; import com.networknt.schema.serialization.JsonMapperFactory; -public class Issue877Test { +class Issue877Test { @Test - public void test() throws Exception { + void test() throws Exception { String schemaData = "{\n" + " \"type\": \"object\",\n" + " \"unevaluatedProperties\": false\n" diff --git a/src/test/java/com/networknt/schema/Issue927Test.java b/src/test/java/com/networknt/schema/Issue927Test.java index 5a56e2c8d..7e723ff21 100644 --- a/src/test/java/com/networknt/schema/Issue927Test.java +++ b/src/test/java/com/networknt/schema/Issue927Test.java @@ -22,16 +22,15 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.networknt.schema.SpecVersion.VersionFlag; import com.networknt.schema.serialization.JsonMapperFactory; /** * Test that the code isn't confused by an anchor in the id. */ -public class Issue927Test { +class Issue927Test { @Test - void test() throws JsonMappingException, JsonProcessingException { + void test() throws JsonProcessingException { String schema = "{\r\n" + " \"$schema\": \"http://json-schema.org/draft-07/schema#\",\r\n" + " \"$id\": \"id\",\r\n" diff --git a/src/test/java/com/networknt/schema/Issue928Test.java b/src/test/java/com/networknt/schema/Issue928Test.java index 96739aed0..2b70f0a30 100644 --- a/src/test/java/com/networknt/schema/Issue928Test.java +++ b/src/test/java/com/networknt/schema/Issue928Test.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class Issue928Test { +class Issue928Test { private final ObjectMapper mapper = new ObjectMapper(); private JsonSchemaFactory factoryFor(SpecVersion.VersionFlag version) { @@ -15,21 +15,21 @@ private JsonSchemaFactory factoryFor(SpecVersion.VersionFlag version) { } @Test - public void test_07() { + void test_07() { test_spec(SpecVersion.VersionFlag.V7); } @Test - public void test_201909() { + void test_201909() { test_spec(SpecVersion.VersionFlag.V201909); } @Test - public void test_202012() { + void test_202012() { test_spec(SpecVersion.VersionFlag.V202012); } - public void test_spec(SpecVersion.VersionFlag specVersion) { + void test_spec(SpecVersion.VersionFlag specVersion) { JsonSchemaFactory schemaFactory = factoryFor(specVersion); String versionId = specVersion.getId(); diff --git a/src/test/java/com/networknt/schema/Issue935Test.java b/src/test/java/com/networknt/schema/Issue935Test.java index fdc018609..e604cf0b3 100644 --- a/src/test/java/com/networknt/schema/Issue935Test.java +++ b/src/test/java/com/networknt/schema/Issue935Test.java @@ -21,7 +21,7 @@ import com.networknt.schema.SpecVersion.VersionFlag; -public class Issue935Test { +class Issue935Test { @Test void shouldThrowInvalidSchemaException() { String schema = "{ \"$schema\": \"0\" }"; diff --git a/src/test/java/com/networknt/schema/Issue936Test.java b/src/test/java/com/networknt/schema/Issue936Test.java index 65e56c179..fe8d9300f 100644 --- a/src/test/java/com/networknt/schema/Issue936Test.java +++ b/src/test/java/com/networknt/schema/Issue936Test.java @@ -22,7 +22,7 @@ import com.networknt.schema.SpecVersion.VersionFlag; -public class Issue936Test { +class Issue936Test { @Test void shouldThrowInvalidSchemaException() { String schema = "{\r\n" + " \"$id\": \"0\",\r\n" diff --git a/src/test/java/com/networknt/schema/Issue939Test.java b/src/test/java/com/networknt/schema/Issue939Test.java index 19b36c73d..ae8eea594 100644 --- a/src/test/java/com/networknt/schema/Issue939Test.java +++ b/src/test/java/com/networknt/schema/Issue939Test.java @@ -24,7 +24,7 @@ import com.networknt.schema.SpecVersion.VersionFlag; -public class Issue939Test { +class Issue939Test { @Test void shouldNotThrowException() { String schema = "{\r\n" diff --git a/src/test/java/com/networknt/schema/Issue940Test.java b/src/test/java/com/networknt/schema/Issue940Test.java index de30e9bff..75b19a7a7 100644 --- a/src/test/java/com/networknt/schema/Issue940Test.java +++ b/src/test/java/com/networknt/schema/Issue940Test.java @@ -21,7 +21,7 @@ import com.networknt.schema.SpecVersion.VersionFlag; -public class Issue940Test { +class Issue940Test { @Test void shouldNotThrowException() { String schema = "{\r\n" diff --git a/src/test/java/com/networknt/schema/Issue943Test.java b/src/test/java/com/networknt/schema/Issue943Test.java index 2cf9c32b3..d90bcbd7d 100644 --- a/src/test/java/com/networknt/schema/Issue943Test.java +++ b/src/test/java/com/networknt/schema/Issue943Test.java @@ -25,7 +25,7 @@ import com.networknt.schema.SpecVersion.VersionFlag; -public class Issue943Test { +class Issue943Test { @Test void test() { Map external = new HashMap<>(); diff --git a/src/test/java/com/networknt/schema/Issue994Test.java b/src/test/java/com/networknt/schema/Issue994Test.java index 52a612d1f..ae3e4eee6 100644 --- a/src/test/java/com/networknt/schema/Issue994Test.java +++ b/src/test/java/com/networknt/schema/Issue994Test.java @@ -21,14 +21,13 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.SpecVersion.VersionFlag; import com.networknt.schema.serialization.JsonMapperFactory; -public class Issue994Test { +class Issue994Test { @Test - void test() throws JsonMappingException, JsonProcessingException { + void test() throws JsonProcessingException { String schemaData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\r\n" + " \"type\": \"object\",\r\n" diff --git a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java index 24d77718b..ed8dda7da 100644 --- a/src/test/java/com/networknt/schema/ItemsValidator202012Test.java +++ b/src/test/java/com/networknt/schema/ItemsValidator202012Test.java @@ -34,7 +34,7 @@ /** * ItemsValidatorTest. */ -public class ItemsValidator202012Test { +class ItemsValidator202012Test { /** * Tests that the message contains the correct values when there are invalid * items. diff --git a/src/test/java/com/networknt/schema/ItemsValidatorTest.java b/src/test/java/com/networknt/schema/ItemsValidatorTest.java index 9864f73d3..a09d86359 100644 --- a/src/test/java/com/networknt/schema/ItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/ItemsValidatorTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.SpecVersion.VersionFlag; import com.networknt.schema.serialization.JsonMapperFactory; @@ -38,7 +37,7 @@ /** * ItemsValidatorTest. */ -public class ItemsValidatorTest { +class ItemsValidatorTest { /** * Tests that the message contains the correct values when there are invalid * items. @@ -240,7 +239,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set validationMess } @Test - void walkTupleItemsAdditional() throws JsonMappingException, JsonProcessingException { + void walkTupleItemsAdditional() throws JsonProcessingException { String schemaData = "{\r\n" + " \"items\": [\r\n" + " {\r\n" @@ -291,7 +290,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set validationMess } @Test - void walkTupleItemsAdditionalDefaults() throws JsonMappingException, JsonProcessingException { + void walkTupleItemsAdditionalDefaults() throws JsonProcessingException { String schemaData = "{\r\n" + " \"items\": [\r\n" + " {\r\n" diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java index 474222049..956352fef 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryTest.java @@ -50,7 +50,7 @@ void concurrency() { .singletonMap("https://www.example.com/no-validation-no-format/schema", metaSchemaData)))); AtomicBoolean failed = new AtomicBoolean(false); - JsonMetaSchema[] instance = new JsonMetaSchema[1];; + JsonMetaSchema[] instance = new JsonMetaSchema[1]; CountDownLatch latch = new CountDownLatch(1); List threads = new ArrayList<>(); for (int i = 0; i < 50; ++i) { diff --git a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java index 31d4854b1..7297fde18 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaFactoryUriCacheTest.java @@ -15,17 +15,17 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class JsonSchemaFactoryUriCacheTest { +class JsonSchemaFactoryUriCacheTest { private final ObjectMapper objectMapper = new ObjectMapper(); @Test - public void cacheEnabled() throws JsonProcessingException { + void cacheEnabled() throws JsonProcessingException { runCacheTest(true); } @Test - public void cacheDisabled() throws JsonProcessingException { + void cacheDisabled() throws JsonProcessingException { runCacheTest(false); } @@ -53,7 +53,7 @@ private JsonSchemaFactory buildJsonSchemaFactory(CustomURIFetcher uriFetcher, bo private class CustomURIFetcher implements SchemaLoader { - private Map uriToResource = new HashMap<>(); + private final Map uriToResource = new HashMap<>(); void addResource(AbsoluteIri uri, String schema) { addResource(uri, new ByteArrayInputStream(schema.getBytes(StandardCharsets.UTF_8))); diff --git a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java index d2a467814..23b900b31 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaPreloadTest.java @@ -23,7 +23,7 @@ /** * Test to control preloading of schemas. */ -public class JsonSchemaPreloadTest { +class JsonSchemaPreloadTest { @Test void cacheRefsFalse() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7); diff --git a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java index 8528b12b6..880c8e647 100644 --- a/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java +++ b/src/test/java/com/networknt/schema/JsonSchemaTestSuiteTest.java @@ -17,7 +17,7 @@ class JsonSchemaTestSuiteTest extends AbstractJsonSchemaTestSuite { private final Map disabled; - public JsonSchemaTestSuiteTest() { + JsonSchemaTestSuiteTest() { this.disabled = new HashMap<>(); disableV202012Tests(); diff --git a/src/test/java/com/networknt/schema/JsonWalkTest.java b/src/test/java/com/networknt/schema/JsonWalkTest.java index d8020ebc9..99d73c6ae 100644 --- a/src/test/java/com/networknt/schema/JsonWalkTest.java +++ b/src/test/java/com/networknt/schema/JsonWalkTest.java @@ -18,7 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class JsonWalkTest { +class JsonWalkTest { private JsonSchema jsonSchema; @@ -29,7 +29,7 @@ public class JsonWalkTest { private static final String CUSTOM_KEYWORD = "custom-keyword"; @BeforeEach - public void setup() { + void setup() { setupSchema(); } @@ -60,7 +60,7 @@ private JsonMetaSchema getJsonMetaSchema() { } @Test - public void testWalk() throws IOException { + void testWalk() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); ValidationResult result = jsonSchema.walk( objectMapper.readTree(getClass().getClassLoader().getResourceAsStream("data/walk-data.json")), false); @@ -79,7 +79,7 @@ public void testWalk() throws IOException { } @Test - public void testWalkWithDifferentListeners() throws IOException { + void testWalkWithDifferentListeners() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); // This instance of schema contains all listeners. ValidationResult result = jsonSchema.walk( @@ -140,13 +140,13 @@ public JsonValidator newValidator(SchemaLocation schemaLocation, JsonNodePath ev */ private static class CustomValidator extends AbstractJsonValidator { - public CustomValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { + CustomValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode) { super(schemaLocation, evaluationPath, new CustomKeyword(), schemaNode); } @Override public Set validate(ExecutionContext executionContext, JsonNode node, JsonNode rootNode, JsonNodePath instanceLocation) { - return new TreeSet(); + return new TreeSet<>(); } @Override diff --git a/src/test/java/com/networknt/schema/LocaleTest.java b/src/test/java/com/networknt/schema/LocaleTest.java index d8783e2a9..02f69cf95 100644 --- a/src/test/java/com/networknt/schema/LocaleTest.java +++ b/src/test/java/com/networknt/schema/LocaleTest.java @@ -33,7 +33,7 @@ import com.networknt.schema.i18n.Locales; import com.networknt.schema.serialization.JsonMapperFactory; -public class LocaleTest { +class LocaleTest { private JsonSchema getSchema(SchemaValidatorsConfig config) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); return factory.getSchema( diff --git a/src/test/java/com/networknt/schema/MaximumValidatorPerfTest.java b/src/test/java/com/networknt/schema/MaximumValidatorPerfTest.java index 99d90272e..f3e689687 100644 --- a/src/test/java/com/networknt/schema/MaximumValidatorPerfTest.java +++ b/src/test/java/com/networknt/schema/MaximumValidatorPerfTest.java @@ -26,11 +26,11 @@ import java.util.List; @Disabled -public class MaximumValidatorPerfTest { +class MaximumValidatorPerfTest { MaximumValidatorTest test = new MaximumValidatorTest(); @Test - public void testTime() throws InvocationTargetException, IllegalAccessException { + void testTime() throws InvocationTargetException, IllegalAccessException { String[] testMethodsToBeExecuted = {"testMaximumDoubleValue"}; List testMethods = getTestMethods(testMethodsToBeExecuted); long start = System.currentTimeMillis(); @@ -39,7 +39,7 @@ public void testTime() throws InvocationTargetException, IllegalAccessException System.out.println("time to execute all tests using:" + (end - start) + "ms"); } - public void executeTests(List methods, int executeTimes) throws InvocationTargetException, IllegalAccessException { + void executeTests(List methods, int executeTimes) throws InvocationTargetException, IllegalAccessException { for (int i = 0; i < executeTimes; i++) { for (Method testMethod : methods) { @@ -49,7 +49,7 @@ public void executeTests(List methods, int executeTimes) throws Invocati } - public List getTestMethods(String[] methodNames) { + List getTestMethods(String[] methodNames) { Method[] methods = test.getClass().getMethods(); List testMethods = new ArrayList(); if (methodNames.length > 0) { diff --git a/src/test/java/com/networknt/schema/MaximumValidatorTest.java b/src/test/java/com/networknt/schema/MaximumValidatorTest.java index ff65cc9d3..5d16fd7e1 100644 --- a/src/test/java/com/networknt/schema/MaximumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MaximumValidatorTest.java @@ -29,19 +29,19 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public class MaximumValidatorTest extends BaseJsonSchemaValidatorTest { +class MaximumValidatorTest extends BaseJsonSchemaValidatorTest { private static final String INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"maximum\": %s }"; private static final String NUMBER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"number\", \"maximum\": %s }"; private static final String EXCLUSIVE_INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"maximum\": %s, \"exclusiveMaximum\": true}"; - private static JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); - private static ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper mapper = new ObjectMapper(); // due to a jackson bug, a float number which is larger than Double.POSITIVE_INFINITY cannot be convert to BigDecimal correctly // https://github.com/FasterXML/jackson-databind/issues/1770 // https://github.com/FasterXML/jackson-databind/issues/2087 - private static ObjectMapper bigDecimalMapper = new ObjectMapper().enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS); - private static ObjectMapper bigIntegerMapper = new ObjectMapper().enable(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS); + private static final ObjectMapper bigDecimalMapper = new ObjectMapper().enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS); + private static final ObjectMapper bigIntegerMapper = new ObjectMapper().enable(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS); static String[][] augmentWithQuotes(String[][] values) { for (int i = 0; i < values.length; i++) { @@ -52,7 +52,7 @@ static String[][] augmentWithQuotes(String[][] values) { } @Test - public void positiveNumber() throws IOException { + void positiveNumber() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // maximum, value {"1000.1", "1000"}, @@ -64,7 +64,7 @@ public void positiveNumber() throws IOException { } @Test - public void negativeNumber() throws IOException { + void negativeNumber() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // maximum, value // These values overflow 64bit IEEE 754 @@ -86,7 +86,7 @@ public void negativeNumber() throws IOException { } @Test - public void positiveInteger() throws IOException { + void positiveInteger() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // maximum, value {"9223372036854775807", "9223372036854775807"}, @@ -105,7 +105,7 @@ public void positiveInteger() throws IOException { } @Test - public void negativeInteger() throws IOException { + void negativeInteger() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // maximum, value {"9223372036854775800", "9223372036854775855"}, @@ -123,7 +123,7 @@ public void negativeInteger() throws IOException { } @Test - public void positiveExclusiveInteger() throws IOException { + void positiveExclusiveInteger() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // maximum, value {"9223372036854775000", "9223372036854774988"}, @@ -142,7 +142,7 @@ public void positiveExclusiveInteger() throws IOException { } @Test - public void negativeExclusiveInteger() throws IOException { + void negativeExclusiveInteger() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // maximum, value {"10", "20"}, @@ -160,7 +160,7 @@ public void negativeExclusiveInteger() throws IOException { } @Test - public void negativeDoubleOverflowTest() throws IOException { + void negativeDoubleOverflowTest() throws IOException { String[][] values = new String[][]{ // maximum, value // both of these get parsed into double (with a precision loss) as 1.7976931348623157E+308 @@ -221,7 +221,7 @@ public void negativeDoubleOverflowTest() throws IOException { * the only way to spot this is to use BigDecimal for schema (and for document) */ @Test - public void doubleValueCoarsing() throws IOException { + void doubleValueCoarsing() throws IOException { String schema = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"number\", \"maximum\": 1.7976931348623157e+308 }"; String content = "1.7976931348623158e+308"; @@ -253,7 +253,7 @@ public void doubleValueCoarsing() throws IOException { * BigDecimalMapper issue, it doesn't work as expected, it will treat 1.7976931348623159e+308 as INFINITY instead of as it is. */ @Test - public void doubleValueCoarsingExceedRange() throws IOException { + void doubleValueCoarsingExceedRange() throws IOException { String schema = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"number\", \"maximum\": 1.7976931348623159e+308 }"; String content = "1.7976931348623160e+308"; diff --git a/src/test/java/com/networknt/schema/MessageTest.java b/src/test/java/com/networknt/schema/MessageTest.java index 3a3faa7da..3c270e894 100644 --- a/src/test/java/com/networknt/schema/MessageTest.java +++ b/src/test/java/com/networknt/schema/MessageTest.java @@ -28,18 +28,13 @@ /** * Test for messages. */ -public class MessageTest { - public static class EqualsValidator extends BaseJsonValidator { - private static ErrorMessageType ERROR_MESSAGE_TYPE = new ErrorMessageType() { - @Override - public String getErrorCode() { - return "equals"; - } - }; +class MessageTest { + static class EqualsValidator extends BaseJsonValidator { + private static final ErrorMessageType ERROR_MESSAGE_TYPE = () -> "equals"; private final String value; - public EqualsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, + EqualsValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, JsonSchema parentSchema, Keyword keyword, ValidationContext validationContext, boolean suppressSubSchemaRetrieval) { super(schemaLocation, evaluationPath, schemaNode, parentSchema, ERROR_MESSAGE_TYPE, keyword, validationContext, @@ -55,12 +50,12 @@ public Set validate(ExecutionContext executionContext, JsonNo .singleton(message().message("{0}: must be equal to ''{1}''") .arguments(value) .instanceLocation(instanceLocation).instanceNode(node).build()); - }; + } return Collections.emptySet(); } } - public static class EqualsKeyword implements Keyword { + static class EqualsKeyword implements Keyword { @Override public String getValue() { diff --git a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java index fa7e35f2c..5abb681de 100644 --- a/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java +++ b/src/test/java/com/networknt/schema/MetaSchemaValidationTest.java @@ -30,7 +30,7 @@ /** * Tests for meta schema validating a schema. */ -public class MetaSchemaValidationTest { +class MetaSchemaValidationTest { /** * Validates a OpenAPI 3.1 schema using the OpenAPI 3.1 meta schema. * diff --git a/src/test/java/com/networknt/schema/MinimumValidatorTest.java b/src/test/java/com/networknt/schema/MinimumValidatorTest.java index 8ce5f300b..baedd665a 100644 --- a/src/test/java/com/networknt/schema/MinimumValidatorTest.java +++ b/src/test/java/com/networknt/schema/MinimumValidatorTest.java @@ -32,20 +32,20 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -public class MinimumValidatorTest { +class MinimumValidatorTest { private static final String NUMBER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"number\", \"minimum\": %s }"; private static final String EXCLUSIVE_INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"minimum\": %s, \"exclusiveMinimum\": true}"; private static final String INTEGER = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"minimum\": %s }"; private static final String NEGATIVE_MESSAGE_TEMPLATE = "Expecting validation errors, value %s is smaller than minimum %s"; private static final String POSITIVT_MESSAGE_TEMPLATE = "Expecting no validation errors, value %s is greater than minimum %s"; - private static JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); private static ObjectMapper mapper; private static ObjectMapper bigDecimalMapper; private static ObjectMapper bigIntegerMapper; @BeforeEach - public void setUp() { + void setUp() { mapper = new ObjectMapper(); // due to a jackson bug, a float number which is larger than Double.POSITIVE_INFINITY cannot be convert to BigDecimal correctly // https://github.com/FasterXML/jackson-databind/issues/1770 @@ -56,7 +56,7 @@ public void setUp() { } @Test - public void positiveNumber() throws IOException { + void positiveNumber() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // minimum, value {"1000", "1000.1"}, @@ -66,7 +66,7 @@ public void positiveNumber() throws IOException { } @Test - public void negativeNumber() throws IOException { + void negativeNumber() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // minimum, value {"-1.7976931348623157e+308", "-1.7976931348623159e+308"}, @@ -85,7 +85,7 @@ public void negativeNumber() throws IOException { } @Test - public void positiveInteger() throws IOException { + void positiveInteger() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // minimum, value {"-1E309", "-1000"}, @@ -97,7 +97,7 @@ public void positiveInteger() throws IOException { } @Test - public void negativeInteger() throws IOException { + void negativeInteger() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // minimum, value {"-9223372036854775800", "-9223372036854775855"}, @@ -110,7 +110,7 @@ public void negativeInteger() throws IOException { } @Test - public void positiveExclusiveInteger() throws IOException { + void positiveExclusiveInteger() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // minimum, value {"-9223372036854775000", "-9223372036854774988"}, @@ -127,7 +127,7 @@ public void positiveExclusiveInteger() throws IOException { } @Test - public void negativeExclusiveInteger() throws IOException { + void negativeExclusiveInteger() throws IOException { String[][] values = augmentWithQuotes(new String[][]{ // minimum, value {"20", "10"}, @@ -143,7 +143,7 @@ public void negativeExclusiveInteger() throws IOException { } @Test - public void negativeDoubleOverflowTest() throws IOException { + void negativeDoubleOverflowTest() throws IOException { String[][] values = { // minimum, value {"-1.79769313486231571E+308", "-1.79769313486231572e+308"}, @@ -213,7 +213,7 @@ public void negativeDoubleOverflowTest() throws IOException { * the only way to spot this is to use BigDecimal for schema (and for document) */ @Test - public void doubleValueCoarsing() throws IOException { + void doubleValueCoarsing() throws IOException { String schema = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"number\", \"minimum\": -1.7976931348623157e+308 }"; String content = "-1.7976931348623158e+308"; @@ -243,7 +243,7 @@ public void doubleValueCoarsing() throws IOException { * BigDecimalMapper issue, it doesn't work as expected, it will treat -1.7976931348623157e+309 as INFINITY instead of as it is. */ @Test - public void doubleValueCoarsingExceedRange() throws IOException { + void doubleValueCoarsingExceedRange() throws IOException { String schema = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"number\", \"minimum\": -1.7976931348623159e+308 }"; String content = "-1.7976931348623160e+308"; diff --git a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java index 02ba8d439..cc6810d5c 100644 --- a/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/MultipleOfValidatorTest.java @@ -26,7 +26,7 @@ /** * Test MultipleOfValidator validator. */ -public class MultipleOfValidatorTest { +class MultipleOfValidatorTest { String schemaData = "{" + " \"type\": \"object\"," + " \"properties\": {" + diff --git a/src/test/java/com/networknt/schema/OneOfValidatorTest.java b/src/test/java/com/networknt/schema/OneOfValidatorTest.java index 4fdb14a03..6800595cc 100644 --- a/src/test/java/com/networknt/schema/OneOfValidatorTest.java +++ b/src/test/java/com/networknt/schema/OneOfValidatorTest.java @@ -33,7 +33,7 @@ /** * OneOfValidatorTest. */ -public class OneOfValidatorTest { +class OneOfValidatorTest { @Test void oneOfMultiple() { String schemaData = "{\r\n" @@ -147,7 +147,7 @@ void invalidTypeShouldThrowJsonSchemaException() { * This test checks that the oneOf example at * https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/ * behaves according to the specification instead of the example. - * + *

* https://github.com/swagger-api/swagger.io/issues/253 * https://github.com/OAI/OpenAPI-Specification/issues/3477 * https://github.com/networknt/json-schema-validator/issues/110 @@ -215,7 +215,7 @@ void invalidSwaggerIoExample() { * This test checks that the oneOf example at * https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/ * behaves according to the specification instead of the example. - * + *

* https://github.com/swagger-api/swagger.io/issues/253 * https://github.com/OAI/OpenAPI-Specification/issues/3477 * https://github.com/networknt/json-schema-validator/issues/110 diff --git a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java index e39d1f379..c1d09019c 100644 --- a/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/OpenAPI30JsonSchemaTest.java @@ -12,12 +12,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -public class OpenAPI30JsonSchemaTest extends HTTPServiceSupport { +class OpenAPI30JsonSchemaTest extends HTTPServiceSupport { protected ObjectMapper mapper = new ObjectMapper(); protected JsonSchemaFactory validatorFactory = JsonSchemaFactory .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)).build(); - public OpenAPI30JsonSchemaTest() { + OpenAPI30JsonSchemaTest() { } private void runTestFile(String testCaseFile) throws Exception { @@ -48,7 +48,7 @@ private void runTestFile(String testCaseFile) throws Exception { if (test.get("valid").asBoolean()) { if (!errors.isEmpty()) { System.out.println("---- test case failed ----"); - System.out.println("schema: " + schema.toString()); + System.out.println("schema: " + schema); System.out.println("data: " + test.get("data")); System.out.println("errors:"); for (ValidationMessage error : errors) { @@ -84,7 +84,7 @@ private void runTestFile(String testCaseFile) throws Exception { } @Test - public void testDiscriminatorMapping() throws Exception { + void testDiscriminatorMapping() throws Exception { runTestFile("openapi3/discriminator.json"); } } diff --git a/src/test/java/com/networknt/schema/OutputFormatTest.java b/src/test/java/com/networknt/schema/OutputFormatTest.java index 558abfb76..c834e0a9b 100644 --- a/src/test/java/com/networknt/schema/OutputFormatTest.java +++ b/src/test/java/com/networknt/schema/OutputFormatTest.java @@ -22,8 +22,8 @@ class OutputFormatTest { - private static JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); - private static String schemaPath1 = "/schema/output-format-schema.json"; + private static final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); + private static final String schemaPath1 = "/schema/output-format-schema.json"; private JsonNode getJsonNodeFromJsonData(String jsonFilePath) throws Exception { InputStream content = getClass().getResourceAsStream(jsonFilePath); diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index 38c24e10a..2f0f7a12c 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -41,7 +41,7 @@ * Specification for Machine-Readable Output for JSON Schema Validation and * Annotation */ -public class OutputUnitTest { +class OutputUnitTest { String schemaData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\r\n" + " \"$id\": \"https://json-schema.org/schemas/example\",\r\n" diff --git a/src/test/java/com/networknt/schema/OverrideValidatorTest.java b/src/test/java/com/networknt/schema/OverrideValidatorTest.java index b5dbcd8b0..0957dce54 100644 --- a/src/test/java/com/networknt/schema/OverrideValidatorTest.java +++ b/src/test/java/com/networknt/schema/OverrideValidatorTest.java @@ -28,10 +28,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class OverrideValidatorTest { +class OverrideValidatorTest { @Test - public void overrideDefaultValidator() throws JsonProcessingException, IOException { + void overrideDefaultValidator() throws JsonProcessingException, IOException { ObjectMapper objectMapper = new ObjectMapper(); final String URI = "https://github.com/networknt/json-schema-validator/tests/schemas/example01"; final String schema = "{\n" + diff --git a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java index a84d4ff6e..35076ca46 100644 --- a/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java +++ b/src/test/java/com/networknt/schema/OverwritingCustomMessageBugTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class OverwritingCustomMessageBugTest { +class OverwritingCustomMessageBugTest { private JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7); return factory.getSchema(schemaContent); @@ -22,7 +22,7 @@ private JsonNode getJsonNodeFromStreamContent(InputStream content) throws Except } @Test - public void customMessageIsNotOverwritten() throws Exception { + void customMessageIsNotOverwritten() throws Exception { Set errors = validate(); Map errorMsgMap = transferErrorMsg(errors); Assertions.assertTrue(errorMsgMap.containsKey("$.toplevel[1].foos"), "error message must contains key: $.foos"); diff --git a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java index 14c45cbe4..444b7ea75 100644 --- a/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java @@ -35,10 +35,10 @@ /** * Created by steve on 22/10/16. */ -public class PatternPropertiesValidatorTest extends BaseJsonSchemaValidatorTest { +class PatternPropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test - public void testInvalidPatternPropertiesValidator() throws Exception { + void testInvalidPatternPropertiesValidator() throws Exception { Assertions.assertThrows(JsonSchemaException.class, () -> { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); JsonSchema schema = factory.getSchema("{\"patternProperties\":6}"); @@ -50,7 +50,7 @@ public void testInvalidPatternPropertiesValidator() throws Exception { } @Test - public void testInvalidPatternPropertiesValidatorECMA262() throws Exception { + void testInvalidPatternPropertiesValidatorECMA262() throws Exception { Assertions.assertThrows(JsonSchemaException.class, () -> { SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() .regularExpressionFactory(JoniRegularExpressionFactory.getInstance()) diff --git a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java index 9b561d6de..d103650e7 100644 --- a/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/PrefixItemsValidatorTest.java @@ -5,7 +5,6 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.SpecVersion.VersionFlag; import com.networknt.schema.serialization.JsonMapperFactory; @@ -27,7 +26,7 @@ /** * This class handles exception case for {@link PrefixItemsValidator} */ -public class PrefixItemsValidatorTest extends AbstractJsonSchemaTestSuite { +class PrefixItemsValidatorTest extends AbstractJsonSchemaTestSuite { /** * this method create test cases from JSON and run those test cases with assertion @@ -167,7 +166,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set validationMess } @Test - void walkDefaults() throws JsonMappingException, JsonProcessingException { + void walkDefaults() throws JsonProcessingException { String schemaData = "{\n" + " \"prefixItems\": [\n" + " {\n" diff --git a/src/test/java/com/networknt/schema/PropertiesTest.java b/src/test/java/com/networknt/schema/PropertiesTest.java index aaca8cb73..083a550ed 100644 --- a/src/test/java/com/networknt/schema/PropertiesTest.java +++ b/src/test/java/com/networknt/schema/PropertiesTest.java @@ -9,7 +9,7 @@ import java.util.stream.Stream; @DisplayName("Properties") -public class PropertiesTest extends AbstractJsonSchemaTestSuite { +class PropertiesTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09") diff --git a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java index 9717100d5..b9de07034 100644 --- a/src/test/java/com/networknt/schema/PropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertiesValidatorTest.java @@ -7,10 +7,10 @@ /** * Created by josejulio on 25/04/22. */ -public class PropertiesValidatorTest extends BaseJsonSchemaValidatorTest { +class PropertiesValidatorTest extends BaseJsonSchemaValidatorTest { @Test - public void testDoesNotThrowWhenApplyingDefaultPropertiesToNonObjects() throws Exception { + void testDoesNotThrowWhenApplyingDefaultPropertiesToNonObjects() throws Exception { Assertions.assertDoesNotThrow(() -> { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); diff --git a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java index 81a8837cf..28216e173 100644 --- a/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java +++ b/src/test/java/com/networknt/schema/PropertyNamesValidatorTest.java @@ -27,7 +27,7 @@ /** * PropertyNamesValidatorTest. */ -public class PropertyNamesValidatorTest { +class PropertyNamesValidatorTest { /** * Tests that the message contains the correct values when there are invalid * property names. diff --git a/src/test/java/com/networknt/schema/RefTest.java b/src/test/java/com/networknt/schema/RefTest.java index f84700fcd..4ebcb3f08 100644 --- a/src/test/java/com/networknt/schema/RefTest.java +++ b/src/test/java/com/networknt/schema/RefTest.java @@ -7,15 +7,14 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; -public class RefTest { +class RefTest { private static final ObjectMapper OBJECT_MAPPER = JsonMapper.builder().build(); @Test - void shouldLoadRelativeClasspathReference() throws JsonMappingException, JsonProcessingException { + void shouldLoadRelativeClasspathReference() throws JsonProcessingException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main.json"), config); @@ -38,7 +37,7 @@ void shouldLoadRelativeClasspathReference() throws JsonMappingException, JsonPro } @Test - void shouldLoadSchemaResource() throws JsonMappingException, JsonProcessingException { + void shouldLoadSchemaResource() throws JsonProcessingException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); JsonSchema schema = factory.getSchema(SchemaLocation.of("classpath:///schema/ref-main-schema-resource.json"), config); diff --git a/src/test/java/com/networknt/schema/RefValidatorTest.java b/src/test/java/com/networknt/schema/RefValidatorTest.java index 7da4f5e3b..9c26df4a8 100644 --- a/src/test/java/com/networknt/schema/RefValidatorTest.java +++ b/src/test/java/com/networknt/schema/RefValidatorTest.java @@ -28,7 +28,7 @@ /** * Tests for RefValidator. */ -public class RefValidatorTest { +class RefValidatorTest { @Test void resolveSamePathDotSlash() { String mainSchema = "{\r\n" diff --git a/src/test/java/com/networknt/schema/SampleTest.java b/src/test/java/com/networknt/schema/SampleTest.java index 418bb06b9..80568730c 100644 --- a/src/test/java/com/networknt/schema/SampleTest.java +++ b/src/test/java/com/networknt/schema/SampleTest.java @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.networknt.schema.SpecVersion.VersionFlag; import com.networknt.schema.serialization.JsonMapperFactory; @@ -16,9 +15,9 @@ /** * Sample test. */ -public class SampleTest { +class SampleTest { @Test - void schemaFromSchemaLocationMapping() throws JsonMappingException, JsonProcessingException { + void schemaFromSchemaLocationMapping() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder.schemaMappers( schemaMappers -> schemaMappers.mapPrefix("https://www.example.com/schema", "classpath:schema"))); /* @@ -38,7 +37,7 @@ void schemaFromSchemaLocationMapping() throws JsonMappingException, JsonProcessi } @Test - void schemaFromSchemaLocationContent() throws JsonMappingException, JsonProcessingException { + void schemaFromSchemaLocationContent() { String schemaData = "{\"enum\":[1, 2, 3, 4]}"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, @@ -61,7 +60,7 @@ void schemaFromSchemaLocationContent() throws JsonMappingException, JsonProcessi } @Test - void schemaFromClasspath() throws JsonMappingException, JsonProcessingException { + void schemaFromClasspath() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); /* * This should be cached for performance. @@ -82,7 +81,7 @@ void schemaFromClasspath() throws JsonMappingException, JsonProcessingException } @Test - void schemaFromString() throws JsonMappingException, JsonProcessingException { + void schemaFromString() { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); /* * This should be cached for performance. @@ -98,7 +97,7 @@ void schemaFromString() throws JsonMappingException, JsonProcessingException { } @Test - void schemaFromJsonNode() throws JsonMappingException, JsonProcessingException { + void schemaFromJsonNode() throws JsonProcessingException { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); JsonNode schemaNode = JsonMapperFactory.getInstance().readTree( "{\"$schema\": \"http://json-schema.org/draft-06/schema#\", \"properties\": { \"id\": {\"type\": \"number\"}}}"); diff --git a/src/test/java/com/networknt/schema/SelfRefTest.java b/src/test/java/com/networknt/schema/SelfRefTest.java index feb60e681..5c328f77a 100644 --- a/src/test/java/com/networknt/schema/SelfRefTest.java +++ b/src/test/java/com/networknt/schema/SelfRefTest.java @@ -22,10 +22,10 @@ /** * Created by stevehu on 2016-12-20. */ -public class SelfRefTest extends BaseJsonSchemaValidatorTest { +class SelfRefTest extends BaseJsonSchemaValidatorTest { @Disabled("This test currently is failing because of a StackOverflow caused by a recursive $ref.") @Test() - public void testSelfRef() throws Exception { + void testSelfRef() throws Exception { JsonSchema node = getJsonSchemaFromClasspath("selfRef.json"); System.out.println("node = " + node); } diff --git a/src/test/java/com/networknt/schema/SharedConfigTest.java b/src/test/java/com/networknt/schema/SharedConfigTest.java index b22cea7d4..d18fce110 100644 --- a/src/test/java/com/networknt/schema/SharedConfigTest.java +++ b/src/test/java/com/networknt/schema/SharedConfigTest.java @@ -13,9 +13,9 @@ /** * Issue 918. */ -public class SharedConfigTest { +class SharedConfigTest { private static class AllKeywordListener implements JsonSchemaWalkListener { - public boolean wasCalled = false; + boolean wasCalled = false; @Override public WalkFlow onWalkStart(WalkEvent walkEvent) { @@ -29,7 +29,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set validationMess } @Test - public void shouldCallAllKeywordListenerOnWalkStart() throws Exception { + void shouldCallAllKeywordListenerOnWalkStart() throws Exception { JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); AllKeywordListener allKeywordListener = new AllKeywordListener(); diff --git a/src/test/java/com/networknt/schema/StringCheckerTest.java b/src/test/java/com/networknt/schema/StringCheckerTest.java index 6113046c5..6978a03e1 100755 --- a/src/test/java/com/networknt/schema/StringCheckerTest.java +++ b/src/test/java/com/networknt/schema/StringCheckerTest.java @@ -22,7 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public class StringCheckerTest { +class StringCheckerTest { private static final String[] validNumericValues = { "1", "-1", "1.1", "-1.1", "0E+1", "0E-1", "0E1", "-0E+1", "-0E-1", "-0E1", "0.1E+1", "0.1E-1", "0.1E1", diff --git a/src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java b/src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java index aea1ca49b..98cae3484 100644 --- a/src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java +++ b/src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java @@ -24,12 +24,11 @@ import java.math.BigDecimal; import java.math.BigInteger; -import static java.lang.String.format; import static java.lang.System.out; @Disabled -public class ThresholdMixinPerfTest { - private static long thresholdIntegral = Long.MAX_VALUE - 1; +class ThresholdMixinPerfTest { + private static final long thresholdIntegral = Long.MAX_VALUE - 1; private final LongNode maximumLong = new LongNode(thresholdIntegral); @@ -58,104 +57,104 @@ public class ThresholdMixinPerfTest { private double baseTimeForLong; @BeforeEach - public void baseTimeEstimate() { + void baseTimeEstimate() { baseTimeForDouble = getAvgTimeViaMixin(asDouble, valueDouble, executeTimes); - out.println(format("Base execution time (comparing two DoubleNodes) %f ns", baseTimeForDouble)); + out.printf("Base execution time (comparing two DoubleNodes) %f ns%n", baseTimeForDouble); baseTimeForLong = getAvgTimeViaMixin(asLong, valueLong, executeTimes); - out.println(format("Base execution time (comparing two LongeNodes) %f ns \n", baseTimeForDouble)); + out.printf("Base execution time (comparing two LongeNodes) %f ns \n%n", baseTimeForDouble); } @Test - public void currentTimeEstimate() { + void currentTimeEstimate() { out.println("Estimating time for current implementation:"); double currentAvgTimeOnDouble = getAvgTimeViaMixin(currentImplementationDouble, valueDouble, executeTimes); - out.println(format("Current double on double execution time %f ns, %f times slower", currentAvgTimeOnDouble, (currentAvgTimeOnDouble / baseTimeForDouble))); + out.printf("Current double on double execution time %f ns, %f times slower%n", currentAvgTimeOnDouble, (currentAvgTimeOnDouble / baseTimeForDouble)); double currentAvgTimeOnDecimal = getAvgTimeViaMixin(currentImplementationDouble, valueDecimal, executeTimes); - out.println(format("Current double on decimal execution time %f ns, %f times slower", currentAvgTimeOnDecimal, (currentAvgTimeOnDecimal / baseTimeForDouble))); + out.printf("Current double on decimal execution time %f ns, %f times slower%n", currentAvgTimeOnDecimal, (currentAvgTimeOnDecimal / baseTimeForDouble)); double currentAvgTimeOnText = getAvgTimeViaMixin(currentImplementationDouble, valueTextual, executeTimes); - out.println(format("Current double on text execution time %f ns, %f times slower", currentAvgTimeOnText, (currentAvgTimeOnText / baseTimeForDouble))); + out.printf("Current double on text execution time %f ns, %f times slower%n", currentAvgTimeOnText, (currentAvgTimeOnText / baseTimeForDouble)); double currentAvgTimeDecimalOnDouble = getAvgTimeViaMixin(currentImplementationDecimal, valueDouble, executeTimes); - out.println(format("Current decimal on double execution time %f ns, %f times slower", currentAvgTimeDecimalOnDouble, (currentAvgTimeDecimalOnDouble / baseTimeForDouble))); + out.printf("Current decimal on double execution time %f ns, %f times slower%n", currentAvgTimeDecimalOnDouble, (currentAvgTimeDecimalOnDouble / baseTimeForDouble)); double currentAvgTimeDecimalOnDecimal = getAvgTimeViaMixin(currentImplementationDecimal, valueDecimal, executeTimes); - out.println(format("Current decimal on decimal execution time %f ns, %f times slower", currentAvgTimeDecimalOnDecimal, (currentAvgTimeDecimalOnDecimal / baseTimeForDouble))); + out.printf("Current decimal on decimal execution time %f ns, %f times slower%n", currentAvgTimeDecimalOnDecimal, (currentAvgTimeDecimalOnDecimal / baseTimeForDouble)); double currentAvgTimeDecimalOnText = getAvgTimeViaMixin(currentImplementationDecimal, valueTextual, executeTimes); - out.println(format("Current decimal on text execution time %f ns, %f times slower", currentAvgTimeDecimalOnText, (currentAvgTimeDecimalOnText / baseTimeForDouble))); + out.printf("Current decimal on text execution time %f ns, %f times slower%n", currentAvgTimeDecimalOnText, (currentAvgTimeDecimalOnText / baseTimeForDouble)); - out.println(format("Cumulative average: %f\n\n", (currentAvgTimeOnDouble + currentAvgTimeOnDecimal + currentAvgTimeOnText + currentAvgTimeDecimalOnDouble + currentAvgTimeDecimalOnDecimal + currentAvgTimeDecimalOnText) / 6.0d)); + out.printf("Cumulative average: %f\n\n%n", (currentAvgTimeOnDouble + currentAvgTimeOnDecimal + currentAvgTimeOnText + currentAvgTimeDecimalOnDouble + currentAvgTimeDecimalOnDecimal + currentAvgTimeDecimalOnText) / 6.0d); } @Test - public void allInOneAproachTimeEstimate() { + void allInOneAproachTimeEstimate() { out.println("Estimating time threshold value agnostic mixin (aka allInOne):"); double allInOneDoubleOnDouble = getAvgTimeViaMixin(allInOneDouble, valueDouble, executeTimes); - out.println(format("AllInOne double on double execution time %f ns, %f times slower", allInOneDoubleOnDouble, (allInOneDoubleOnDouble / baseTimeForDouble))); + out.printf("AllInOne double on double execution time %f ns, %f times slower%n", allInOneDoubleOnDouble, (allInOneDoubleOnDouble / baseTimeForDouble)); double allInOneDoubleOnDecimal = getAvgTimeViaMixin(allInOneDouble, valueDecimal, executeTimes); - out.println(format("AllInOne double on decimal execution time %f ns, %f times slower", allInOneDoubleOnDecimal, (allInOneDoubleOnDecimal / baseTimeForDouble))); + out.printf("AllInOne double on decimal execution time %f ns, %f times slower%n", allInOneDoubleOnDecimal, (allInOneDoubleOnDecimal / baseTimeForDouble)); double allInOneDoubleOnText = getAvgTimeViaMixin(allInOneDouble, valueTextual, executeTimes); - out.println(format("AllInOne double on text execution time %f ns, %f times slower", allInOneDoubleOnText, (allInOneDoubleOnText / baseTimeForDouble))); + out.printf("AllInOne double on text execution time %f ns, %f times slower%n", allInOneDoubleOnText, (allInOneDoubleOnText / baseTimeForDouble)); double allInOneDecimalOnDouble = getAvgTimeViaMixin(allInOneDecimal, valueDouble, executeTimes); - out.println(format("AllInOne decimal on double execution time %f ns, %f times slower", allInOneDecimalOnDouble, (allInOneDecimalOnDouble / baseTimeForDouble))); + out.printf("AllInOne decimal on double execution time %f ns, %f times slower%n", allInOneDecimalOnDouble, (allInOneDecimalOnDouble / baseTimeForDouble)); double allInOneDecimalOnDecimal = getAvgTimeViaMixin(allInOneDecimal, valueDecimal, executeTimes); - out.println(format("AllInOne decimal on decimal execution time %f ns, %f times slower", allInOneDecimalOnDecimal, (allInOneDecimalOnDecimal / baseTimeForDouble))); + out.printf("AllInOne decimal on decimal execution time %f ns, %f times slower%n", allInOneDecimalOnDecimal, (allInOneDecimalOnDecimal / baseTimeForDouble)); double allInOneDecimalOnText = getAvgTimeViaMixin(allInOneDecimal, valueTextual, executeTimes); - out.println(format("AllInOne decimal on text execution time %f ns, %f times slower", allInOneDecimalOnText, (allInOneDecimalOnText / baseTimeForDouble))); + out.printf("AllInOne decimal on text execution time %f ns, %f times slower%n", allInOneDecimalOnText, (allInOneDecimalOnText / baseTimeForDouble)); - out.println(format("Cumulative average: %f\n\n", (allInOneDoubleOnDouble + allInOneDoubleOnDecimal + allInOneDoubleOnText + allInOneDecimalOnDouble + allInOneDecimalOnDecimal + allInOneDecimalOnText) / 6.0d)); + out.printf("Cumulative average: %f\n\n%n", (allInOneDoubleOnDouble + allInOneDoubleOnDecimal + allInOneDoubleOnText + allInOneDecimalOnDouble + allInOneDecimalOnDecimal + allInOneDecimalOnText) / 6.0d); } @Test - public void specificCaseForEachThresholdValue() { + void specificCaseForEachThresholdValue() { out.println("Estimating time for specific cases:"); double doubleValueAvgTime = getAvgTimeViaMixin(typedThreshold, valueDouble, executeTimes); - out.println(format("Typed threshold execution time %f ns, %f times slower", doubleValueAvgTime, (doubleValueAvgTime / baseTimeForDouble))); + out.printf("Typed threshold execution time %f ns, %f times slower%n", doubleValueAvgTime, (doubleValueAvgTime / baseTimeForDouble)); double decimalValueAvgTime = getAvgTimeViaMixin(typedThreshold, valueDecimal, executeTimes); - out.println(format("Typed threshold execution time %f ns, %f times slower", decimalValueAvgTime, (decimalValueAvgTime / baseTimeForDouble))); + out.printf("Typed threshold execution time %f ns, %f times slower%n", decimalValueAvgTime, (decimalValueAvgTime / baseTimeForDouble)); double textValueAvgTime = getAvgTimeViaMixin(typedThreshold, valueTextual, executeTimes); - out.println(format("Typed threshold execution time %f ns, %f times slower", textValueAvgTime, (textValueAvgTime / baseTimeForDouble))); + out.printf("Typed threshold execution time %f ns, %f times slower%n", textValueAvgTime, (textValueAvgTime / baseTimeForDouble)); - out.println(format("Cumulative average: %f\n\n", (doubleValueAvgTime + decimalValueAvgTime + textValueAvgTime) / 3.0d)); + out.printf("Cumulative average: %f\n\n%n", (doubleValueAvgTime + decimalValueAvgTime + textValueAvgTime) / 3.0d); } @Test - public void noMixinsFloatingTimeEstimate() { + void noMixinsFloatingTimeEstimate() { out.println("Estimating time no mixins at all (floating point values):"); double doubleValueAvgTime = getAvgTimeViaMixin(oneMixinForIntegerAndNumber, valueDecimal, executeTimes); - out.println(format("No mixins with double value time %f ns, %f times slower", doubleValueAvgTime, (doubleValueAvgTime / baseTimeForDouble))); + out.printf("No mixins with double value time %f ns, %f times slower%n", doubleValueAvgTime, (doubleValueAvgTime / baseTimeForDouble)); double decimalValueAvgTime = getAvgTimeViaMixin(oneMixinForIntegerAndNumber, valueDecimal, executeTimes); - out.println(format("No mixins with decimal value time %f ns, %f times slower", decimalValueAvgTime, (decimalValueAvgTime / baseTimeForDouble))); + out.printf("No mixins with decimal value time %f ns, %f times slower%n", decimalValueAvgTime, (decimalValueAvgTime / baseTimeForDouble)); double textValueAvgTime = getAvgTimeViaMixin(oneMixinForIntegerAndNumber, valueTextual, executeTimes); - out.println(format("No mixins with text value time %f ns, %f times slower", textValueAvgTime, (textValueAvgTime / baseTimeForDouble))); - out.println(format("Cumulative average: %f\n\n", - (doubleValueAvgTime + decimalValueAvgTime + textValueAvgTime) / 3.0d)); + out.printf("No mixins with text value time %f ns, %f times slower%n", textValueAvgTime, (textValueAvgTime / baseTimeForDouble)); + out.printf("Cumulative average: %f\n\n%n", + (doubleValueAvgTime + decimalValueAvgTime + textValueAvgTime) / 3.0d); } @Test - public void noMixinsIntegralTimeEstimate() { + void noMixinsIntegralTimeEstimate() { double longValueAvgTime = getAvgTimeViaMixin(oneMixinForIntegerAndNumber, new LongNode((long) value), executeTimes); - out.println(format("No mixins with long value time %f ns, %f times slower", longValueAvgTime, (longValueAvgTime / baseTimeForLong))); + out.printf("No mixins with long value time %f ns, %f times slower%n", longValueAvgTime, (longValueAvgTime / baseTimeForLong)); double bigIntValueAvgTime = getAvgTimeViaMixin(oneMixinForIntegerAndNumber, new BigIntegerNode(BigInteger.valueOf((long) value)), executeTimes); - out.println(format("No mixins with big int value time %f ns, %f times slower", bigIntValueAvgTime, (bigIntValueAvgTime / baseTimeForLong))); + out.printf("No mixins with big int value time %f ns, %f times slower%n", bigIntValueAvgTime, (bigIntValueAvgTime / baseTimeForLong)); double textIntValueAvgTime = getAvgTimeViaMixin(oneMixinForIntegerAndNumber, new TextNode(String.valueOf((long) value)), executeTimes); - out.println(format("No mixins with text value time %f ns, %f times slower", textIntValueAvgTime, (textIntValueAvgTime / baseTimeForLong))); - out.println(format("Cumulative average: %f\n\n", - (longValueAvgTime + bigIntValueAvgTime + textIntValueAvgTime) / 3.0d)); + out.printf("No mixins with text value time %f ns, %f times slower%n", textIntValueAvgTime, (textIntValueAvgTime / baseTimeForLong)); + out.printf("Cumulative average: %f\n\n%n", + (longValueAvgTime + bigIntValueAvgTime + textIntValueAvgTime) / 3.0d); } ThresholdMixin allInOneDouble = new AllInOneThreshold(maximumDouble, false); @@ -165,7 +164,7 @@ public static class AllInOneThreshold implements ThresholdMixin { private final BigDecimal bigDecimalMax; JsonNode maximum; - private boolean excludeEqual; + private final boolean excludeEqual; AllInOneThreshold(JsonNode maximum, boolean exludeEqual) { this.maximum = maximum; @@ -204,9 +203,7 @@ public String thresholdValue() { } } - ; - - ThresholdMixin asDouble = new ThresholdMixin() { + ThresholdMixin asDouble = new ThresholdMixin() { @Override public boolean crossesThreshold(JsonNode node) { double lm = maximumDouble.doubleValue(); diff --git a/src/test/java/com/networknt/schema/TypeFactoryTest.java b/src/test/java/com/networknt/schema/TypeFactoryTest.java index 2e5248bc8..90d410412 100755 --- a/src/test/java/com/networknt/schema/TypeFactoryTest.java +++ b/src/test/java/com/networknt/schema/TypeFactoryTest.java @@ -33,7 +33,7 @@ /** * Test for TypeFactory. */ -public class TypeFactoryTest { +class TypeFactoryTest { private static final String[] validIntegralValues = { "1", "-1", "0E+1", "0E1", "-0E+1", "-0E1", "10.1E+1", "10.1E1", "-10.1E+1", "-10.1E1", "1E+0", "1E-0", "1E0", "1E18", "9223372036854775807", @@ -115,7 +115,7 @@ void testBooleanValue() { } @Test - public void testNullValue() { + void testNullValue() { assertSame(JsonType.NULL, getValueNodeType(JsonMapperFactory.getInstance().getNodeFactory().nullNode(), SchemaValidatorsConfig.builder().build())); } diff --git a/src/test/java/com/networknt/schema/TypeValidatorTest.java b/src/test/java/com/networknt/schema/TypeValidatorTest.java index b5919f25e..592429071 100644 --- a/src/test/java/com/networknt/schema/TypeValidatorTest.java +++ b/src/test/java/com/networknt/schema/TypeValidatorTest.java @@ -27,7 +27,7 @@ /** * Test TypeValidator validator. */ -public class TypeValidatorTest { +class TypeValidatorTest { String schemaData = "{\r\n" // Issue 415 + " \"$schema\": \"http://json-schema.org/draft-07/schema\",\r\n" + " \"$id\": \"http://example.com/example.json\",\r\n" diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java index 1b6a923be..765440666 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsTest.java @@ -8,7 +8,7 @@ import java.util.stream.Stream; @DisplayName("Unevaluated Items") -public class UnevaluatedItemsTest extends AbstractJsonSchemaTestSuite { +class UnevaluatedItemsTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09") diff --git a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java index 982a57124..6445f7685 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedItemsValidatorTest.java @@ -29,7 +29,7 @@ /** * UnevaluatedItemsValidatorTest. */ -public class UnevaluatedItemsValidatorTest { +class UnevaluatedItemsValidatorTest { @Test void unevaluatedItemsFalse() { String schemaData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java index fae48a7d7..61cf70426 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java @@ -9,7 +9,7 @@ import java.util.stream.Stream; @DisplayName("Unevaluated Properties") -public class UnevaluatedPropertiesTest extends AbstractJsonSchemaTestSuite { +class UnevaluatedPropertiesTest extends AbstractJsonSchemaTestSuite { @TestFactory @DisplayName("Draft 2019-09") diff --git a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java index 2a8f7c413..6b8db6dea 100644 --- a/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java +++ b/src/test/java/com/networknt/schema/UnevaluatedPropertiesValidatorTest.java @@ -33,7 +33,7 @@ /** * UnevaluatedPropertiesValidatorTest. */ -public class UnevaluatedPropertiesValidatorTest { +class UnevaluatedPropertiesValidatorTest { /** * Issue 962. */ diff --git a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java index ed4603172..252c29367 100644 --- a/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java +++ b/src/test/java/com/networknt/schema/UnknownMetaSchemaTest.java @@ -8,16 +8,16 @@ import java.io.IOException; import java.util.Set; -public class UnknownMetaSchemaTest { +class UnknownMetaSchemaTest { - private String schema1 = "{\"$schema\":\"http://json-schema.org/draft-07/schema\",\"title\":\"thingModel\",\"description\":\"description of thing\",\"type\":\"object\",\"properties\":{\"data\":{\"type\":\"integer\"},\"required\":[\"data\"]}}"; - private String schema2 = "{\"$schema\":\"https://json-schema.org/draft-07/schema\",\"title\":\"thingModel\",\"description\":\"description of thing\",\"type\":\"object\",\"properties\":{\"data\":{\"type\":\"integer\"},\"required\":[\"data\"]}}"; - private String schema3 = "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"title\":\"thingModel\",\"description\":\"description of thing\",\"type\":\"object\",\"properties\":{\"data\":{\"type\":\"integer\"},\"required\":[\"data\"]}}"; + private final String schema1 = "{\"$schema\":\"http://json-schema.org/draft-07/schema\",\"title\":\"thingModel\",\"description\":\"description of thing\",\"type\":\"object\",\"properties\":{\"data\":{\"type\":\"integer\"},\"required\":[\"data\"]}}"; + private final String schema2 = "{\"$schema\":\"https://json-schema.org/draft-07/schema\",\"title\":\"thingModel\",\"description\":\"description of thing\",\"type\":\"object\",\"properties\":{\"data\":{\"type\":\"integer\"},\"required\":[\"data\"]}}"; + private final String schema3 = "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"title\":\"thingModel\",\"description\":\"description of thing\",\"type\":\"object\",\"properties\":{\"data\":{\"type\":\"integer\"},\"required\":[\"data\"]}}"; - private String json = "{\"data\":1}"; + private final String json = "{\"data\":1}"; @Test - public void testSchema1() throws IOException { + void testSchema1() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); @@ -31,7 +31,7 @@ public void testSchema1() throws IOException { } @Test - public void testSchema2() throws IOException { + void testSchema2() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); @@ -44,7 +44,7 @@ public void testSchema2() throws IOException { } } @Test - public void testSchema3() throws IOException { + void testSchema3() throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(this.json); @@ -58,7 +58,7 @@ public void testSchema3() throws IOException { } @Test - public void testNormalize() throws JsonSchemaException { + void testNormalize() throws JsonSchemaException { String uri01 = "http://json-schema.org/draft-07/schema"; String uri02 = "http://json-schema.org/draft-07/schema#"; diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index 332fb1c48..cbab660df 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -31,7 +31,7 @@ import com.networknt.schema.resource.MapSchemaMapper; import com.networknt.schema.resource.SchemaMapper; -public class UriMappingTest { +class UriMappingTest { private final ObjectMapper mapper = new ObjectMapper(); @@ -42,7 +42,7 @@ public class UriMappingTest { * @throws IOException if unable to parse the mapping file */ @Test - public void testBuilderUriMappingUri() throws IOException { + void testBuilderUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/draft4/extra/uri_mapping/uri-mapping.json"); JsonMetaSchema draftV4 = JsonMetaSchema.getV4(); Builder builder = JsonSchemaFactory.builder() @@ -58,13 +58,13 @@ public void testBuilderUriMappingUri() throws IOException { /** * Validate that local URI is used when attempting to get a schema that is not * available publicly. Use the URL http://example.com/invalid/schema/url to use - * a public URL that returns a 404 Not Found. The locally mapped schema is a + * a URL that returns a 404 Not Found. The locally mapped schema is a * valid, but empty schema. * * @throws IOException if unable to parse the mapping file */ @Test - public void testBuilderExampleMappings() throws IOException { + void testBuilderExampleMappings() throws IOException { JsonSchemaFactory instance = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); SchemaLocation example = SchemaLocation.of("https://example.com/invalid/schema/url"); // first test that attempting to use example URL throws an error @@ -99,7 +99,7 @@ public void testBuilderExampleMappings() throws IOException { * @throws IOException if unable to parse the mapping file */ @Test - public void testValidatorConfigUriMappingUri() throws IOException { + void testValidatorConfigUriMappingUri() throws IOException { URL mappings = UriMappingTest.class.getResource("/draft4/extra/uri_mapping/uri-mapping.json"); JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); @@ -111,13 +111,13 @@ public void testValidatorConfigUriMappingUri() throws IOException { /** * Validate that local URL is used when attempting to get a schema that is not * available publicly. Use the URL http://example.com/invalid/schema/url to use - * a public URL that returns a 404 Not Found. The locally mapped schema is a + * a URL that returns a 404 Not Found. The locally mapped schema is a * valid, but empty schema. * * @throws IOException if unable to parse the mapping file */ @Test - public void testValidatorConfigExampleMappings() throws IOException { + void testValidatorConfigExampleMappings() throws IOException { URL mappings = UriMappingTest.class.getResource("/draft4/extra/uri_mapping/invalid-schema-uri.json"); JsonSchemaFactory instance = JsonSchemaFactory .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)).build(); @@ -144,7 +144,7 @@ public void testValidatorConfigExampleMappings() throws IOException { } @Test - public void testMappingsForRef() throws IOException { + void testMappingsForRef() throws IOException { URL mappings = UriMappingTest.class.getResource("/draft4/extra/uri_mapping/schema-with-ref-mapping.json"); JsonSchemaFactory instance = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4)) .schemaMappers(schemaMappers -> schemaMappers.add(getUriMappingsFromUrl(mappings))).build(); diff --git a/src/test/java/com/networknt/schema/UrnTest.java b/src/test/java/com/networknt/schema/UrnTest.java index b0746302f..dbf29283e 100644 --- a/src/test/java/com/networknt/schema/UrnTest.java +++ b/src/test/java/com/networknt/schema/UrnTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class UrnTest +class UrnTest { private final ObjectMapper mapper = new ObjectMapper(); @@ -20,7 +20,7 @@ public class UrnTest * @throws IOException if unable to parse the mapping file */ @Test - public void testURNToURI() throws Exception { + void testURNToURI() throws Exception { InputStream urlTestData = UrnTest.class.getResourceAsStream("/draft7/urn/test.json"); InputStream is = null; try { diff --git a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java index e8f4a4f0a..338e90748 100644 --- a/src/test/java/com/networknt/schema/V4JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V4JsonSchemaTest.java @@ -27,12 +27,12 @@ import static org.junit.jupiter.api.Assertions.*; -public class V4JsonSchemaTest extends HTTPServiceSupport { +class V4JsonSchemaTest extends HTTPServiceSupport { protected ObjectMapper mapper = new ObjectMapper(); @Test(/* expected = java.lang.StackOverflowError.class */) - public void testLoadingWithId() throws Exception { + void testLoadingWithId() throws Exception { URL url = new URL("http://localhost:1234/self_ref/selfRef.json"); JsonNode schemaJson = mapper.readTree(url); JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); @@ -44,7 +44,7 @@ public void testLoadingWithId() throws Exception { * Although, the data file has three errors, but only on is reported */ @Test - public void testFailFast_AllErrors() throws IOException { + void testFailFast_AllErrors() throws IOException { Set messages = validateFailingFastSchemaFor("extra/product/product.schema.json", "extra/product/product-all-errors-data.json"); assertEquals(1, messages.size()); @@ -54,7 +54,7 @@ public void testFailFast_AllErrors() throws IOException { * File contains only one error and that is reported. */ @Test - public void testFailFast_OneErrors() throws IOException { + void testFailFast_OneErrors() throws IOException { Set messages = validateFailingFastSchemaFor("extra/product/product.schema.json", "extra/product/product-one-error-data.json"); assertEquals(1, messages.size()); @@ -64,7 +64,7 @@ public void testFailFast_OneErrors() throws IOException { * Although, the file contains two errors, but only one is reported */ @Test - public void testFailFast_TwoErrors() throws IOException { + void testFailFast_TwoErrors() throws IOException { Set messages = validateFailingFastSchemaFor("extra/product/product.schema.json", "extra/product/product-two-errors-data.json"); assertEquals(1, messages.size()); @@ -75,7 +75,7 @@ public void testFailFast_TwoErrors() throws IOException { * {@link Set}<{@link ValidationMessage}> must be empty */ @Test - public void testFailFast_NoErrors() throws IOException { + void testFailFast_NoErrors() throws IOException { final Set messages = validateFailingFastSchemaFor("extra/product/product.schema.json", "extra/product/product-no-errors-data.json"); assertTrue(messages.isEmpty()); diff --git a/src/test/java/com/networknt/schema/ValidationMessageTest.java b/src/test/java/com/networknt/schema/ValidationMessageTest.java index 1b3709d55..2357e395b 100644 --- a/src/test/java/com/networknt/schema/ValidationMessageTest.java +++ b/src/test/java/com/networknt/schema/ValidationMessageTest.java @@ -25,7 +25,7 @@ /** * ValidationMessageTest. */ -public class ValidationMessageTest { +class ValidationMessageTest { @Test void testSerialization() throws JsonProcessingException { String value = JsonMapperFactory.getInstance() diff --git a/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java b/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java index c7d7291eb..8484378c0 100644 --- a/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java +++ b/src/test/java/com/networknt/schema/ValidatorTypeCodeTest.java @@ -23,26 +23,26 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class ValidatorTypeCodeTest { +class ValidatorTypeCodeTest { @Test - public void testFromValueString() { + void testFromValueString() { assertEquals(ValidatorTypeCode.ADDITIONAL_PROPERTIES, ValidatorTypeCode.fromValue("additionalProperties")); } @Test - public void testFromValueMissing() { + void testFromValueMissing() { Assertions.assertThrows(IllegalArgumentException.class, () -> assertEquals(ValidatorTypeCode.ADDITIONAL_PROPERTIES, ValidatorTypeCode.fromValue("missing"))); } @Test - public void testIfThenElseNotInV4() { + void testIfThenElseNotInV4() { List list = ValidatorTypeCode.getKeywords(SpecVersion.VersionFlag.V4); Assertions.assertFalse(list.contains(ValidatorTypeCode.fromValue("if"))); } @Test - public void testExclusiveMaximumNotInV4() { + void testExclusiveMaximumNotInV4() { List list = ValidatorTypeCode.getKeywords(SpecVersion.VersionFlag.V4); Assertions.assertFalse(list.contains(ValidatorTypeCode.fromValue("exclusiveMaximum"))); } diff --git a/src/test/java/com/networknt/schema/VocabularyTest.java b/src/test/java/com/networknt/schema/VocabularyTest.java index 3c42ad05a..ccb5c823f 100644 --- a/src/test/java/com/networknt/schema/VocabularyTest.java +++ b/src/test/java/com/networknt/schema/VocabularyTest.java @@ -31,7 +31,7 @@ /** * Tests for vocabulary support in meta schemas. */ -public class VocabularyTest { +class VocabularyTest { @Test void noValidation() { String metaSchemaData = "{\r\n" diff --git a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java index 449265c95..d57ef51cf 100644 --- a/src/test/java/com/networknt/schema/oas/OpenApi30Test.java +++ b/src/test/java/com/networknt/schema/oas/OpenApi30Test.java @@ -95,8 +95,7 @@ void exclusiveMaximum() { + " \"minimum\": 0,\r\n" + " \"maximum\": 100,\r\n" + " \"exclusiveMaximum\": true\r\n" - + "}\r\n" - + ""; + + "}\r\n"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); JsonSchema schema = factory.getSchema(schemaData); @@ -113,8 +112,7 @@ void exclusiveMinimum() { + " \"minimum\": 0,\r\n" + " \"maximum\": 100,\r\n" + " \"exclusiveMinimum\": true\r\n" - + "}\r\n" - + ""; + + "}\r\n"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7, builder -> builder .metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri())); JsonSchema schema = factory.getSchema(schemaData); diff --git a/src/test/java/com/networknt/schema/regex/AllowRegularExpressionFactoryTest.java b/src/test/java/com/networknt/schema/regex/AllowRegularExpressionFactoryTest.java index 12f5d751c..2ece4d5da 100644 --- a/src/test/java/com/networknt/schema/regex/AllowRegularExpressionFactoryTest.java +++ b/src/test/java/com/networknt/schema/regex/AllowRegularExpressionFactoryTest.java @@ -30,7 +30,7 @@ class AllowRegularExpressionFactoryTest { @Test void getRegularExpression() { - boolean called[] = { false }; + boolean[] called = { false }; RegularExpressionFactory delegate = (regex) -> { called[0] = true; return null; diff --git a/src/test/java/com/networknt/schema/regex/GraalJSRegularExpressionTest.java b/src/test/java/com/networknt/schema/regex/GraalJSRegularExpressionTest.java index 6d1531c87..4f18b14dd 100644 --- a/src/test/java/com/networknt/schema/regex/GraalJSRegularExpressionTest.java +++ b/src/test/java/com/networknt/schema/regex/GraalJSRegularExpressionTest.java @@ -33,7 +33,7 @@ * Test for GraalJSRegularExpression. */ class GraalJSRegularExpressionTest { - private static GraalJSRegularExpressionContext CONTEXT = new GraalJSRegularExpressionContext( + private static final GraalJSRegularExpressionContext CONTEXT = new GraalJSRegularExpressionContext( GraalJSContextFactory.getInstance()); enum InvalidEscapeInput { diff --git a/src/test/java/com/networknt/schema/regex/JoniRegularExpressionTest.java b/src/test/java/com/networknt/schema/regex/JoniRegularExpressionTest.java index 83279ba06..4b98dc122 100644 --- a/src/test/java/com/networknt/schema/regex/JoniRegularExpressionTest.java +++ b/src/test/java/com/networknt/schema/regex/JoniRegularExpressionTest.java @@ -126,7 +126,7 @@ void invalidPropertyName() { /** * Named capturing group: (?...). * - * @see org.joni.constants.SyntaxProperties#OP2_QMARK_LT_NAMED_GROUP. + * @see org.joni.constants.SyntaxProperties#OP2_QMARK_LT_NAMED_GROUP * @see Named * capturing group @@ -145,7 +145,7 @@ void invalidNamedCapturingGroup() { /** * Named capturing group: (?...). * - * @see org.joni.constants.SyntaxProperties#OP2_ESC_K_NAMED_BACKREF. + * @see org.joni.constants.SyntaxProperties#OP2_ESC_K_NAMED_BACKREF * @see Named * backreference diff --git a/src/test/java/com/networknt/schema/resource/MapSchemaLoaderTest.java b/src/test/java/com/networknt/schema/resource/MapSchemaLoaderTest.java index a3178d237..9fe9a7078 100644 --- a/src/test/java/com/networknt/schema/resource/MapSchemaLoaderTest.java +++ b/src/test/java/com/networknt/schema/resource/MapSchemaLoaderTest.java @@ -28,14 +28,14 @@ import com.networknt.schema.AbsoluteIri; class MapSchemaLoaderTest { - public static class Result { + static class Result { private final String schema; - public Result(String schema) { + Result(String schema) { this.schema = schema; } - public String getSchema() { + String getSchema() { return this.schema; } } diff --git a/src/test/java/com/networknt/schema/serialization/DefaultJsonNodeReaderTest.java b/src/test/java/com/networknt/schema/serialization/DefaultJsonNodeReaderTest.java index addf992b7..b508cf167 100644 --- a/src/test/java/com/networknt/schema/serialization/DefaultJsonNodeReaderTest.java +++ b/src/test/java/com/networknt/schema/serialization/DefaultJsonNodeReaderTest.java @@ -88,8 +88,7 @@ void yamlLocation() throws IOException { + "properties:\r\n" + " startDate:\r\n" + " format: 'date'\r\n" - + " minLength: 6\r\n" - + ""; + + " minLength: 6\r\n"; JsonNode jsonNode = JsonNodeReader.builder().locationAware().build().readTree(schemaData, InputFormat.YAML); JsonLocation formatSchemaNodeTokenLocation = JsonNodes.tokenLocationOf(jsonNode.at("/properties/startDate/format")); diff --git a/src/test/java/com/networknt/schema/suite/TestSource.java b/src/test/java/com/networknt/schema/suite/TestSource.java index 5479edc70..29edd248f 100644 --- a/src/test/java/com/networknt/schema/suite/TestSource.java +++ b/src/test/java/com/networknt/schema/suite/TestSource.java @@ -1,9 +1,9 @@ package com.networknt.schema.suite; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.Collections; import java.util.List; @@ -74,7 +74,7 @@ public boolean isDisabled() { } public static Optional loadFrom(Path path, boolean disabled, String reason) { - try (InputStream in = new FileInputStream(path.toFile())) { + try (InputStream in = Files.newInputStream(path.toFile().toPath())) { List testCases = mapper.readValue(in, testCaseType); return Optional.of(new TestSource(path, testCases, disabled, reason)); } catch (MismatchedInputException e) { diff --git a/src/test/java/com/networknt/schema/suite/TestSpec.java b/src/test/java/com/networknt/schema/suite/TestSpec.java index 115ab30dc..0b03625c7 100644 --- a/src/test/java/com/networknt/schema/suite/TestSpec.java +++ b/src/test/java/com/networknt/schema/suite/TestSpec.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import com.networknt.schema.SchemaValidatorsConfig; import java.util.Collections; import java.util.HashMap; @@ -261,7 +262,7 @@ public RegexKind getRegex() { return this.regex; } - public static enum RegexKind { + public enum RegexKind { @JsonProperty("unspecified") UNSPECIFIED, @JsonProperty("ecma-262") JONI, @JsonProperty("jdk") JDK diff --git a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java index a6c8fa430..aa21c89b6 100644 --- a/src/test/java/com/networknt/schema/utils/JsonNodesTest.java +++ b/src/test/java/com/networknt/schema/utils/JsonNodesTest.java @@ -44,7 +44,7 @@ /** * Tests for JsonNodes. */ -public class JsonNodesTest { +class JsonNodesTest { @Test void location() throws JsonParseException, IOException { String schemaData = "{\r\n" @@ -131,11 +131,9 @@ void yamlLocation() { + "properties:\r\n" + " startDate:\r\n" + " format: 'date'\r\n" - + " minLength: 6\r\n" - + ""; + + " minLength: 6\r\n"; String inputData = "---\r\n" - + "startDate: '1'\r\n" - + ""; + + "startDate: '1'\r\n"; JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012, builder -> builder.jsonNodeReader(JsonNodeReader.builder().locationAware().build())); SchemaValidatorsConfig config = SchemaValidatorsConfig.builder().build(); diff --git a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java index eb31a9079..bdef7af7b 100644 --- a/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java +++ b/src/test/java/com/networknt/schema/walk/JsonSchemaWalkListenerTest.java @@ -17,6 +17,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; @@ -30,7 +31,6 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -290,7 +290,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set validationMess List items = (List) result.getExecutionContext().getCollectorContext().get("items"); assertEquals(2, items.size()); assertEquals("items", items.get(0).getValidator().getKeyword()); - assertTrue(items.get(0).getValidator() instanceof ItemsValidator); + assertInstanceOf(ItemsValidator.class, items.get(0).getValidator()); assertEquals("/tags/0", items.get(0).getInstanceLocation().toString()); assertEquals("/properties/tags/items", items.get(0).getSchema().getEvaluationPath().toString()); @@ -363,7 +363,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set validationMess List items = (List) result.getExecutionContext().getCollectorContext().get("items"); assertEquals(2, items.size()); assertEquals("items", items.get(0).getValidator().getKeyword()); - assertTrue(items.get(0).getValidator() instanceof ItemsValidator202012); + assertInstanceOf(ItemsValidator202012.class, items.get(0).getValidator()); assertEquals("/tags/0", items.get(0).getInstanceLocation().toString()); assertEquals("/properties/tags/items", items.get(0).getSchema().getEvaluationPath().toString()); @@ -531,7 +531,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set validationMess } @Test - void applyDefaults() throws JsonMappingException, JsonProcessingException { + void applyDefaults() throws JsonProcessingException { String schemaData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\r\n" + " \"title\": \"\",\r\n" @@ -564,7 +564,7 @@ void applyDefaults() throws JsonMappingException, JsonProcessingException { } @Test - void applyDefaultsWithWalker() throws JsonMappingException, JsonProcessingException { + void applyDefaultsWithWalker() throws JsonProcessingException { String schemaData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\r\n" + " \"title\": \"\",\r\n" @@ -621,7 +621,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set validationMess } @Test - void applyInvalidDefaultsWithWalker() throws JsonMappingException, JsonProcessingException { + void applyInvalidDefaultsWithWalker() throws JsonProcessingException { String schemaData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\r\n" + " \"title\": \"\",\r\n" @@ -683,7 +683,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set validationMess } @Test - void missingRequired() throws JsonMappingException, JsonProcessingException { + void missingRequired() throws JsonProcessingException { String schemaData = "{\r\n" + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\r\n" + " \"title\": \"\",\r\n" @@ -747,7 +747,7 @@ public void onWalkEnd(WalkEvent walkEvent, Set validationMess } @Test - void generateDataWithWalker() throws JsonMappingException, JsonProcessingException { + void generateDataWithWalker() throws JsonProcessingException { Map> generators = new HashMap<>(); generators.put("name.findName", () -> "John Doe"); generators.put("internet.email", () -> "john.doe@gmail.com");