From 6de988a086314d8e2f64b38235aedcd2722abd64 Mon Sep 17 00:00:00 2001 From: Justin Tay <49700559+justin-tay@users.noreply.github.com> Date: Wed, 31 Jan 2024 20:52:22 +0800 Subject: [PATCH] Fix os line ending difference --- .../com/networknt/schema/OutputUnitTest.java | 181 +----------------- 1 file changed, 6 insertions(+), 175 deletions(-) diff --git a/src/test/java/com/networknt/schema/OutputUnitTest.java b/src/test/java/com/networknt/schema/OutputUnitTest.java index f4a117c7c..840e3cdc8 100644 --- a/src/test/java/com/networknt/schema/OutputUnitTest.java +++ b/src/test/java/com/networknt/schema/OutputUnitTest.java @@ -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); } @@ -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); } @@ -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); } }