File tree 1 file changed +45
-0
lines changed
src/test/java/com/fasterxml/jackson/failing
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .failing ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonTypeInfo ;
4
+
5
+ import com .fasterxml .jackson .databind .*;
6
+
7
+ public class EnumPolymorphic2605Test extends BaseMapTest
8
+ {
9
+ // for [databind#2605]
10
+ static class EnumContaintingClass <ENUM_TYPE extends Enum <ENUM_TYPE >> {
11
+ @ JsonTypeInfo (
12
+ use = JsonTypeInfo .Id .CLASS ,
13
+ include = JsonTypeInfo .As .PROPERTY ,
14
+ property = "@class"
15
+ )
16
+ private ENUM_TYPE selected ;
17
+
18
+ protected EnumContaintingClass () { }
19
+
20
+ public EnumContaintingClass (ENUM_TYPE selected ) {
21
+ this .selected = selected ;
22
+ }
23
+
24
+ public ENUM_TYPE getSelected () {
25
+ return selected ;
26
+ }
27
+
28
+ public void setSelected (ENUM_TYPE selected ) {
29
+ this .selected = selected ;
30
+ }
31
+ }
32
+
33
+ static enum TestEnum { FIRST , SECOND , THIRD ; }
34
+
35
+ private final ObjectMapper MAPPER = newJsonMapper ();
36
+
37
+ // for [databind#2605]
38
+ public void testRoundtrip () throws Exception
39
+ {
40
+ EnumContaintingClass <TestEnum > gui = new EnumContaintingClass <TestEnum >(TestEnum .SECOND );
41
+ String str = MAPPER .writeValueAsString (gui );
42
+ Object o = MAPPER .readerFor (EnumContaintingClass .class ).readValue (str );
43
+ assertNotNull (o );
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments