Skip to content

Commit

Permalink
2 more test improvements pre #4552
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 1, 2024
1 parent f9dd3cc commit c3d22c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public POJO2527PublicField(boolean b) {
}

static class POJO2527Creator {
final boolean isEnabled;
boolean isEnabled;

public POJO2527Creator(@JsonProperty("enabled") boolean b) {
isEnabled = b;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,28 @@ public static class Bar extends BaseEntity
use = JsonTypeInfo.Id.NAME,
property = "type",
defaultImpl = JsonMapSchema.class)
@JsonSubTypes({
@JsonSubTypes.Type(value = JsonMapSchema.class, name = "map"),
@JsonSubTypes.Type(value = JsonJdbcSchema.class, name = "jdbc") })
public static abstract class JsonSchema {
public String name;
@JsonSubTypes({
@JsonSubTypes.Type(value = JsonMapSchema.class, name = "map"),
@JsonSubTypes.Type(value = JsonJdbcSchema.class, name = "jdbc") })
public static abstract class JsonSchema {
public String name;
}

static class JsonMapSchema extends JsonSchema { }

static class JsonJdbcSchema extends JsonSchema { }

static class JsonRoot1083 {
public List<JsonSchema> schemas = new ArrayList<JsonSchema>();
}

/*
/**********************************************************
/* Test methods
/**********************************************************
*/

private final ObjectMapper MAPPER = new ObjectMapper();
private final ObjectMapper MAPPER = newJsonMapper();

@Test
public void testColumnMetadata() throws Exception
Expand Down Expand Up @@ -177,17 +181,15 @@ public void testMixedRefsIssue188() throws Exception
@Test
public void testObjectAndTypeId() throws Exception
{
final ObjectMapper mapper = new ObjectMapper();

Bar inputRoot = new Bar();
Foo inputChild = new Foo();
inputRoot.next = inputChild;
inputChild.ref = inputRoot;

String json = mapper.writerWithDefaultPrettyPrinter()
String json = MAPPER.writerWithDefaultPrettyPrinter()
.writeValueAsString(inputRoot);

BaseEntity resultRoot = mapper.readValue(json, BaseEntity.class);
BaseEntity resultRoot = MAPPER.readValue(json, BaseEntity.class);
assertNotNull(resultRoot);
assertTrue(resultRoot instanceof Bar);
Bar first = (Bar) resultRoot;
Expand All @@ -199,15 +201,11 @@ public void testObjectAndTypeId() throws Exception
assertSame(first, second.ref);
}

public static class JsonRoot {
public final List<JsonSchema> schemas = new ArrayList<JsonSchema>();
}

@Test
public void testWithFieldsInBaseClass1083() throws Exception {
final String json = a2q("{'schemas': [{\n"
+ " 'name': 'FoodMart'\n"
+ "}]}\n");
MAPPER.readValue(json, JsonRoot.class);
MAPPER.readValue(json, JsonRoot1083.class);
}
}

0 comments on commit c3d22c4

Please sign in to comment.