18
18
19
19
class JsonWalkApplyDefaultsTest {
20
20
21
- @ AfterEach
21
+ /* @AfterEach
22
22
void cleanup() {
23
23
CollectorContext.getInstance().reset();
24
- }
24
+ }*/
25
25
26
26
@ ParameterizedTest
27
27
@ ValueSource (booleans = { true , false })
@@ -33,14 +33,15 @@ void testApplyDefaults3(boolean shouldValidateSchema) throws IOException {
33
33
if (shouldValidateSchema ) {
34
34
assertThat (result .getValidationMessages ().stream ().map (ValidationMessage ::getMessage ).collect (Collectors .toList ()),
35
35
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" ));
37
38
} else {
38
39
assertThat (result .getValidationMessages (), Matchers .empty ());
39
40
}
40
41
// TODO: In Java 14 use text blocks
41
42
assertEquals (
42
43
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\" }}}" ),
44
45
inputNode );
45
46
}
46
47
@@ -53,10 +54,11 @@ void testApplyDefaults2() throws IOException {
53
54
assertThat (result .getValidationMessages ().stream ().map (ValidationMessage ::getMessage ).collect (Collectors .toList ()),
54
55
Matchers .containsInAnyOrder ("$.outer.mixedObject.intValue_missingButError: string found, integer expected" ,
55
56
"$.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" ));
57
59
assertEquals (
58
60
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\" }}}" ),
60
62
inputNode );
61
63
}
62
64
@@ -70,10 +72,11 @@ void testApplyDefaults1() throws IOException {
70
72
Matchers .containsInAnyOrder ("$.outer.mixedObject.intValue_null: null found, integer expected" ,
71
73
"$.outer.mixedObject.intValue_missingButError: string found, integer expected" ,
72
74
"$.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" ));
74
77
assertEquals (
75
78
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\" }}}" ),
77
80
inputNode );
78
81
}
79
82
0 commit comments