-
-
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
01628a7
commit af21e31
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/test/java/com/fasterxml/jackson/failing/EnumPolymorphic2605Test.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,45 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
|
||
public class EnumPolymorphic2605Test extends BaseMapTest | ||
{ | ||
// for [databind#2605] | ||
static class EnumContaintingClass <ENUM_TYPE extends Enum<ENUM_TYPE>> { | ||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.CLASS, | ||
include = JsonTypeInfo.As.PROPERTY, | ||
property = "@class" | ||
) | ||
private ENUM_TYPE selected; | ||
|
||
protected EnumContaintingClass() { } | ||
|
||
public EnumContaintingClass(ENUM_TYPE selected) { | ||
this.selected = selected; | ||
} | ||
|
||
public ENUM_TYPE getSelected() { | ||
return selected; | ||
} | ||
|
||
public void setSelected(ENUM_TYPE selected) { | ||
this.selected = selected; | ||
} | ||
} | ||
|
||
static enum TestEnum { FIRST, SECOND, THIRD; } | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
// for [databind#2605] | ||
public void testRoundtrip() throws Exception | ||
{ | ||
EnumContaintingClass<TestEnum> gui = new EnumContaintingClass<TestEnum>(TestEnum.SECOND); | ||
String str = MAPPER.writeValueAsString(gui); | ||
Object o = MAPPER.readerFor(EnumContaintingClass.class).readValue(str); | ||
assertNotNull(o); | ||
} | ||
} |