-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fb56ae
commit 8cec7af
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/test/java/com/fasterxml/jackson/failing/TestPOJOAsArrayPolymorphic2077.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |