7
7
import com .fasterxml .jackson .annotation .JsonCreator ;
8
8
import com .fasterxml .jackson .annotation .PropertyAccessor ;
9
9
10
+ import tools .jackson .databind .DeserializationFeature ;
10
11
import tools .jackson .databind .ObjectMapper ;
11
12
import tools .jackson .databind .cfg .MapperConfig ;
12
13
import tools .jackson .databind .introspect .AnnotatedClass ;
@@ -60,7 +61,8 @@ private record PrivateRecord3906(String string, int integer) {
60
61
@ Test
61
62
public void testEmptyJsonToRecordWorkAround () throws Exception {
62
63
ObjectMapper mapper = jsonMapperBuilder ()
63
- .changeDefaultVisibility (vc ->
64
+ .disable (DeserializationFeature .FAIL_ON_NULL_FOR_PRIMITIVES )
65
+ .changeDefaultVisibility (vc ->
64
66
vc .withVisibility (PropertyAccessor .ALL , Visibility .NONE )
65
67
.withVisibility (PropertyAccessor .CREATOR , Visibility .ANY ))
66
68
.build ();
@@ -72,7 +74,8 @@ public void testEmptyJsonToRecordWorkAround() throws Exception {
72
74
@ Test
73
75
public void testEmptyJsonToRecordCreatorsVisible () throws Exception {
74
76
ObjectMapper mapper = jsonMapperBuilder ()
75
- .changeDefaultVisibility (vc ->
77
+ .disable (DeserializationFeature .FAIL_ON_NULL_FOR_PRIMITIVES )
78
+ .changeDefaultVisibility (vc ->
76
79
vc .withVisibility (PropertyAccessor .CREATOR , Visibility .NON_PRIVATE ))
77
80
.build ();
78
81
@@ -97,23 +100,29 @@ public VisibilityChecker findAutoDetectVisibility(MapperConfig<?> cfg,
97
100
}
98
101
});
99
102
}
100
- }).build ();
103
+ })
104
+ .disable (DeserializationFeature .FAIL_ON_NULL_FOR_PRIMITIVES )
105
+ .build ();
101
106
102
107
Record3906 recordDeser = mapper .readValue ("{}" , Record3906 .class );
103
108
assertEquals (new Record3906 (null , 0 ), recordDeser );
104
109
}
105
110
106
111
@ Test
107
112
public void testEmptyJsonToRecordDirectAutoDetectConfig () throws Exception {
108
- ObjectMapper mapper = newJsonMapper ();
113
+ ObjectMapper mapper = jsonMapperBuilder ()
114
+ .disable (DeserializationFeature .FAIL_ON_NULL_FOR_PRIMITIVES )
115
+ .build ();
109
116
110
117
Record3906Annotated recordDeser = mapper .readValue ("{}" , Record3906Annotated .class );
111
118
assertEquals (new Record3906Annotated (null , 0 ), recordDeser );
112
119
}
113
120
114
121
@ Test
115
122
public void testEmptyJsonToRecordJsonCreator () throws Exception {
116
- ObjectMapper mapper = newJsonMapper ();
123
+ ObjectMapper mapper = jsonMapperBuilder ()
124
+ .disable (DeserializationFeature .FAIL_ON_NULL_FOR_PRIMITIVES )
125
+ .build ();
117
126
118
127
Record3906Creator recordDeser = mapper .readValue ("{}" , Record3906Creator .class );
119
128
assertEquals (new Record3906Creator (null , 0 ), recordDeser );
@@ -143,6 +152,7 @@ public VisibilityChecker findAutoDetectVisibility(MapperConfig<?> cfg,
143
152
});
144
153
}
145
154
})
155
+ .disable (DeserializationFeature .FAIL_ON_NULL_FOR_PRIMITIVES )
146
156
.build ();
147
157
148
158
assertEquals (new Record3906 (null , 0 ),
0 commit comments