Skip to content

Commit

Permalink
Fix os line ending difference
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-tay committed Jan 31, 2024
1 parent d37aa90 commit 6de988a
Showing 1 changed file with 6 additions and 175 deletions.
181 changes: 6 additions & 175 deletions src/test/java/com/networknt/schema/OutputUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,69 +97,8 @@ void annotationCollectionList() throws JsonProcessingException {
executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true);
executionConfiguration.getExecutionConfig().setAnnotationCollectionPredicate(keyword -> true);
});
String output = JsonMapperFactory.getInstance().writerWithDefaultPrettyPrinter().writeValueAsString(outputUnit);
String expected = "{\r\n"
+ " \"valid\" : false,\r\n"
+ " \"details\" : [ {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"/properties/foo/allOf/0\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/properties/foo/allOf/0\",\r\n"
+ " \"instanceLocation\" : \"/foo\",\r\n"
+ " \"errors\" : {\r\n"
+ " \"required\" : \"required property 'unspecified-prop' not found\"\r\n"
+ " }\r\n"
+ " }, {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"/properties/foo/allOf/1/properties/foo-prop\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\r\n"
+ " \"instanceLocation\" : \"/foo/foo-prop\",\r\n"
+ " \"errors\" : {\r\n"
+ " \"const\" : \"must be a constant value 1\"\r\n"
+ " },\r\n"
+ " \"droppedAnnotations\" : {\r\n"
+ " \"title\" : \"foo-prop-title\"\r\n"
+ " }\r\n"
+ " }, {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"/properties/bar/$ref/properties/bar-prop\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\r\n"
+ " \"instanceLocation\" : \"/bar/bar-prop\",\r\n"
+ " \"errors\" : {\r\n"
+ " \"minimum\" : \"must have a minimum value of 10\"\r\n"
+ " },\r\n"
+ " \"droppedAnnotations\" : {\r\n"
+ " \"title\" : \"bar-prop-title\"\r\n"
+ " }\r\n"
+ " }, {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"/properties/foo/allOf/1\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\r\n"
+ " \"instanceLocation\" : \"/foo\",\r\n"
+ " \"droppedAnnotations\" : {\r\n"
+ " \"properties\" : [ \"foo-prop\" ],\r\n"
+ " \"title\" : \"foo-title\",\r\n"
+ " \"additionalProperties\" : [ \"foo-prop\", \"other-prop\" ]\r\n"
+ " }\r\n"
+ " }, {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"/properties/bar/$ref\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/$defs/bar\",\r\n"
+ " \"instanceLocation\" : \"/bar\",\r\n"
+ " \"droppedAnnotations\" : {\r\n"
+ " \"properties\" : [ \"bar-prop\" ],\r\n"
+ " \"title\" : \"bar-title\"\r\n"
+ " }\r\n"
+ " }, {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#\",\r\n"
+ " \"instanceLocation\" : \"\",\r\n"
+ " \"droppedAnnotations\" : {\r\n"
+ " \"properties\" : [ \"foo\", \"bar\" ],\r\n"
+ " \"title\" : \"root\"\r\n"
+ " }\r\n"
+ " } ]\r\n"
+ "}";
String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit);
String expected = "{\"valid\":false,\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/0\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/0\",\"instanceLocation\":\"/foo\",\"errors\":{\"required\":\"required property 'unspecified-prop' not found\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1/properties/foo-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\"instanceLocation\":\"/foo/foo-prop\",\"errors\":{\"const\":\"must be a constant value 1\"},\"droppedAnnotations\":{\"title\":\"foo-prop-title\"}},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref/properties/bar-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\"instanceLocation\":\"/bar/bar-prop\",\"errors\":{\"minimum\":\"must have a minimum value of 10\"},\"droppedAnnotations\":{\"title\":\"bar-prop-title\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\"instanceLocation\":\"/foo\",\"droppedAnnotations\":{\"properties\":[\"foo-prop\"],\"title\":\"foo-title\",\"additionalProperties\":[\"foo-prop\",\"other-prop\"]}},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar\",\"instanceLocation\":\"/bar\",\"droppedAnnotations\":{\"properties\":[\"bar-prop\"],\"title\":\"bar-title\"}},{\"valid\":false,\"evaluationPath\":\"\",\"schemaLocation\":\"https://json-schema.org/schemas/example#\",\"instanceLocation\":\"\",\"droppedAnnotations\":{\"properties\":[\"foo\",\"bar\"],\"title\":\"root\"}}]}";
assertEquals(expected, output);
}

Expand All @@ -176,69 +115,8 @@ void annotationCollectionHierarchical() throws JsonProcessingException {
executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true);
executionConfiguration.getExecutionConfig().setAnnotationCollectionPredicate(keyword -> true);
});
String output = JsonMapperFactory.getInstance().writerWithDefaultPrettyPrinter().writeValueAsString(outputUnit);
String expected = "{\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#\",\r\n"
+ " \"instanceLocation\" : \"\",\r\n"
+ " \"droppedAnnotations\" : {\r\n"
+ " \"properties\" : [ \"foo\", \"bar\" ],\r\n"
+ " \"title\" : \"root\"\r\n"
+ " },\r\n"
+ " \"details\" : [ {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"/properties/foo/allOf/0\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/properties/foo/allOf/0\",\r\n"
+ " \"instanceLocation\" : \"/foo\",\r\n"
+ " \"errors\" : {\r\n"
+ " \"required\" : \"required property 'unspecified-prop' not found\"\r\n"
+ " }\r\n"
+ " }, {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"/properties/foo/allOf/1\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\r\n"
+ " \"instanceLocation\" : \"/foo\",\r\n"
+ " \"droppedAnnotations\" : {\r\n"
+ " \"properties\" : [ \"foo-prop\" ],\r\n"
+ " \"title\" : \"foo-title\",\r\n"
+ " \"additionalProperties\" : [ \"foo-prop\", \"other-prop\" ]\r\n"
+ " },\r\n"
+ " \"details\" : [ {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"/properties/foo/allOf/1/properties/foo-prop\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\r\n"
+ " \"instanceLocation\" : \"/foo/foo-prop\",\r\n"
+ " \"errors\" : {\r\n"
+ " \"const\" : \"must be a constant value 1\"\r\n"
+ " },\r\n"
+ " \"droppedAnnotations\" : {\r\n"
+ " \"title\" : \"foo-prop-title\"\r\n"
+ " }\r\n"
+ " } ]\r\n"
+ " }, {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"/properties/bar/$ref\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/$defs/bar\",\r\n"
+ " \"instanceLocation\" : \"/bar\",\r\n"
+ " \"droppedAnnotations\" : {\r\n"
+ " \"properties\" : [ \"bar-prop\" ],\r\n"
+ " \"title\" : \"bar-title\"\r\n"
+ " },\r\n"
+ " \"details\" : [ {\r\n"
+ " \"valid\" : false,\r\n"
+ " \"evaluationPath\" : \"/properties/bar/$ref/properties/bar-prop\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\r\n"
+ " \"instanceLocation\" : \"/bar/bar-prop\",\r\n"
+ " \"errors\" : {\r\n"
+ " \"minimum\" : \"must have a minimum value of 10\"\r\n"
+ " },\r\n"
+ " \"droppedAnnotations\" : {\r\n"
+ " \"title\" : \"bar-prop-title\"\r\n"
+ " }\r\n"
+ " } ]\r\n"
+ " } ]\r\n"
+ "}";
String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit);
String expected = "{\"valid\":false,\"evaluationPath\":\"\",\"schemaLocation\":\"https://json-schema.org/schemas/example#\",\"instanceLocation\":\"\",\"droppedAnnotations\":{\"properties\":[\"foo\",\"bar\"],\"title\":\"root\"},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/0\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/0\",\"instanceLocation\":\"/foo\",\"errors\":{\"required\":\"required property 'unspecified-prop' not found\"}},{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\"instanceLocation\":\"/foo\",\"droppedAnnotations\":{\"properties\":[\"foo-prop\"],\"title\":\"foo-title\",\"additionalProperties\":[\"foo-prop\",\"other-prop\"]},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/foo/allOf/1/properties/foo-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\"instanceLocation\":\"/foo/foo-prop\",\"errors\":{\"const\":\"must be a constant value 1\"},\"droppedAnnotations\":{\"title\":\"foo-prop-title\"}}]},{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar\",\"instanceLocation\":\"/bar\",\"droppedAnnotations\":{\"properties\":[\"bar-prop\"],\"title\":\"bar-title\"},\"details\":[{\"valid\":false,\"evaluationPath\":\"/properties/bar/$ref/properties/bar-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\"instanceLocation\":\"/bar/bar-prop\",\"errors\":{\"minimum\":\"must have a minimum value of 10\"},\"droppedAnnotations\":{\"title\":\"bar-prop-title\"}}]}]}";
assertEquals(expected, output);
}

Expand All @@ -255,55 +133,8 @@ void annotationCollectionHierarchical2() throws JsonProcessingException {
executionConfiguration.getExecutionConfig().setAnnotationCollectionEnabled(true);
executionConfiguration.getExecutionConfig().setAnnotationCollectionPredicate(keyword -> true);
});
String output = JsonMapperFactory.getInstance().writerWithDefaultPrettyPrinter().writeValueAsString(outputUnit);
String expected = "{\r\n"
+ " \"valid\" : true,\r\n"
+ " \"evaluationPath\" : \"\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#\",\r\n"
+ " \"instanceLocation\" : \"\",\r\n"
+ " \"annotations\" : {\r\n"
+ " \"properties\" : [ \"foo\", \"bar\" ],\r\n"
+ " \"title\" : \"root\"\r\n"
+ " },\r\n"
+ " \"details\" : [ {\r\n"
+ " \"valid\" : true,\r\n"
+ " \"evaluationPath\" : \"/properties/foo/allOf/1\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\r\n"
+ " \"instanceLocation\" : \"/foo\",\r\n"
+ " \"annotations\" : {\r\n"
+ " \"properties\" : [ \"foo-prop\" ],\r\n"
+ " \"title\" : \"foo-title\",\r\n"
+ " \"additionalProperties\" : [ \"foo-prop\", \"unspecified-prop\" ]\r\n"
+ " },\r\n"
+ " \"details\" : [ {\r\n"
+ " \"valid\" : true,\r\n"
+ " \"evaluationPath\" : \"/properties/foo/allOf/1/properties/foo-prop\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\r\n"
+ " \"instanceLocation\" : \"/foo/foo-prop\",\r\n"
+ " \"annotations\" : {\r\n"
+ " \"title\" : \"foo-prop-title\"\r\n"
+ " }\r\n"
+ " } ]\r\n"
+ " }, {\r\n"
+ " \"valid\" : true,\r\n"
+ " \"evaluationPath\" : \"/properties/bar/$ref\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/$defs/bar\",\r\n"
+ " \"instanceLocation\" : \"/bar\",\r\n"
+ " \"annotations\" : {\r\n"
+ " \"properties\" : [ \"bar-prop\" ],\r\n"
+ " \"title\" : \"bar-title\"\r\n"
+ " },\r\n"
+ " \"details\" : [ {\r\n"
+ " \"valid\" : true,\r\n"
+ " \"evaluationPath\" : \"/properties/bar/$ref/properties/bar-prop\",\r\n"
+ " \"schemaLocation\" : \"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\r\n"
+ " \"instanceLocation\" : \"/bar/bar-prop\",\r\n"
+ " \"annotations\" : {\r\n"
+ " \"title\" : \"bar-prop-title\"\r\n"
+ " }\r\n"
+ " } ]\r\n"
+ " } ]\r\n"
+ "}";
String output = JsonMapperFactory.getInstance().writeValueAsString(outputUnit);
String expected = "{\"valid\":true,\"evaluationPath\":\"\",\"schemaLocation\":\"https://json-schema.org/schemas/example#\",\"instanceLocation\":\"\",\"annotations\":{\"properties\":[\"foo\",\"bar\"],\"title\":\"root\"},\"details\":[{\"valid\":true,\"evaluationPath\":\"/properties/foo/allOf/1\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1\",\"instanceLocation\":\"/foo\",\"annotations\":{\"properties\":[\"foo-prop\"],\"title\":\"foo-title\",\"additionalProperties\":[\"foo-prop\",\"unspecified-prop\"]},\"details\":[{\"valid\":true,\"evaluationPath\":\"/properties/foo/allOf/1/properties/foo-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/properties/foo/allOf/1/properties/foo-prop\",\"instanceLocation\":\"/foo/foo-prop\",\"annotations\":{\"title\":\"foo-prop-title\"}}]},{\"valid\":true,\"evaluationPath\":\"/properties/bar/$ref\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar\",\"instanceLocation\":\"/bar\",\"annotations\":{\"properties\":[\"bar-prop\"],\"title\":\"bar-title\"},\"details\":[{\"valid\":true,\"evaluationPath\":\"/properties/bar/$ref/properties/bar-prop\",\"schemaLocation\":\"https://json-schema.org/schemas/example#/$defs/bar/properties/bar-prop\",\"instanceLocation\":\"/bar/bar-prop\",\"annotations\":{\"title\":\"bar-prop-title\"}}]}]}";
assertEquals(expected, output);
}
}

0 comments on commit 6de988a

Please sign in to comment.