Skip to content

Commit 1c406fd

Browse files
chore(deps): update dependency com.networknt:json-schema-validator to v2 (#23)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: M.P. Korstanje <[email protected]>
1 parent 744ffae commit 1c406fd

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
<dependency>
115115
<groupId>com.networknt</groupId>
116116
<artifactId>json-schema-validator</artifactId>
117-
<version>1.5.9</version>
117+
<version>2.0.0</version>
118118
<scope>test</scope>
119119
</dependency>
120120
</dependencies>

java/src/test/java/io/cucumber/jsonformatter/MessagesToJsonWriterAcceptanceTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package io.cucumber.jsonformatter;
22

3+
import com.networknt.schema.Error;
34
import com.networknt.schema.InputFormat;
4-
import com.networknt.schema.JsonSchema;
5-
import com.networknt.schema.JsonSchemaFactory;
6-
import com.networknt.schema.ValidationMessage;
5+
import com.networknt.schema.Schema;
6+
import com.networknt.schema.SchemaRegistry;
7+
import com.networknt.schema.SpecificationVersion;
78
import io.cucumber.compatibilitykit.MessageOrderer;
89
import io.cucumber.messages.NdjsonToMessageIterable;
910
import io.cucumber.messages.types.Envelope;
@@ -24,12 +25,10 @@
2425
import java.util.Comparator;
2526
import java.util.List;
2627
import java.util.Random;
27-
import java.util.Set;
2828
import java.util.function.Consumer;
2929
import java.util.stream.Collectors;
3030
import java.util.stream.Stream;
3131

32-
import static com.networknt.schema.SpecVersion.VersionFlag.V202012;
3332
import static io.cucumber.jsonformatter.Jackson.OBJECT_MAPPER;
3433
import static io.cucumber.jsonformatter.Jackson.PRETTY_PRINTER;
3534
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -39,7 +38,7 @@
3938
class MessagesToJsonWriterAcceptanceTest {
4039
private static final NdjsonToMessageIterable.Deserializer deserializer = (json) -> OBJECT_MAPPER.readValue(json, Envelope.class);
4140
private static final MessagesToJsonWriter.Serializer serializer = OBJECT_MAPPER.writer(PRETTY_PRINTER)::writeValue;
42-
private static final JsonSchema jsonSchema = readJsonSchema();
41+
private static final Schema jsonSchema = readJsonSchema();
4342
private static final Random random = new Random(202509171757L);
4443
private static final MessageOrderer messageOrderer = new MessageOrderer(random);
4544

@@ -85,10 +84,11 @@ private static void assertJsonEquals(String expected, String actual) throws JSON
8584
JSONAssert.assertEquals(expected, actual, true);
8685
}
8786

88-
private static JsonSchema readJsonSchema() {
87+
private static Schema readJsonSchema() {
8988
Path path = Paths.get("../testdata/json-schema/src/cucumber-jvm.json");
9089
try (InputStream resource = Files.newInputStream(path)) {
91-
return JsonSchemaFactory.getInstance(V202012).getSchema(resource);
90+
SchemaRegistry registry = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12);
91+
return registry.getSchema(resource);
9292
} catch (IOException e) {
9393
throw new RuntimeException(e);
9494
}
@@ -117,11 +117,11 @@ void validateAgainstJsonSchema(TestCase testCase) throws IOException {
117117
// So for schema validation there is no need to run the formatter
118118
// Makes the test faster
119119
byte[] expected = Files.readAllBytes(testCase.expected);
120-
Set<ValidationMessage> assertions = jsonSchema.validate(
120+
List<Error> assertions = jsonSchema.validate(
121121
new String(expected, UTF_8),
122122
InputFormat.JSON,
123123
// By default, since Draft 2019-09 the format keyword only generates annotations and not assertions
124-
executionContext -> executionContext.getExecutionConfig().setFormatAssertionsEnabled(true));
124+
executionContext -> executionContext.executionConfig(config -> config.formatAssertionsEnabled(true)));
125125
assertThat(assertions).isEmpty();
126126
}
127127

0 commit comments

Comments
 (0)