Skip to content

Commit 4065b69

Browse files
committed
Update code
1 parent a0e236b commit 4065b69

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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)