diff --git a/CHANGELOG.md b/CHANGELOG.md index e7fd91844..d1d09621e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed +## 1.0.34 - 2020-03-12 + +### Added + +### Changed + +- fixes #268 Collector Context changes to handle simple Objects. Thanks @prashanthjos +- fixes #266 reformat the code and resolve javadoc warnnings + ## 1.0.33 - 2020-03-09 ### Added diff --git a/README.md b/README.md index 5e19bc19d..ac9190303 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ Maven: com.networknt json-schema-validator - 1.0.33 + 1.0.34 ``` @@ -88,7 +88,7 @@ Gradle: ``` dependencies { - compile(group: "com.networknt", name: "json-schema-validator", version: "1.0.33"); + compile(group: "com.networknt", name: "json-schema-validator", version: "1.0.34"); } ``` diff --git a/pom.xml b/pom.xml index f4a9c37bf..de556da7b 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ 4.0.0 com.networknt json-schema-validator - 1.0.33 + 1.0.34 bundle A json schema validator that supports draft v4, v6, v7 and v2019-09 https://github.com/networknt/json-schema-validator diff --git a/src/main/java/com/networknt/schema/AbstractCollector.java b/src/main/java/com/networknt/schema/AbstractCollector.java index 7a522a0cd..cb0cf4bcc 100644 --- a/src/main/java/com/networknt/schema/AbstractCollector.java +++ b/src/main/java/com/networknt/schema/AbstractCollector.java @@ -1,9 +1,24 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; -public abstract class AbstractCollector implements Collector{ +public abstract class AbstractCollector implements Collector { - @Override - public void combine(Object object) { - // Do nothing. This is the default Implementation. - } + @Override + public void combine(Object object) { + // Do nothing. This is the default Implementation. + } } diff --git a/src/main/java/com/networknt/schema/Collector.java b/src/main/java/com/networknt/schema/Collector.java index ff5163a7d..c8404e063 100644 --- a/src/main/java/com/networknt/schema/Collector.java +++ b/src/main/java/com/networknt/schema/Collector.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.networknt.schema; /** @@ -9,20 +25,22 @@ public interface Collector { - /** - * This method should be called by the intermediate touch points that want to - * combine the data being collected by this collector. This is an optional - * method and could be used when the same collector is used for collecting data - * at multiple touch points or accumulating data at same touch point. - */ - public void combine(Object object); + /** + * This method should be called by the intermediate touch points that want to + * combine the data being collected by this collector. This is an optional + * method and could be used when the same collector is used for collecting data + * at multiple touch points or accumulating data at same touch point. + * @param object Object + */ + public void combine(Object object); - /** - * Final method called by the framework that returns the actual collected data. - * If the collector is not accumulating data or being used to collect data at - * multiple touch points, only this method can be implemented. - */ - public E collect(); + /** + * Final method called by the framework that returns the actual collected data. + * If the collector is not accumulating data or being used to collect data at + * multiple touch points, only this method can be implemented. + * @return E element + */ + public E collect(); } diff --git a/src/main/java/com/networknt/schema/CollectorContext.java b/src/main/java/com/networknt/schema/CollectorContext.java index 253194a11..75032075b 100644 --- a/src/main/java/com/networknt/schema/CollectorContext.java +++ b/src/main/java/com/networknt/schema/CollectorContext.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import java.util.HashMap; @@ -11,105 +26,102 @@ */ public class CollectorContext { - // Using a namespace string as key in ThreadLocal so that it is unique in - // ThreadLocal. - static final String COLLECTOR_CONTEXT_THREAD_LOCAL_KEY = "com.networknt.schema.CollectorKey"; + // Using a namespace string as key in ThreadLocal so that it is unique in + // ThreadLocal. + static final String COLLECTOR_CONTEXT_THREAD_LOCAL_KEY = "com.networknt.schema.CollectorKey"; - // Get an instance from thread info (which uses ThreadLocal). - public static CollectorContext getInstance() { - return (CollectorContext) ThreadInfo.get(COLLECTOR_CONTEXT_THREAD_LOCAL_KEY); - } + // Get an instance from thread info (which uses ThreadLocal). + public static CollectorContext getInstance() { + return (CollectorContext) ThreadInfo.get(COLLECTOR_CONTEXT_THREAD_LOCAL_KEY); + } - /** - * Map for holding the name and {@link Collector} or a simple Object. - */ - private Map collectorMap = new HashMap(); + /** + * Map for holding the name and {@link Collector} or a simple Object. + */ + private Map collectorMap = new HashMap(); - /** - * Map for holding the name and {@link Collector} class collect method output. - */ - private Map collectorLoadMap = new HashMap(); + /** + * Map for holding the name and {@link Collector} class collect method output. + */ + private Map collectorLoadMap = new HashMap(); - /** - * - * Adds a collector with give name. Preserving this method for backward - * compatibility. - * - * @param - * @param name - * @param collector - */ - public void add(String name, Collector collector) { - collectorMap.put(name, collector); - } + /** + * Adds a collector with give name. Preserving this method for backward + * compatibility. + * + * @param element + * @param name String + * @param collector Collector + */ + public void add(String name, Collector collector) { + collectorMap.put(name, collector); + } - /** - * - * Adds a collector or a simple object with give name. - * - * @param - * @param name - * @param collector - */ - public void add(String name, Object object) { - collectorMap.put(name, object); - } + /** + * Adds a collector or a simple object with give name. + * + * @param element + * @param object Object + * @param name String + * + */ + public void add(String name, Object object) { + collectorMap.put(name, object); + } - /** - * - * Gets the data associated with a given name. Please note if you are using a - * Collector you should wait till the validation is complete to gather all data. - * - * For a Collector, this method will return the collector as long as load method - * is not called. Once the load method is called this method will return the - * actual data collected by collector. - * - * @param name - * @return - */ - public Object get(String name) { - Object object = collectorMap.get(name); - if (object instanceof Collector && (collectorLoadMap.get(name) != null)) { - return collectorLoadMap.get(name); - } - return collectorMap.get(name); - } + /** + * Gets the data associated with a given name. Please note if you are using a + * Collector you should wait till the validation is complete to gather all data. + *

+ * For a Collector, this method will return the collector as long as load method + * is not called. Once the load method is called this method will return the + * actual data collected by collector. + * + * @param name String + * @return Object + */ + public Object get(String name) { + Object object = collectorMap.get(name); + if (object instanceof Collector && (collectorLoadMap.get(name) != null)) { + return collectorLoadMap.get(name); + } + return collectorMap.get(name); + } - /** - * - * Combines data with Collector identified by the given name. - * - * @param name - * @param data - */ - public void combineWithCollector(String name, Object data) { - Object object = collectorMap.get(name); - if (object instanceof Collector) { - Collector collector = (Collector) object; - collector.combine(data); - } - } + /** + * Combines data with Collector identified by the given name. + * + * @param name String + * @param data Object + */ + public void combineWithCollector(String name, Object data) { + Object object = collectorMap.get(name); + if (object instanceof Collector) { + Collector collector = (Collector) object; + collector.combine(data); + } + } - /** - * Reset the context - */ - void reset() { - this.collectorMap = new HashMap(); - this.collectorLoadMap = new HashMap(); - } + /** + * Reset the context + */ + void reset() { + this.collectorMap = new HashMap(); + this.collectorLoadMap = new HashMap(); + } - /** - * Loads data from all collectors. - */ - void loadCollectors() { - Set> entrySet = collectorMap.entrySet(); - for (Entry entry : entrySet) { - if (entry.getValue() instanceof Collector) { - Collector collector = (Collector) entry.getValue(); - collectorLoadMap.put(entry.getKey(), collector.collect()); - } - } + /** + * Loads data from all collectors. + */ + void loadCollectors() { + Set> entrySet = collectorMap.entrySet(); + for (Entry entry : entrySet) { + if (entry.getValue() instanceof Collector) { + Collector collector = (Collector) entry.getValue(); + collectorLoadMap.put(entry.getKey(), collector.collect()); + } + } - } + } } diff --git a/src/main/java/com/networknt/schema/ConstValidator.java b/src/main/java/com/networknt/schema/ConstValidator.java index 33dd30caf..fd3f82552 100644 --- a/src/main/java/com/networknt/schema/ConstValidator.java +++ b/src/main/java/com/networknt/schema/ConstValidator.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/main/java/com/networknt/schema/FalseValidator.java b/src/main/java/com/networknt/schema/FalseValidator.java index 2acea2cec..a1bca6eb2 100644 --- a/src/main/java/com/networknt/schema/FalseValidator.java +++ b/src/main/java/com/networknt/schema/FalseValidator.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java index b725e5979..95a94faef 100644 --- a/src/main/java/com/networknt/schema/JsonSchema.java +++ b/src/main/java/com/networknt/schema/JsonSchema.java @@ -216,31 +216,31 @@ public ValidationResult validateAndCollect(JsonNode node) { return validateAndCollect(node, node, AT_ROOT); } - - /** - * - * This method both validates and collects the data in a CollectionContext. - * @param jsonNode - * @param rootNode - * @param at - * @return - */ - protected ValidationResult validateAndCollect(JsonNode jsonNode, JsonNode rootNode, String at) { - try { - // Create the collector context object. - CollectorContext collectorContext = new CollectorContext(); - // Set the collector context in thread info, this is unique for every thread. - ThreadInfo.set(CollectorContext.COLLECTOR_CONTEXT_THREAD_LOCAL_KEY, collectorContext); - Set errors = validate(jsonNode, rootNode, at); - // Load all the data from collectors into the context. - collectorContext.loadCollectors(); - // Collect errors and collector context into validation result. - ValidationResult validationResult = new ValidationResult(errors, collectorContext); - return validationResult; - } finally { - ThreadInfo.remove(CollectorContext.COLLECTOR_CONTEXT_THREAD_LOCAL_KEY); - } - } + + /** + * This method both validates and collects the data in a CollectionContext. + * + * @param jsonNode JsonNode + * @param rootNode JsonNode + * @param at String path + * @return ValidationResult + */ + protected ValidationResult validateAndCollect(JsonNode jsonNode, JsonNode rootNode, String at) { + try { + // Create the collector context object. + CollectorContext collectorContext = new CollectorContext(); + // Set the collector context in thread info, this is unique for every thread. + ThreadInfo.set(CollectorContext.COLLECTOR_CONTEXT_THREAD_LOCAL_KEY, collectorContext); + Set errors = validate(jsonNode, rootNode, at); + // Load all the data from collectors into the context. + collectorContext.loadCollectors(); + // Collect errors and collector context into validation result. + ValidationResult validationResult = new ValidationResult(errors, collectorContext); + return validationResult; + } finally { + ThreadInfo.remove(CollectorContext.COLLECTOR_CONTEXT_THREAD_LOCAL_KEY); + } + } @Override public String toString() { @@ -254,9 +254,9 @@ public boolean hasRequiredValidator() { public JsonValidator getRequiredValidator() { return requiredValidator; } - + public Map getValidators() { - return validators; + return validators; } } diff --git a/src/main/java/com/networknt/schema/JsonSchemaRef.java b/src/main/java/com/networknt/schema/JsonSchemaRef.java index 3af98d38b..df654dcaf 100644 --- a/src/main/java/com/networknt/schema/JsonSchemaRef.java +++ b/src/main/java/com/networknt/schema/JsonSchemaRef.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/main/java/com/networknt/schema/SpecVersion.java b/src/main/java/com/networknt/schema/SpecVersion.java index cdb70deef..d67294181 100644 --- a/src/main/java/com/networknt/schema/SpecVersion.java +++ b/src/main/java/com/networknt/schema/SpecVersion.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import java.util.EnumSet; diff --git a/src/main/java/com/networknt/schema/ThreadInfo.java b/src/main/java/com/networknt/schema/ThreadInfo.java index fb543d86b..e09a86c62 100644 --- a/src/main/java/com/networknt/schema/ThreadInfo.java +++ b/src/main/java/com/networknt/schema/ThreadInfo.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import java.util.HashMap; diff --git a/src/main/java/com/networknt/schema/TrueValidator.java b/src/main/java/com/networknt/schema/TrueValidator.java index 27acbcc17..54f33f21b 100644 --- a/src/main/java/com/networknt/schema/TrueValidator.java +++ b/src/main/java/com/networknt/schema/TrueValidator.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/main/java/com/networknt/schema/ValidationResult.java b/src/main/java/com/networknt/schema/ValidationResult.java index d35c38cdf..1b247fbfb 100644 --- a/src/main/java/com/networknt/schema/ValidationResult.java +++ b/src/main/java/com/networknt/schema/ValidationResult.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import java.util.Set; diff --git a/src/main/java/com/networknt/schema/ValidatorState.java b/src/main/java/com/networknt/schema/ValidatorState.java index 798067517..8770cd6ad 100644 --- a/src/main/java/com/networknt/schema/ValidatorState.java +++ b/src/main/java/com/networknt/schema/ValidatorState.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; public class ValidatorState { diff --git a/src/test/java/com/networknt/schema/CollectorContextTest.java b/src/test/java/com/networknt/schema/CollectorContextTest.java index ff9a78784..924ec8b45 100644 --- a/src/test/java/com/networknt/schema/CollectorContextTest.java +++ b/src/test/java/com/networknt/schema/CollectorContextTest.java @@ -1,370 +1,369 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.*; public class CollectorContextTest { - private static final String SAMPLE_COLLECTOR = "sampleCollectorType"; - - private JsonSchema jsonSchema; - - private JsonSchema jsonSchemaForCombine; - - - @Before - public void setup() throws Exception { - setupSchema(); - } - - - @SuppressWarnings("unchecked") - @Test - public void testCollectorContextWithKeyword() throws Exception { - ValidationResult validationResult = validate("{\"test-property1\":\"sample1\",\"test-property2\":\"sample2\"}"); - Assert.assertEquals(0, validationResult.getValidationMessages().size()); - List contextValues = (List) validationResult.getCollectorContext().get(SAMPLE_COLLECTOR); - Assert.assertEquals(0, validationResult.getValidationMessages().size()); - Assert.assertEquals(2, contextValues.size()); - Assert.assertEquals(contextValues.get(0), "actual_value_added_to_context1"); - Assert.assertEquals(contextValues.get(1), "actual_value_added_to_context2"); - } - - @SuppressWarnings("unchecked") - @Test - public void testCollectorContextWithMultiplThreads() throws Exception { - - ValidationThread validationRunnable1 = new ValidationThread("{\"test-property1\":\"sample1\" }", "thread1"); - ValidationThread validationRunnable2 = new ValidationThread("{\"test-property1\":\"sample2\" }", "thread2"); - ValidationThread validationRunnable3 = new ValidationThread("{\"test-property1\":\"sample3\" }", "thread3"); - - // This simulates calling the validateAndCollect method from three different - // threads.It should be noted that all these three threads use same - // json schema instance.Create three threads with there own Runnables. - Thread thread1 = new Thread(validationRunnable1); - Thread thread2 = new Thread(validationRunnable2); - Thread thread3 = new Thread(validationRunnable3); - - thread1.start(); - thread2.start(); - thread3.start(); - - thread1.join(); - thread2.join(); - thread3.join(); - - ValidationResult validationResult1 = validationRunnable1.getValidationResult(); - ValidationResult validationResult2 = validationRunnable2.getValidationResult(); - ValidationResult validationResult3 = validationRunnable3.getValidationResult(); - - Assert.assertEquals(0, validationResult1.getValidationMessages().size()); - Assert.assertEquals(0, validationResult2.getValidationMessages().size()); - Assert.assertEquals(0, validationResult3.getValidationMessages().size()); - - List contextValue1 = (List) validationResult1.getCollectorContext().get(SAMPLE_COLLECTOR); - List contextValue2 = (List) validationResult2.getCollectorContext().get(SAMPLE_COLLECTOR); - List contextValue3 = (List) validationResult3.getCollectorContext().get(SAMPLE_COLLECTOR); - - Assert.assertEquals(contextValue1.get(0), "actual_value_added_to_context1"); - Assert.assertEquals(contextValue2.get(0), "actual_value_added_to_context2"); - Assert.assertEquals(contextValue3.get(0), "actual_value_added_to_context3"); - } - - @SuppressWarnings("unchecked") - @Test - public void testCollectorWithFormat() throws JsonMappingException, JsonProcessingException { - ObjectMapper objectMapper = new ObjectMapper(); - ValidationResult validationResult = jsonSchemaForCombine.validateAndCollect(objectMapper.readTree("{\"property1\":\"sample1\",\"property2\":\"sample2\",\"property3\":\"sample3\" }")); - List values = (List) validationResult.getCollectorContext().get(SAMPLE_COLLECTOR); - Assert.assertEquals(values.size(), 4); - } - - private JsonMetaSchema getJsonMetaSchema(String uri) throws Exception { - JsonMetaSchema jsonMetaSchema = JsonMetaSchema.builder(uri, JsonMetaSchema.getV201909()) - .addKeyword(new CustomKeyword()).addKeyword(new CustomKeyword1()).addFormat(new Format() { - - @SuppressWarnings("unchecked") - @Override - public boolean matches(String value) { - CollectorContext collectorContext = CollectorContext.getInstance(); - if (collectorContext.get(SAMPLE_COLLECTOR) == null) { - collectorContext.add(SAMPLE_COLLECTOR, new ArrayList()); - } - List returnList = (List) collectorContext.get(SAMPLE_COLLECTOR); - returnList.add(value); - return true; - } - - @Override - public String getName() { - return "sample-format"; - } - - // Return null. As are just testing collection context. - @Override - public String getErrorMessageDescription() { - return null; - } - }).build(); - return jsonMetaSchema; - } - - private void setupSchema() throws Exception { - final JsonMetaSchema metaSchema = getJsonMetaSchema( - "https://github.com/networknt/json-schema-validator/tests/schemas/example01#"); - final JsonSchemaFactory schemaFactory = JsonSchemaFactory - .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)).addMetaSchema(metaSchema) - .build(); - this.jsonSchema = schemaFactory.getSchema(getSchemaString()); - this.jsonSchemaForCombine = schemaFactory.getSchema(getSchemaStringMultipleProperties()); - } - - private String getSchemaString() { - return "{" - + "\"$schema\": \"https://github.com/networknt/json-schema-validator/tests/schemas/example01#\"," - + "\"title\" : \"Sample test schema\",\n" - + "\"description\" : \"Sample schema definition\"," - + "\"type\" : \"object\"," - + "\"properties\" :" - + "{" - + "\"test-property1\" : " - + "{" - + "\"title\": \"Test Property1\"," - + "\"type\": \"string\", " - + "\"custom-keyword\":[\"x\",\"y\"]" - + "}," - + "\"test-property2\" : " - + "{" - + "\"title\": \"Test Property2\"," - + "\"type\": \"string\", " - + "\"custom-keyword\":[\"x\",\"y\"]" - + "}" - + "}," - +"\"additionalProperties\":\"false\"," - + "\"required\": [\"test-property1\"]\n" - + "}"; - } - - private String getSchemaStringMultipleProperties() { - return "{" - + "\"$schema\": \"https://github.com/networknt/json-schema-validator/tests/schemas/example01#\"," - + "\"title\" : \"Sample test schema\"," - + "\"description\" : \"Sample schema definition\"," - + "\"type\" : \"object\"," - + "\"properties\" :" - + "{" - + "\"property1\" : " - + "{" - + "\"title\": \"Property1\"," - + "\"type\": \"string\", " - + "\"custom-keyword1\":[\"x\",\"y\"]," - + "\"format\":\"sample-format\"" - + "}," - + "\"property2\" : " - + "{" - + "\"title\": \"Property2\"," - + "\"type\": \"string\", " - + "\"custom-keyword1\":[\"x\",\"y\"]" - + "}," - + "\"property3\" : " - + "{" - + "\"title\": \"Property3\"," - + "\"type\": \"string\", " - + "\"custom-keyword1\":[\"x\",\"y\"]" - + "}" - + "}" - + "}"; - } - - - - - private class ValidationThread implements Runnable { - - private String data; - - private String name; - - private ValidationResult validationResult; - - ValidationThread(String data,String name) { - this.name = name; - this.data = data; - } - - @Override - public void run() { - try { - this.validationResult = validate(data); - } catch (JsonMappingException e) { - e.printStackTrace(); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - ValidationResult getValidationResult() { - return this.validationResult; - } - - @Override - public String toString() { - return "ValidationThread [data=" + data + ", name=" + name + ", validationResult=" + validationResult + "]"; - } - - } - - /** - * - * Our own custom keyword. In this case we don't use this keyword. It is just - * for demonstration purpose. - * - */ - private class CustomKeyword implements Keyword { - @Override - public String getValue() { - return "custom-keyword"; - } - - @Override - public JsonValidator newValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, - ValidationContext validationContext) throws JsonSchemaException, Exception { - if (schemaNode != null && schemaNode.isArray()) { - return new CustomValidator(); - } - return null; - } - } - - - /** - * - * We will be collecting information/data by adding the data in the form of - * collectors into collector context object while we are validating this node. - * This will be helpful in cases where we don't want to revisit the entire JSON - * document again just for gathering this kind of information. - * - */ - private class CustomValidator implements JsonValidator { - - @Override - public Set validate(JsonNode node, JsonNode rootNode, String at) { - // Get an instance of collector context. - CollectorContext collectorContext = CollectorContext.getInstance(); - if (collectorContext.get(SAMPLE_COLLECTOR) == null) { - collectorContext.add(SAMPLE_COLLECTOR, new CustomCollector()); - } - collectorContext.combineWithCollector(SAMPLE_COLLECTOR, node.textValue()); - return new TreeSet(); - } - - @Override - public Set validate(JsonNode rootNode) { - return validate(rootNode, rootNode, BaseJsonValidator.AT_ROOT); - } - - } - - private class CustomCollector extends AbstractCollector> { - - List returnList = new ArrayList(); - - private Map referenceMap = null; - - public CustomCollector() { - referenceMap = getDatasourceMap(); - } - - @Override - public List collect() { - return returnList; - } - - @Override - public void combine(Object object) { - returnList.add(referenceMap.get((String) object)); - } - - } - - /** - * - * Our own custom keyword. In this case we don't use this keyword. It is just - * for demonstration purpose. - * - */ - private class CustomKeyword1 implements Keyword { - @Override - public String getValue() { - return "custom-keyword1"; - } - - @Override - public JsonValidator newValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, - ValidationContext validationContext) throws JsonSchemaException, Exception { - if (schemaNode != null && schemaNode.isArray()) { - return new CustomValidator1(); - } - return null; - } - } - - /** - * - * We will be collecting information/data by adding the data in the form of - * collectors into collector context object while we are validating this node. - * This will be helpful in cases where we don't want to revisit the entire JSON - * document again just for gathering this kind of information. In this test case - * we expect this validator to be called multiple times as the associated - * keyword has been used multiple times in JSON Schema. - * - */ - private class CustomValidator1 implements JsonValidator { - @SuppressWarnings("unchecked") - @Override - public Set validate(JsonNode node, JsonNode rootNode, String at) { - // Get an instance of collector context. - CollectorContext collectorContext = CollectorContext.getInstance(); - // If collector type is not added to context add one. - if (collectorContext.get(SAMPLE_COLLECTOR) == null) { - collectorContext.add(SAMPLE_COLLECTOR, new ArrayList()); - } - List returnList = (List) collectorContext.get(SAMPLE_COLLECTOR); - returnList.add(node.textValue()); - return new TreeSet(); - } - - @Override - public Set validate(JsonNode rootNode) { - return validate(rootNode, rootNode, BaseJsonValidator.AT_ROOT); - } - } - - private ValidationResult validate(String jsonData) throws JsonMappingException, JsonProcessingException, Exception { - ObjectMapper objectMapper = new ObjectMapper(); - return this.jsonSchema.validateAndCollect(objectMapper.readTree(jsonData)); - } - - private Map getDatasourceMap() { - Map map = new HashMap(); - map.put("sample1", "actual_value_added_to_context1"); - map.put("sample2", "actual_value_added_to_context2"); - map.put("sample3", "actual_value_added_to_context3"); - return map; - } + private static final String SAMPLE_COLLECTOR = "sampleCollectorType"; + + private JsonSchema jsonSchema; + + private JsonSchema jsonSchemaForCombine; + + + @Before + public void setup() throws Exception { + setupSchema(); + } + + + @SuppressWarnings("unchecked") + @Test + public void testCollectorContextWithKeyword() throws Exception { + ValidationResult validationResult = validate("{\"test-property1\":\"sample1\",\"test-property2\":\"sample2\"}"); + Assert.assertEquals(0, validationResult.getValidationMessages().size()); + List contextValues = (List) validationResult.getCollectorContext().get(SAMPLE_COLLECTOR); + Assert.assertEquals(0, validationResult.getValidationMessages().size()); + Assert.assertEquals(2, contextValues.size()); + Assert.assertEquals(contextValues.get(0), "actual_value_added_to_context1"); + Assert.assertEquals(contextValues.get(1), "actual_value_added_to_context2"); + } + + @SuppressWarnings("unchecked") + @Test + public void testCollectorContextWithMultiplThreads() throws Exception { + + ValidationThread validationRunnable1 = new ValidationThread("{\"test-property1\":\"sample1\" }", "thread1"); + ValidationThread validationRunnable2 = new ValidationThread("{\"test-property1\":\"sample2\" }", "thread2"); + ValidationThread validationRunnable3 = new ValidationThread("{\"test-property1\":\"sample3\" }", "thread3"); + + // This simulates calling the validateAndCollect method from three different + // threads.It should be noted that all these three threads use same + // json schema instance.Create three threads with there own Runnables. + Thread thread1 = new Thread(validationRunnable1); + Thread thread2 = new Thread(validationRunnable2); + Thread thread3 = new Thread(validationRunnable3); + + thread1.start(); + thread2.start(); + thread3.start(); + + thread1.join(); + thread2.join(); + thread3.join(); + + ValidationResult validationResult1 = validationRunnable1.getValidationResult(); + ValidationResult validationResult2 = validationRunnable2.getValidationResult(); + ValidationResult validationResult3 = validationRunnable3.getValidationResult(); + + Assert.assertEquals(0, validationResult1.getValidationMessages().size()); + Assert.assertEquals(0, validationResult2.getValidationMessages().size()); + Assert.assertEquals(0, validationResult3.getValidationMessages().size()); + + List contextValue1 = (List) validationResult1.getCollectorContext().get(SAMPLE_COLLECTOR); + List contextValue2 = (List) validationResult2.getCollectorContext().get(SAMPLE_COLLECTOR); + List contextValue3 = (List) validationResult3.getCollectorContext().get(SAMPLE_COLLECTOR); + + Assert.assertEquals(contextValue1.get(0), "actual_value_added_to_context1"); + Assert.assertEquals(contextValue2.get(0), "actual_value_added_to_context2"); + Assert.assertEquals(contextValue3.get(0), "actual_value_added_to_context3"); + } + + @SuppressWarnings("unchecked") + @Test + public void testCollectorWithFormat() throws JsonMappingException, JsonProcessingException { + ObjectMapper objectMapper = new ObjectMapper(); + ValidationResult validationResult = jsonSchemaForCombine.validateAndCollect(objectMapper.readTree("{\"property1\":\"sample1\",\"property2\":\"sample2\",\"property3\":\"sample3\" }")); + List values = (List) validationResult.getCollectorContext().get(SAMPLE_COLLECTOR); + Assert.assertEquals(values.size(), 4); + } + + private JsonMetaSchema getJsonMetaSchema(String uri) throws Exception { + JsonMetaSchema jsonMetaSchema = JsonMetaSchema.builder(uri, JsonMetaSchema.getV201909()) + .addKeyword(new CustomKeyword()).addKeyword(new CustomKeyword1()).addFormat(new Format() { + + @SuppressWarnings("unchecked") + @Override + public boolean matches(String value) { + CollectorContext collectorContext = CollectorContext.getInstance(); + if (collectorContext.get(SAMPLE_COLLECTOR) == null) { + collectorContext.add(SAMPLE_COLLECTOR, new ArrayList()); + } + List returnList = (List) collectorContext.get(SAMPLE_COLLECTOR); + returnList.add(value); + return true; + } + + @Override + public String getName() { + return "sample-format"; + } + + // Return null. As are just testing collection context. + @Override + public String getErrorMessageDescription() { + return null; + } + }).build(); + return jsonMetaSchema; + } + + private void setupSchema() throws Exception { + final JsonMetaSchema metaSchema = getJsonMetaSchema( + "https://github.com/networknt/json-schema-validator/tests/schemas/example01#"); + final JsonSchemaFactory schemaFactory = JsonSchemaFactory + .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909)).addMetaSchema(metaSchema) + .build(); + this.jsonSchema = schemaFactory.getSchema(getSchemaString()); + this.jsonSchemaForCombine = schemaFactory.getSchema(getSchemaStringMultipleProperties()); + } + + private String getSchemaString() { + return "{" + + "\"$schema\": \"https://github.com/networknt/json-schema-validator/tests/schemas/example01#\"," + + "\"title\" : \"Sample test schema\",\n" + + "\"description\" : \"Sample schema definition\"," + + "\"type\" : \"object\"," + + "\"properties\" :" + + "{" + + "\"test-property1\" : " + + "{" + + "\"title\": \"Test Property1\"," + + "\"type\": \"string\", " + + "\"custom-keyword\":[\"x\",\"y\"]" + + "}," + + "\"test-property2\" : " + + "{" + + "\"title\": \"Test Property2\"," + + "\"type\": \"string\", " + + "\"custom-keyword\":[\"x\",\"y\"]" + + "}" + + "}," + + "\"additionalProperties\":\"false\"," + + "\"required\": [\"test-property1\"]\n" + + "}"; + } + + private String getSchemaStringMultipleProperties() { + return "{" + + "\"$schema\": \"https://github.com/networknt/json-schema-validator/tests/schemas/example01#\"," + + "\"title\" : \"Sample test schema\"," + + "\"description\" : \"Sample schema definition\"," + + "\"type\" : \"object\"," + + "\"properties\" :" + + "{" + + "\"property1\" : " + + "{" + + "\"title\": \"Property1\"," + + "\"type\": \"string\", " + + "\"custom-keyword1\":[\"x\",\"y\"]," + + "\"format\":\"sample-format\"" + + "}," + + "\"property2\" : " + + "{" + + "\"title\": \"Property2\"," + + "\"type\": \"string\", " + + "\"custom-keyword1\":[\"x\",\"y\"]" + + "}," + + "\"property3\" : " + + "{" + + "\"title\": \"Property3\"," + + "\"type\": \"string\", " + + "\"custom-keyword1\":[\"x\",\"y\"]" + + "}" + + "}" + + "}"; + } + + + private class ValidationThread implements Runnable { + + private String data; + + private String name; + + private ValidationResult validationResult; + + ValidationThread(String data, String name) { + this.name = name; + this.data = data; + } + + @Override + public void run() { + try { + this.validationResult = validate(data); + } catch (JsonMappingException e) { + e.printStackTrace(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + ValidationResult getValidationResult() { + return this.validationResult; + } + + @Override + public String toString() { + return "ValidationThread [data=" + data + ", name=" + name + ", validationResult=" + validationResult + "]"; + } + + } + + /** + * Our own custom keyword. In this case we don't use this keyword. It is just + * for demonstration purpose. + */ + private class CustomKeyword implements Keyword { + @Override + public String getValue() { + return "custom-keyword"; + } + + @Override + public JsonValidator newValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, + ValidationContext validationContext) throws JsonSchemaException, Exception { + if (schemaNode != null && schemaNode.isArray()) { + return new CustomValidator(); + } + return null; + } + } + + + /** + * We will be collecting information/data by adding the data in the form of + * collectors into collector context object while we are validating this node. + * This will be helpful in cases where we don't want to revisit the entire JSON + * document again just for gathering this kind of information. + */ + private class CustomValidator implements JsonValidator { + + @Override + public Set validate(JsonNode node, JsonNode rootNode, String at) { + // Get an instance of collector context. + CollectorContext collectorContext = CollectorContext.getInstance(); + if (collectorContext.get(SAMPLE_COLLECTOR) == null) { + collectorContext.add(SAMPLE_COLLECTOR, new CustomCollector()); + } + collectorContext.combineWithCollector(SAMPLE_COLLECTOR, node.textValue()); + return new TreeSet(); + } + + @Override + public Set validate(JsonNode rootNode) { + return validate(rootNode, rootNode, BaseJsonValidator.AT_ROOT); + } + + } + + private class CustomCollector extends AbstractCollector> { + + List returnList = new ArrayList(); + + private Map referenceMap = null; + + public CustomCollector() { + referenceMap = getDatasourceMap(); + } + + @Override + public List collect() { + return returnList; + } + + @Override + public void combine(Object object) { + returnList.add(referenceMap.get((String) object)); + } + + } + + /** + * Our own custom keyword. In this case we don't use this keyword. It is just + * for demonstration purpose. + */ + private class CustomKeyword1 implements Keyword { + @Override + public String getValue() { + return "custom-keyword1"; + } + + @Override + public JsonValidator newValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, + ValidationContext validationContext) throws JsonSchemaException, Exception { + if (schemaNode != null && schemaNode.isArray()) { + return new CustomValidator1(); + } + return null; + } + } + + /** + * We will be collecting information/data by adding the data in the form of + * collectors into collector context object while we are validating this node. + * This will be helpful in cases where we don't want to revisit the entire JSON + * document again just for gathering this kind of information. In this test case + * we expect this validator to be called multiple times as the associated + * keyword has been used multiple times in JSON Schema. + */ + private class CustomValidator1 implements JsonValidator { + @SuppressWarnings("unchecked") + @Override + public Set validate(JsonNode node, JsonNode rootNode, String at) { + // Get an instance of collector context. + CollectorContext collectorContext = CollectorContext.getInstance(); + // If collector type is not added to context add one. + if (collectorContext.get(SAMPLE_COLLECTOR) == null) { + collectorContext.add(SAMPLE_COLLECTOR, new ArrayList()); + } + List returnList = (List) collectorContext.get(SAMPLE_COLLECTOR); + returnList.add(node.textValue()); + return new TreeSet(); + } + + @Override + public Set validate(JsonNode rootNode) { + return validate(rootNode, rootNode, BaseJsonValidator.AT_ROOT); + } + } + + private ValidationResult validate(String jsonData) throws JsonMappingException, JsonProcessingException, Exception { + ObjectMapper objectMapper = new ObjectMapper(); + return this.jsonSchema.validateAndCollect(objectMapper.readTree(jsonData)); + } + + private Map getDatasourceMap() { + Map map = new HashMap(); + map.put("sample1", "actual_value_added_to_context1"); + map.put("sample2", "actual_value_added_to_context2"); + map.put("sample3", "actual_value_added_to_context3"); + return map; + } } diff --git a/src/test/java/com/networknt/schema/Issue255Test.java b/src/test/java/com/networknt/schema/Issue255Test.java index 20764369c..01450b2f1 100644 --- a/src/test/java/com/networknt/schema/Issue255Test.java +++ b/src/test/java/com/networknt/schema/Issue255Test.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/test/java/com/networknt/schema/MaximumValidatorPerfTest.java b/src/test/java/com/networknt/schema/MaximumValidatorPerfTest.java index 4d2b7cd67..34799bd1a 100644 --- a/src/test/java/com/networknt/schema/MaximumValidatorPerfTest.java +++ b/src/test/java/com/networknt/schema/MaximumValidatorPerfTest.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import org.junit.Ignore; diff --git a/src/test/java/com/networknt/schema/SpecVersionTest.java b/src/test/java/com/networknt/schema/SpecVersionTest.java index e1fa0db98..e597a95ba 100644 --- a/src/test/java/com/networknt/schema/SpecVersionTest.java +++ b/src/test/java/com/networknt/schema/SpecVersionTest.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import org.junit.Assert; diff --git a/src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java b/src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java index 3a4a81894..2f7bafe73 100644 --- a/src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java +++ b/src/test/java/com/networknt/schema/ThresholdMixinPerfTest.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/test/java/com/networknt/schema/UriMappingTest.java b/src/test/java/com/networknt/schema/UriMappingTest.java index f0800cb7b..703f36ded 100644 --- a/src/test/java/com/networknt/schema/UriMappingTest.java +++ b/src/test/java/com/networknt/schema/UriMappingTest.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/test/java/com/networknt/schema/V201909JsonSchemaTest.java b/src/test/java/com/networknt/schema/V201909JsonSchemaTest.java index fdb600867..3ade5ed42 100644 --- a/src/test/java/com/networknt/schema/V201909JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V201909JsonSchemaTest.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/test/java/com/networknt/schema/V6JsonSchemaTest.java b/src/test/java/com/networknt/schema/V6JsonSchemaTest.java index d75f04ec0..b3686b597 100644 --- a/src/test/java/com/networknt/schema/V6JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V6JsonSchemaTest.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/test/java/com/networknt/schema/V7JsonSchemaTest.java b/src/test/java/com/networknt/schema/V7JsonSchemaTest.java index f69ca41fc..b9963e86a 100644 --- a/src/test/java/com/networknt/schema/V7JsonSchemaTest.java +++ b/src/test/java/com/networknt/schema/V7JsonSchemaTest.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2020 Network New Technologies Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.networknt.schema; import com.fasterxml.jackson.databind.JsonNode;