From 883c020774f5f963a92aacc8a5f07a8069451f1b Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 10 Jun 2024 15:09:45 -0700 Subject: [PATCH] ... --- .../SingleImmutableFieldCreatorTest.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/creators/SingleImmutableFieldCreatorTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/creators/SingleImmutableFieldCreatorTest.java index 7adf63b174..9b6a414228 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/creators/SingleImmutableFieldCreatorTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/creators/SingleImmutableFieldCreatorTest.java @@ -86,12 +86,15 @@ public String findImplicitPropertyName(AnnotatedMember param) { /********************************************************** */ + private final ObjectMapper MAPPER = newJsonMapper(); + @Test public void testSetterlessProperty() throws Exception { ImmutableId input = new ImmutableId(13); - ObjectMapper m = new ObjectMapper(); - m.setAnnotationIntrospector(new MyParamIntrospector()); + ObjectMapper m = jsonMapperBuilder() + .annotationIntrospector(new MyParamIntrospector()) + .build(); String json = m.writerWithDefaultPrettyPrinter().writeValueAsString(input); ImmutableId output = m.readValue(json, ImmutableId.class); @@ -105,10 +108,9 @@ public void testSetterlessProperty() throws Exception public void testSetterlessPropertyWithEmptyConstructor() throws Exception { ImmutableIdWithEmptyConstuctor input = new ImmutableIdWithEmptyConstuctor(13); - ObjectMapper m = new ObjectMapper(); - String json = m.writerWithDefaultPrettyPrinter().writeValueAsString(input); + String json = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(input); - ImmutableIdWithEmptyConstuctor output = m.readValue(json, ImmutableIdWithEmptyConstuctor.class); + ImmutableIdWithEmptyConstuctor output = MAPPER.readValue(json, ImmutableIdWithEmptyConstuctor.class); assertNotNull(output); assertEquals(input.id, output.id); @@ -118,8 +120,9 @@ public void testSetterlessPropertyWithEmptyConstructor() throws Exception public void testSetterlessPropertyWithJsonCreator() throws Exception { ImmutableIdWithJsonCreatorAnnotation input = new ImmutableIdWithJsonCreatorAnnotation(13); - ObjectMapper m = new ObjectMapper(); - m.setAnnotationIntrospector(new MyParamIntrospector()); + ObjectMapper m = jsonMapperBuilder() + .annotationIntrospector(new MyParamIntrospector()) + .build(); String json = m.writerWithDefaultPrettyPrinter().writeValueAsString(input); ImmutableIdWithJsonCreatorAnnotation output = @@ -134,11 +137,10 @@ public void testSetterlessPropertyWithJsonCreator() throws Exception public void testSetterlessPropertyWithJsonPropertyField() throws Exception { ImmutableIdWithJsonPropertyConstructorAnnotation input = new ImmutableIdWithJsonPropertyConstructorAnnotation(13); - ObjectMapper m = new ObjectMapper(); - String json = m.writerWithDefaultPrettyPrinter().writeValueAsString(input); + String json = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(input); ImmutableIdWithJsonPropertyConstructorAnnotation output = - m.readValue(json, ImmutableIdWithJsonPropertyConstructorAnnotation.class); + MAPPER.readValue(json, ImmutableIdWithJsonPropertyConstructorAnnotation.class); assertNotNull(output); assertEquals(input.id, output.id); @@ -148,8 +150,9 @@ public void testSetterlessPropertyWithJsonPropertyField() throws Exception public void testSetterlessPropertyWithJsonPropertyConstructor() throws Exception { ImmutableIdWithJsonPropertyFieldAnnotation input = new ImmutableIdWithJsonPropertyFieldAnnotation(13); - ObjectMapper m = new ObjectMapper(); - m.setAnnotationIntrospector(new MyParamIntrospector()); + ObjectMapper m = jsonMapperBuilder() + .annotationIntrospector(new MyParamIntrospector()) + .build(); String json = m.writerWithDefaultPrettyPrinter().writeValueAsString(input); ImmutableIdWithJsonPropertyFieldAnnotation output =