Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 6 additions & 147 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
<version>1.0.29</version>
<packaging>bundle</packaging>
<version>1.0.30-SNAPSHOT</version>
<description>A json schema validator that supports draft v4, v6, v7 and v2019-09</description>
<url>https://github.com/networknt/json-schema-validator</url>
<name>JsonSchemaValidator</name>
Expand Down Expand Up @@ -58,8 +57,8 @@
</repository>
</distributionManagement>
<properties>
<java.version>1.8</java.version>
<java.testversion>1.8</java.testversion>
<java.version>1.7</java.version>
<java.testversion>1.7</java.testversion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.jackson>2.10.0</version.jackson>
<version.slf4j>1.7.25</version.slf4j>
Expand All @@ -68,7 +67,7 @@
<version.junit>4.12</version.junit>
<version.mockito>2.7.21</version.mockito>
<version.hamcrest>1.3</version.hamcrest>
<version.undertow>2.0.28.Final</version.undertow>
<version.undertow>1.4.28.Final</version.undertow>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -139,12 +138,7 @@
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.2.1</version>
<extensions>true</extensions>
</plugin>

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand Down Expand Up @@ -219,142 +213,7 @@
</dependency>
</dependencies>
</plugin>
<!-- JACOCO added for code coverage -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
<!-- End Executions for unit tests -->
<!-- The Executions for integration tests -->
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
<!-- End Executions for integration tests -->
</executions>
</plugin>
<!-- end JACOCO -->

</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
</plugin>
</plugins>
</reporting>
<profiles>
<profile>
<id>dev</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${version.jacoco}</version>
<executions>
<!-- The Executions for merging -->
<execution>
<id>merge-results</id>
<phase>verify</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${project.build.directory}/coverage-reports</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
</fileSets>
<destFile>${project.build.directory}/coverage-reports/aggregate.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-merge-report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/aggregate.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory>
</configuration>
</execution>
<!-- End Executions for merging -->
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ExclusiveMinimumValidator extends BaseJsonValidator implements Json
*/
private final ThresholdMixin typedMinimum;

public ExclusiveMinimumValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) {
public ExclusiveMinimumValidator(String schemaPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) {
super(schemaPath, schemaNode, parentSchema, ValidatorTypeCode.EXCLUSIVE_MINIMUM, validationContext);

if (!schemaNode.isNumber()) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/networknt/schema/JsonSchemaFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ public JsonSchema getSchema(final URI schemaUri, final SchemaValidatorsConfig co

final URI mappedUri;
try {
mappedUri = this.uriFactory.create(map.getOrDefault(schemaUri.toString(), schemaUri.toString()));
String uriString = schemaUri.toString();
if (map.containsKey(uriString)) {
uriString = map.get(uriString);
}
mappedUri = this.uriFactory.create(uriString);
} catch (IllegalArgumentException e) {
logger.error("Failed to create URI.", e);
throw new JsonSchemaException(e);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/networknt/schema/MinimumValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class MinimumValidator extends BaseJsonValidator implements JsonValidator
*/
private final ThresholdMixin typedMinimum;

public MinimumValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) {
public MinimumValidator(String schemaPath, final JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) {
super(schemaPath, schemaNode, parentSchema, ValidatorTypeCode.MINIMUM, validationContext);

if (!schemaNode.isNumber()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import static org.junit.Assert.assertTrue;

@Ignore
Expand Down Expand Up @@ -47,7 +45,11 @@ public List<Method> getTestMethods(String[] methodNames) {
List<Method> testMethods = new ArrayList<Method>();
if(methodNames.length > 0) {
for(String name : methodNames) {
testMethods.addAll(Arrays.stream(methods).filter(m -> m.getName().equals(name)).collect(Collectors.toList()));
for (Method method: methods) {
if (method.getName().equals(name)) {
testMethods.add(method);
}
}
}
return testMethods;
}
Expand Down
12 changes: 7 additions & 5 deletions src/test/java/com/networknt/schema/MaximumValidatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.stream.Stream;

import static java.lang.String.format;
import static org.junit.Assert.assertFalse;
Expand All @@ -46,9 +45,12 @@ public class MaximumValidatorTest extends BaseJsonSchemaValidatorTest {
private static ObjectMapper bigIntegerMapper = new ObjectMapper().enable(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS);

static String[][] augmentWithQuotes(String[][] values) {
return Arrays.stream(values)
.flatMap(pair -> Stream.of(pair, new String[]{pair[0], format("\"%s\"", pair[1])}))
.toArray(String[][]::new);
ArrayList<String[]> returnValue = new ArrayList<>();
for (String[] pair: values) {
returnValue.add(pair);
returnValue.add(new String[]{pair[0], format("\"%s\"", pair[1])});
}
return returnValue.toArray(new String[returnValue.size()][]);
}

@Test
Expand Down