8
8
import com .fasterxml .jackson .databind .annotation .JsonDeserialize ;
9
9
10
10
import static org .junit .jupiter .api .Assertions .assertEquals ;
11
+ import static org .junit .jupiter .api .Assertions .assertNull ;
11
12
12
13
import static com .fasterxml .jackson .databind .testutil .DatabindTestUtil .a2q ;
13
14
@@ -51,9 +52,9 @@ public ValueClassXY build() {
51
52
@ JsonDeserialize (builder =CreatorBuilderXY .class )
52
53
static class CreatorValueXY
53
54
{
54
- final int _x , _y ;
55
+ final Integer _x , _y ;
55
56
56
- protected CreatorValueXY (int x , int y ) {
57
+ protected CreatorValueXY (Integer x , Integer y ) {
57
58
_x = x ;
58
59
_y = y ;
59
60
}
@@ -62,11 +63,11 @@ protected CreatorValueXY(int x, int y) {
62
63
@ JsonIgnoreProperties ({ "bogus" })
63
64
static class CreatorBuilderXY
64
65
{
65
- public int x , y ;
66
+ public Integer x , y ;
66
67
67
68
@ JsonCreator
68
- public CreatorBuilderXY (@ JsonProperty ("x" ) @ JsonView (ViewX .class ) int x ,
69
- @ JsonProperty ("y" ) @ JsonView (ViewY .class ) int y )
69
+ public CreatorBuilderXY (@ JsonProperty ("x" ) @ JsonView (ViewX .class ) Integer x ,
70
+ @ JsonProperty ("y" ) @ JsonView (ViewY .class ) Integer y )
70
71
{
71
72
this .x = x ;
72
73
this .y = y ;
@@ -110,12 +111,12 @@ public void testCreatorViews() throws Exception
110
111
.withView (ViewX .class )
111
112
.readValue (json );
112
113
assertEquals (5 , resultX ._x );
113
- assertEquals ( 0 , resultX ._y );
114
+ assertNull ( resultX ._y );
114
115
115
116
CreatorValueXY resultY = MAPPER .readerFor (CreatorValueXY .class )
116
117
.withView (ViewY .class )
117
118
.readValue (json );
118
- assertEquals ( 0 , resultY ._x );
119
+ assertNull ( resultY ._x );
119
120
assertEquals (10 , resultY ._y );
120
121
}
121
122
}
0 commit comments