File tree 2 files changed +37
-0
lines changed
src/test/java/com/fasterxml/jackson/failing 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
import com .fasterxml .jackson .databind .*;
7
7
8
+ // Fixed in 2.11.0, but not 2.10.x
8
9
public class EnumAliasDeser2352Test extends BaseMapTest
9
10
{
10
11
// for [databind#2352]: Support aliases on enum values
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .failing ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonValue ;
4
+
5
+ import com .fasterxml .jackson .databind .*;
6
+
7
+ public class EnumDeserializationFromInt1850Test extends BaseMapTest
8
+ {
9
+ enum Example1 {
10
+ A (101 );
11
+ final int x ;
12
+ Example1 (int x ) { this .x = x ; }
13
+ @ JsonValue
14
+ public int code () { return x ; }
15
+ }
16
+
17
+ enum Example2 {
18
+ A (202 );
19
+ @ JsonValue
20
+ public final int x ;
21
+ Example2 (int x ) { this .x = x ; }
22
+ }
23
+
24
+ public void testEnumFromInt1850 () throws Exception
25
+ {
26
+ final ObjectMapper mapper = newJsonMapper ();
27
+
28
+ String json = mapper .writeValueAsString (Example1 .A );
29
+ Example1 e1 = mapper .readValue (json , Example1 .class );
30
+ assertEquals (Example1 .A , e1 );
31
+
32
+ json = mapper .writeValueAsString (Example2 .A );
33
+ Example2 e2 = mapper .readValue (json , Example2 .class );
34
+ assertEquals (Example2 .A , e2 );
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments