@@ -11,67 +11,50 @@ public class ReadOnlyDeser1890Test
1111 extends BaseMapTest
1212{
1313 public static class PersonAnnotations {
14+ public String name ;
1415 @ JsonProperty (access = JsonProperty .Access .READ_ONLY )
15- private TestEnum testEnum ;
16- private String name ;
16+ private TestEnum testEnum = TestEnum .DEFAULT ;
1717
18- public PersonAnnotations () { }
18+ PersonAnnotations () { }
1919
2020 @ ConstructorProperties ({"testEnum" , "name" })
2121 public PersonAnnotations (TestEnum testEnum , String name ) {
22- this .testEnum = testEnum ;
23- this .name = name ;
22+ this .testEnum = testEnum ;
23+ this .name = name ;
2424 }
2525
2626 public TestEnum getTestEnum () {
27- return testEnum ;
27+ return testEnum ;
2828 }
2929
3030 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 ;
4032 }
4133 }
4234
43- public static class Person {
35+ public static class Person {
36+ public String name ;
4437 @ JsonProperty (access = JsonProperty .Access .READ_ONLY )
45- private TestEnum testEnum ;
46- private String name ;
38+ private TestEnum testEnum = TestEnum .DEFAULT ;
4739
48- public Person () {
49- }
40+ Person () { }
5041
5142 public Person (TestEnum testEnum , String name ) {
52- this .testEnum = testEnum ;
53- this .name = name ;
43+ this .testEnum = testEnum ;
44+ this .name = name ;
5445 }
5546
5647 public TestEnum getTestEnum () {
57- return testEnum ;
48+ return testEnum ;
5849 }
5950
6051 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 ;
7053 }
7154 }
7255
7356 enum TestEnum {
74- TEST
57+ DEFAULT , TEST ;
7558 }
7659
7760 /*
@@ -84,25 +67,27 @@ enum TestEnum{
8467
8568 public void testDeserializeAnnotationsOneField () throws IOException {
8669 PersonAnnotations person = MAPPER .readValue ("{\" testEnum\" :\" \" }" , PersonAnnotations .class );
87- assertNull (person .getTestEnum ());
70+ assertEquals (TestEnum .DEFAULT , person .getTestEnum ());
71+ assertNull (person .name );
8872 }
8973
9074 public void testDeserializeAnnotationsTwoFields () throws IOException {
9175 PersonAnnotations person = MAPPER .readValue ("{\" testEnum\" :\" \" ,\" name\" :\" changyong\" }" ,
9276 PersonAnnotations .class );
93- assertNull ( person .getTestEnum ());
94- assertEquals ("changyong" , person .getName () );
77+ assertEquals ( TestEnum . DEFAULT , person .getTestEnum ());
78+ assertEquals ("changyong" , person .name );
9579 }
9680
9781 public void testDeserializeOneField () throws IOException {
9882 Person person = MAPPER .readValue ("{\" testEnum\" :\" \" }" , Person .class );
99- assertNull (person .getTestEnum ());
83+ assertEquals (TestEnum .DEFAULT , person .getTestEnum ());
84+ assertNull (person .name );
10085 }
10186
10287 public void testDeserializeTwoFields () throws IOException {
10388 Person person = MAPPER .readValue ("{\" testEnum\" :\" \" ,\" name\" :\" changyong\" }" ,
10489 Person .class );
105- assertNull ( person .getTestEnum ());
106- assertEquals ("changyong" , person .getName () );
90+ assertEquals ( TestEnum . DEFAULT , person .getTestEnum ());
91+ assertEquals ("changyong" , person .name );
10792 }
10893}
0 commit comments