@@ -86,12 +86,15 @@ public String findImplicitPropertyName(AnnotatedMember param) {
86
86
/**********************************************************
87
87
*/
88
88
89
+ private final ObjectMapper MAPPER = newJsonMapper ();
90
+
89
91
@ Test
90
92
public void testSetterlessProperty () throws Exception
91
93
{
92
94
ImmutableId input = new ImmutableId (13 );
93
- ObjectMapper m = new ObjectMapper ();
94
- m .setAnnotationIntrospector (new MyParamIntrospector ());
95
+ ObjectMapper m = jsonMapperBuilder ()
96
+ .annotationIntrospector (new MyParamIntrospector ())
97
+ .build ();
95
98
String json = m .writerWithDefaultPrettyPrinter ().writeValueAsString (input );
96
99
97
100
ImmutableId output = m .readValue (json , ImmutableId .class );
@@ -105,10 +108,9 @@ public void testSetterlessProperty() throws Exception
105
108
public void testSetterlessPropertyWithEmptyConstructor () throws Exception
106
109
{
107
110
ImmutableIdWithEmptyConstuctor input = new ImmutableIdWithEmptyConstuctor (13 );
108
- ObjectMapper m = new ObjectMapper ();
109
- String json = m .writerWithDefaultPrettyPrinter ().writeValueAsString (input );
111
+ String json = MAPPER .writerWithDefaultPrettyPrinter ().writeValueAsString (input );
110
112
111
- ImmutableIdWithEmptyConstuctor output = m .readValue (json , ImmutableIdWithEmptyConstuctor .class );
113
+ ImmutableIdWithEmptyConstuctor output = MAPPER .readValue (json , ImmutableIdWithEmptyConstuctor .class );
112
114
assertNotNull (output );
113
115
114
116
assertEquals (input .id , output .id );
@@ -118,8 +120,9 @@ public void testSetterlessPropertyWithEmptyConstructor() throws Exception
118
120
public void testSetterlessPropertyWithJsonCreator () throws Exception
119
121
{
120
122
ImmutableIdWithJsonCreatorAnnotation input = new ImmutableIdWithJsonCreatorAnnotation (13 );
121
- ObjectMapper m = new ObjectMapper ();
122
- m .setAnnotationIntrospector (new MyParamIntrospector ());
123
+ ObjectMapper m = jsonMapperBuilder ()
124
+ .annotationIntrospector (new MyParamIntrospector ())
125
+ .build ();
123
126
String json = m .writerWithDefaultPrettyPrinter ().writeValueAsString (input );
124
127
125
128
ImmutableIdWithJsonCreatorAnnotation output =
@@ -134,11 +137,10 @@ public void testSetterlessPropertyWithJsonCreator() throws Exception
134
137
public void testSetterlessPropertyWithJsonPropertyField () throws Exception
135
138
{
136
139
ImmutableIdWithJsonPropertyConstructorAnnotation input = new ImmutableIdWithJsonPropertyConstructorAnnotation (13 );
137
- ObjectMapper m = new ObjectMapper ();
138
- String json = m .writerWithDefaultPrettyPrinter ().writeValueAsString (input );
140
+ String json = MAPPER .writerWithDefaultPrettyPrinter ().writeValueAsString (input );
139
141
140
142
ImmutableIdWithJsonPropertyConstructorAnnotation output =
141
- m .readValue (json , ImmutableIdWithJsonPropertyConstructorAnnotation .class );
143
+ MAPPER .readValue (json , ImmutableIdWithJsonPropertyConstructorAnnotation .class );
142
144
assertNotNull (output );
143
145
144
146
assertEquals (input .id , output .id );
@@ -148,8 +150,9 @@ public void testSetterlessPropertyWithJsonPropertyField() throws Exception
148
150
public void testSetterlessPropertyWithJsonPropertyConstructor () throws Exception
149
151
{
150
152
ImmutableIdWithJsonPropertyFieldAnnotation input = new ImmutableIdWithJsonPropertyFieldAnnotation (13 );
151
- ObjectMapper m = new ObjectMapper ();
152
- m .setAnnotationIntrospector (new MyParamIntrospector ());
153
+ ObjectMapper m = jsonMapperBuilder ()
154
+ .annotationIntrospector (new MyParamIntrospector ())
155
+ .build ();
153
156
String json = m .writerWithDefaultPrettyPrinter ().writeValueAsString (input );
154
157
155
158
ImmutableIdWithJsonPropertyFieldAnnotation output =
0 commit comments