@@ -11,67 +11,50 @@ public class ReadOnlyDeser1890Test
11
11
extends BaseMapTest
12
12
{
13
13
public static class PersonAnnotations {
14
+ public String name ;
14
15
@ JsonProperty (access = JsonProperty .Access .READ_ONLY )
15
- private TestEnum testEnum ;
16
- private String name ;
16
+ private TestEnum testEnum = TestEnum .DEFAULT ;
17
17
18
- public PersonAnnotations () { }
18
+ PersonAnnotations () { }
19
19
20
20
@ ConstructorProperties ({"testEnum" , "name" })
21
21
public PersonAnnotations (TestEnum testEnum , String name ) {
22
- this .testEnum = testEnum ;
23
- this .name = name ;
22
+ this .testEnum = testEnum ;
23
+ this .name = name ;
24
24
}
25
25
26
26
public TestEnum getTestEnum () {
27
- return testEnum ;
27
+ return testEnum ;
28
28
}
29
29
30
30
public void setTestEnum (TestEnum testEnum ) {
31
- this .testEnum = testEnum ;
32
- }
33
-
34
- public String getName () {
35
- return name ;
36
- }
37
-
38
- public void setName (String name ) {
39
- this .name = name ;
31
+ this .testEnum = testEnum ;
40
32
}
41
33
}
42
34
43
- public static class Person {
35
+ public static class Person {
36
+ public String name ;
44
37
@ JsonProperty (access = JsonProperty .Access .READ_ONLY )
45
- private TestEnum testEnum ;
46
- private String name ;
38
+ private TestEnum testEnum = TestEnum .DEFAULT ;
47
39
48
- public Person () {
49
- }
40
+ Person () { }
50
41
51
42
public Person (TestEnum testEnum , String name ) {
52
- this .testEnum = testEnum ;
53
- this .name = name ;
43
+ this .testEnum = testEnum ;
44
+ this .name = name ;
54
45
}
55
46
56
47
public TestEnum getTestEnum () {
57
- return testEnum ;
48
+ return testEnum ;
58
49
}
59
50
60
51
public void setTestEnum (TestEnum testEnum ) {
61
- this .testEnum = testEnum ;
62
- }
63
-
64
- public String getName () {
65
- return name ;
66
- }
67
-
68
- public void setName (String name ) {
69
- this .name = name ;
52
+ this .testEnum = testEnum ;
70
53
}
71
54
}
72
55
73
56
enum TestEnum {
74
- TEST
57
+ DEFAULT , TEST ;
75
58
}
76
59
77
60
/*
@@ -84,25 +67,27 @@ enum TestEnum{
84
67
85
68
public void testDeserializeAnnotationsOneField () throws IOException {
86
69
PersonAnnotations person = MAPPER .readValue ("{\" testEnum\" :\" \" }" , PersonAnnotations .class );
87
- assertNull (person .getTestEnum ());
70
+ assertEquals (TestEnum .DEFAULT , person .getTestEnum ());
71
+ assertNull (person .name );
88
72
}
89
73
90
74
public void testDeserializeAnnotationsTwoFields () throws IOException {
91
75
PersonAnnotations person = MAPPER .readValue ("{\" testEnum\" :\" \" ,\" name\" :\" changyong\" }" ,
92
76
PersonAnnotations .class );
93
- assertNull ( person .getTestEnum ());
94
- assertEquals ("changyong" , person .getName () );
77
+ assertEquals ( TestEnum . DEFAULT , person .getTestEnum ());
78
+ assertEquals ("changyong" , person .name );
95
79
}
96
80
97
81
public void testDeserializeOneField () throws IOException {
98
82
Person person = MAPPER .readValue ("{\" testEnum\" :\" \" }" , Person .class );
99
- assertNull (person .getTestEnum ());
83
+ assertEquals (TestEnum .DEFAULT , person .getTestEnum ());
84
+ assertNull (person .name );
100
85
}
101
86
102
87
public void testDeserializeTwoFields () throws IOException {
103
88
Person person = MAPPER .readValue ("{\" testEnum\" :\" \" ,\" name\" :\" changyong\" }" ,
104
89
Person .class );
105
- assertNull ( person .getTestEnum ());
106
- assertEquals ("changyong" , person .getName () );
90
+ assertEquals ( TestEnum . DEFAULT , person .getTestEnum ());
91
+ assertEquals ("changyong" , person .name );
107
92
}
108
93
}
0 commit comments