1818
1919class JsonWalkApplyDefaultsTest {
2020
21- @ AfterEach
21+ /* @AfterEach
2222 void cleanup() {
2323 CollectorContext.getInstance().reset();
24- }
24+ }*/
2525
2626 @ ParameterizedTest
2727 @ ValueSource (booleans = { true , false })
@@ -33,14 +33,15 @@ void testApplyDefaults3(boolean shouldValidateSchema) throws IOException {
3333 if (shouldValidateSchema ) {
3434 assertThat (result .getValidationMessages ().stream ().map (ValidationMessage ::getMessage ).collect (Collectors .toList ()),
3535 Matchers .containsInAnyOrder ("$.outer.mixedObject.intValue_missingButError: string found, integer expected" ,
36- "$.outer.badArray[1]: integer found, string expected" ));
36+ "$.outer.badArray[1]: integer found, string expected" ,
37+ "$.outer.reference.stringValue_missing_with_default_null: null found, string expected" ));
3738 } else {
3839 assertThat (result .getValidationMessages (), Matchers .empty ());
3940 }
4041 // TODO: In Java 14 use text blocks
4142 assertEquals (
4243 objectMapper .readTree (
43- "{\" outer\" :{\" mixedObject\" :{\" intValue_present\" :8,\" intValue_missing \" :15 ,\" intValue_missing_notRequired \" :25, \" intValue_null \" :35 ,\" intValue_missingButError \" :\" forty-five \" },\" goodArray\" :[\" hello\" ,\" five\" ],\" badArray\" :[\" hello\" ,5],\" reference\" :{\" stringValue_missing\" :\" hello\" }}}" ),
44+ "{\" outer\" :{\" mixedObject\" :{\" intValue_present\" :8,\" intValue_null \" :35 ,\" intValue_missingButError \" :\" forty-five \" ,\" intValue_missing \" :15, \" intValue_missing_notRequired \" :25 },\" goodArray\" :[\" hello\" ,\" five\" ],\" badArray\" :[\" hello\" ,5],\" reference\" :{\" stringValue_missing_with_default_null \" :null, \" stringValue_missing\" :\" hello\" }}}" ),
4445 inputNode );
4546 }
4647
@@ -53,10 +54,11 @@ void testApplyDefaults2() throws IOException {
5354 assertThat (result .getValidationMessages ().stream ().map (ValidationMessage ::getMessage ).collect (Collectors .toList ()),
5455 Matchers .containsInAnyOrder ("$.outer.mixedObject.intValue_missingButError: string found, integer expected" ,
5556 "$.outer.goodArray[1]: null found, string expected" ,
56- "$.outer.badArray[1]: null found, string expected" ));
57+ "$.outer.badArray[1]: null found, string expected" ,
58+ "$.outer.reference.stringValue_missing_with_default_null: null found, string expected" ));
5759 assertEquals (
5860 objectMapper .readTree (
59- "{\" outer\" :{\" mixedObject\" :{\" intValue_present\" :8,\" intValue_missing \" :15 ,\" intValue_missing_notRequired \" :25, \" intValue_null \" :35 ,\" intValue_missingButError \" :\" forty-five \" },\" goodArray\" :[\" hello\" ,null],\" badArray\" :[\" hello\" ,null],\" reference\" :{\" stringValue_missing\" :\" hello\" }}}" ),
61+ "{\" outer\" :{\" mixedObject\" :{\" intValue_present\" :8,\" intValue_null \" :35 ,\" intValue_missingButError \" :\" forty-five \" ,\" intValue_missing \" :15, \" intValue_missing_notRequired \" :25 },\" goodArray\" :[\" hello\" ,null],\" badArray\" :[\" hello\" ,null],\" reference\" :{\" stringValue_missing_with_default_null \" :null, \" stringValue_missing\" :\" hello\" }}}" ),
6062 inputNode );
6163 }
6264
@@ -70,10 +72,11 @@ void testApplyDefaults1() throws IOException {
7072 Matchers .containsInAnyOrder ("$.outer.mixedObject.intValue_null: null found, integer expected" ,
7173 "$.outer.mixedObject.intValue_missingButError: string found, integer expected" ,
7274 "$.outer.goodArray[1]: null found, string expected" ,
73- "$.outer.badArray[1]: null found, string expected" ));
75+ "$.outer.badArray[1]: null found, string expected" ,
76+ "$.outer.reference.stringValue_missing_with_default_null: null found, string expected" ));
7477 assertEquals (
7578 objectMapper .readTree (
76- "{\" outer\" :{\" mixedObject\" :{\" intValue_present\" :8,\" intValue_missing \" :15 ,\" intValue_missing_notRequired \" :25, \" intValue_null \" :null ,\" intValue_missingButError \" :\" forty-five \" },\" goodArray\" :[\" hello\" ,null],\" badArray\" :[\" hello\" ,null],\" reference\" :{\" stringValue_missing\" :\" hello\" }}}" ),
79+ "{\" outer\" :{\" mixedObject\" :{\" intValue_present\" :8,\" intValue_null \" :null ,\" intValue_missingButError \" :\" forty-five \" ,\" intValue_missing \" :15, \" intValue_missing_notRequired \" :25 },\" goodArray\" :[\" hello\" ,null],\" badArray\" :[\" hello\" ,null],\" reference\" :{\" stringValue_missing_with_default_null \" :null, \" stringValue_missing\" :\" hello\" }}}" ),
7780 inputNode );
7881 }
7982
0 commit comments