File tree 2 files changed +52
-1
lines changed
src/test/java/com/fasterxml/jackson
2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,8 @@ enum MixinOverloadedDefault {
90
90
/* Test methods
91
91
/**********************************************************
92
92
*/
93
- private final ObjectMapper MAPPER = new ObjectMapper ();
93
+
94
+ private final ObjectMapper MAPPER = newJsonMapper ();
94
95
95
96
@ Test
96
97
public void testWithoutCustomFeatures () throws Exception
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .failing ;
2
+
3
+ import org .junit .jupiter .api .Test ;
4
+
5
+ import com .fasterxml .jackson .annotation .JsonEnumDefaultValue ;
6
+ import com .fasterxml .jackson .annotation .JsonProperty ;
7
+
8
+ import com .fasterxml .jackson .databind .DeserializationFeature ;
9
+ import com .fasterxml .jackson .databind .ObjectMapper ;
10
+ import com .fasterxml .jackson .databind .ObjectReader ;
11
+
12
+ import static com .fasterxml .jackson .databind .testutil .DatabindTestUtil .newJsonMapper ;
13
+ import static com .fasterxml .jackson .databind .testutil .DatabindTestUtil .q ;
14
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
15
+
16
+ public class EnumDefaultRead4403Test
17
+ {
18
+ // [databind#4403]
19
+ enum Brand4403 {
20
+ @ JsonProperty ("005" )
21
+ SEAT ,
22
+ @ JsonProperty ("006" )
23
+ HYUNDAI ,
24
+ @ JsonEnumDefaultValue
25
+ OTHER
26
+ }
27
+
28
+ /*
29
+ /**********************************************************
30
+ /* Test methods
31
+ /**********************************************************
32
+ */
33
+
34
+ private final ObjectMapper MAPPER = newJsonMapper ();
35
+
36
+ // [databind#4403]
37
+ @ Test
38
+ public void readFromDefault4403 () throws Exception
39
+ {
40
+ ObjectReader r = MAPPER .readerFor (Brand4403 .class )
41
+ .with (DeserializationFeature .READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE );
42
+ assertEquals (Brand4403 .SEAT , r .readValue (q ("005" )));
43
+ assertEquals (Brand4403 .HYUNDAI , r .readValue (q ("006" )));
44
+ assertEquals (Brand4403 .OTHER , r .readValue (q ("x" )));
45
+
46
+ // Problem here: "001" taken as "Stringified" index 1
47
+ assertEquals (Brand4403 .OTHER , r .readValue (q ("001" )));
48
+ }
49
+
50
+ }
You can’t perform that action at this time.
0 commit comments