Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 10, 2024
1 parent 13f59e0 commit 883c020
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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 =
Expand All @@ -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);
Expand All @@ -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 =
Expand Down

0 comments on commit 883c020

Please sign in to comment.