Skip to content

Commit 883c020

Browse files
committed
...
1 parent 13f59e0 commit 883c020

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/creators/SingleImmutableFieldCreatorTest.java

+15-12
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,15 @@ public String findImplicitPropertyName(AnnotatedMember param) {
8686
/**********************************************************
8787
*/
8888

89+
private final ObjectMapper MAPPER = newJsonMapper();
90+
8991
@Test
9092
public void testSetterlessProperty() throws Exception
9193
{
9294
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();
9598
String json = m.writerWithDefaultPrettyPrinter().writeValueAsString(input);
9699

97100
ImmutableId output = m.readValue(json, ImmutableId.class);
@@ -105,10 +108,9 @@ public void testSetterlessProperty() throws Exception
105108
public void testSetterlessPropertyWithEmptyConstructor() throws Exception
106109
{
107110
ImmutableIdWithEmptyConstuctor input = new ImmutableIdWithEmptyConstuctor(13);
108-
ObjectMapper m = new ObjectMapper();
109-
String json = m.writerWithDefaultPrettyPrinter().writeValueAsString(input);
111+
String json = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(input);
110112

111-
ImmutableIdWithEmptyConstuctor output = m.readValue(json, ImmutableIdWithEmptyConstuctor.class);
113+
ImmutableIdWithEmptyConstuctor output = MAPPER.readValue(json, ImmutableIdWithEmptyConstuctor.class);
112114
assertNotNull(output);
113115

114116
assertEquals(input.id, output.id);
@@ -118,8 +120,9 @@ public void testSetterlessPropertyWithEmptyConstructor() throws Exception
118120
public void testSetterlessPropertyWithJsonCreator() throws Exception
119121
{
120122
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();
123126
String json = m.writerWithDefaultPrettyPrinter().writeValueAsString(input);
124127

125128
ImmutableIdWithJsonCreatorAnnotation output =
@@ -134,11 +137,10 @@ public void testSetterlessPropertyWithJsonCreator() throws Exception
134137
public void testSetterlessPropertyWithJsonPropertyField() throws Exception
135138
{
136139
ImmutableIdWithJsonPropertyConstructorAnnotation input = new ImmutableIdWithJsonPropertyConstructorAnnotation(13);
137-
ObjectMapper m = new ObjectMapper();
138-
String json = m.writerWithDefaultPrettyPrinter().writeValueAsString(input);
140+
String json = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(input);
139141

140142
ImmutableIdWithJsonPropertyConstructorAnnotation output =
141-
m.readValue(json, ImmutableIdWithJsonPropertyConstructorAnnotation.class);
143+
MAPPER.readValue(json, ImmutableIdWithJsonPropertyConstructorAnnotation.class);
142144
assertNotNull(output);
143145

144146
assertEquals(input.id, output.id);
@@ -148,8 +150,9 @@ public void testSetterlessPropertyWithJsonPropertyField() throws Exception
148150
public void testSetterlessPropertyWithJsonPropertyConstructor() throws Exception
149151
{
150152
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();
153156
String json = m.writerWithDefaultPrettyPrinter().writeValueAsString(input);
154157

155158
ImmutableIdWithJsonPropertyFieldAnnotation output =

0 commit comments

Comments
 (0)