Skip to content

Commit

Permalink
Add a failing test for #2077
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 21, 2019
1 parent 7fb56ae commit 8cec7af
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.fasterxml.jackson.failing;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;

public class TestPOJOAsArrayPolymorphic2077 extends BaseMapTest
{
// [databind#2077]
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.WRAPPER_ARRAY) // Both WRAPPER_OBJECT and WRAPPER_ARRAY cause the same problem
@JsonSubTypes({
@JsonSubTypes.Type(value = DirectLayout.class, name = "Direct"),
})
public interface Layout {
}

@JsonFormat(shape=JsonFormat.Shape.ARRAY)
public static class DirectLayout implements Layout {
}

private final ObjectMapper MAPPER = sharedMapper();

// [databind#2077]
public void testPolymorphicAsArray() throws Exception
{
// 20-Sep-2019, taut: this fails to add shape information, due to class annotations
// not being checked due to missing `property` for `createContextual()`

String json = MAPPER.writeValueAsString(new DirectLayout());

Layout instance = MAPPER.readValue(json, Layout.class);
assertNotNull(instance);
}
}

0 comments on commit 8cec7af

Please sign in to comment.