File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
src/test/java/com/fasterxml/jackson/failing Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 3
3
import com .fasterxml .jackson .annotation .*;
4
4
5
5
import com .fasterxml .jackson .databind .*;
6
+ import com .fasterxml .jackson .databind .exc .InvalidNullException ;
6
7
7
8
public class NullConversionWithCreatorTest extends BaseMapTest
8
9
{
9
10
// [databind#2024]
10
11
static class EmptyFromNullViaCreator {
12
+ @ JsonSetter (nulls =Nulls .AS_EMPTY )
11
13
Point p ;
12
14
13
15
@ JsonCreator (mode = JsonCreator .Mode .PROPERTIES )
@@ -18,6 +20,18 @@ public EmptyFromNullViaCreator(@JsonSetter(nulls=Nulls.AS_EMPTY)
18
20
}
19
21
}
20
22
23
+ static class FailFromNullViaCreator {
24
+ @ JsonSetter (nulls =Nulls .AS_EMPTY )
25
+ Point p ;
26
+
27
+ @ JsonCreator (mode = JsonCreator .Mode .PROPERTIES )
28
+ public FailFromNullViaCreator (@ JsonSetter (nulls =Nulls .FAIL )
29
+ @ JsonProperty ("p" ) Point p )
30
+ {
31
+ this .p = p ;
32
+ }
33
+ }
34
+
21
35
/*
22
36
/**********************************************************
23
37
/* Test methods
@@ -33,4 +47,16 @@ public void testEmptyFromNullViaCreator() throws Exception
33
47
assertNotNull (result );
34
48
assertNotNull (result .p );
35
49
}
50
+
51
+ // [databind#2024]
52
+ public void testFailForNullViaCreator () throws Exception
53
+ {
54
+ try {
55
+ /*FailFromNullViaCreator result =*/ MAPPER .readValue (aposToQuotes ("{'p':null}" ),
56
+ FailFromNullViaCreator .class );
57
+ fail ("Should not pass" );
58
+ } catch (InvalidNullException e ) {
59
+ verifyException (e , "property \" p\" " );
60
+ }
61
+ }
36
62
}
You can’t perform that action at this time.
0 commit comments