Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@
import com.dslplatform.json.JsonWriter;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.networknt.schema.JsonSchema;
import com.networknt.schema.JsonSchemaFactory;
import com.networknt.schema.SpecVersion;
import com.networknt.schema.ValidationMessage;
import com.networknt.schema.Schema;
import com.networknt.schema.SchemaRegistry;
import com.networknt.schema.SpecificationVersion;
import org.awaitility.core.ThrowingRunnable;
import org.stagemonitor.configuration.ConfigurationRegistry;
import specs.TestJsonSpec;
Expand Down Expand Up @@ -384,7 +383,7 @@ public void verifyErrorSchema(JsonNode jsonNode) {
}

private void verifyJsonSchemas(Function<DslJsonSerializer.Writer, String> serializerFunction,
Function<SchemaInstance, JsonSchema> schemaFunction,
Function<SchemaInstance, Schema> schemaFunction,
Function<SchemaInstance, String> schemaPathFunction) {
if (!verifyJsonSchema) {
return;
Expand All @@ -394,14 +393,13 @@ private void verifyJsonSchemas(Function<DslJsonSerializer.Writer, String> serial
String serializedString = serializerFunction.apply(schemaInstance.serializer);
JsonNode jsonNode = asJson(serializedString);

JsonSchema schema = schemaFunction.apply(schemaInstance);
Schema schema = schemaFunction.apply(schemaInstance);
verifyJsonSchema(jsonNode, schema, schemaPathFunction.apply(schemaInstance));
}
}

private void verifyJsonSchema(JsonNode jsonNode, JsonSchema schema, String schemaPath) {
Set<ValidationMessage> errors = schema.validate(jsonNode);
assertThat(errors)
private void verifyJsonSchema(JsonNode jsonNode, Schema schema, String schemaPath) {
assertThat(schema.validate(jsonNode))
.withFailMessage("%s\nJSON schema path = %s\n\n%s", errors, schemaPath, jsonNode.toPrettyString())
.isEmpty();
}
Expand Down Expand Up @@ -777,11 +775,11 @@ private enum SchemaInstance {
false);

private final DslJsonSerializer.Writer serializer;
private final JsonSchema transactionSchema;
private final Schema transactionSchema;
private final String transactionSchemaPath;
private final JsonSchema spanSchema;
private final Schema spanSchema;
private final String spanSchemaPath;
private final JsonSchema errorSchema;
private final Schema errorSchema;
private final String errorSchemaPath;

SchemaInstance(String transactionSchema, String spanSchema, String errorSchema, boolean isLatest) {
Expand All @@ -807,9 +805,9 @@ private enum SchemaInstance {
this.serializer = new DslJsonSerializer(spyConfig, client, metaData).newWriter();
}

private static JsonSchema getSchema(String resource) {
private static Schema getSchema(String resource) {
InputStream input = Objects.requireNonNull(MockReporter.class.getResourceAsStream(resource), "missing resource " + resource);
return JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4).getSchema(input);
return SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4).getSchema(input);
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<version.ecs.logging>1.7.0</version.ecs.logging>
<version.spring>5.0.15.RELEASE</version.spring>
<version.jetty-server>9.4.11.v20180605</version.jetty-server>
<version.json-schema-validator>1.5.9</version.json-schema-validator>
<version.json-schema-validator>2.0.0</version.json-schema-validator>
<!-- Byte Buddy and ASM must be kept in sync -->
<version.byte-buddy>1.18.1</version.byte-buddy>
<version.asm>9.9</version.asm>
Expand Down
Loading