-
-
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.
Add test for #1328 (not failing, alas)
- Loading branch information
1 parent
9004269
commit 520cdba
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/test/java/com/fasterxml/jackson/failing/EnumAsExternalPropertyId1328Test.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,54 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
|
||
// Test for [databind#1328]; does not actually reproduce the issue at this point. | ||
public class EnumAsExternalPropertyId1328Test extends BaseMapTest | ||
{ | ||
static class Bean1328 { | ||
public Type1328 type; | ||
|
||
@JsonTypeInfo(property = "type", include = JsonTypeInfo.As.EXTERNAL_PROPERTY, use = JsonTypeInfo.Id.NAME, | ||
visible=true) | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = A.class,name = "A"), | ||
@JsonSubTypes.Type(value = B.class,name = "B") | ||
}) | ||
public Interface1328 obj; | ||
} | ||
|
||
static interface Interface1328 { } | ||
|
||
enum Type1328 { | ||
A, B; | ||
} | ||
|
||
static class A implements Interface1328 { | ||
public int a; | ||
} | ||
|
||
static class B implements Interface1328 { | ||
public int b; | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Test methods | ||
/********************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = new ObjectMapper(); | ||
|
||
public void testExternalTypeIdAsEnum() throws Exception | ||
{ | ||
final String JSON = aposToQuotes("{ 'type':'A', 'obj': { 'a' : 4 } }'"); | ||
Bean1328 result = MAPPER.readValue(JSON, Bean1328.class); | ||
assertNotNull(result.obj); | ||
assertSame(A.class, result.obj.getClass()); | ||
assertEquals(4, ((A) result.obj).a); | ||
|
||
assertSame(Type1328.A, result.type); | ||
} | ||
} |