File tree 1 file changed +40
-0
lines changed
src/test/java/com/fasterxml/jackson/failing
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .failing ;
2
+
3
+ import java .util .Map ;
4
+
5
+ import com .fasterxml .jackson .annotation .JsonCreator ;
6
+ import com .fasterxml .jackson .core .type .TypeReference ;
7
+ import com .fasterxml .jackson .databind .BaseMapTest ;
8
+ import com .fasterxml .jackson .databind .ObjectMapper ;
9
+
10
+ public class KeyDeserializer3143Test extends BaseMapTest
11
+ {
12
+ // [databind#3143]
13
+ static class Key3143 {
14
+ protected String value ;
15
+
16
+ private Key3143 (String v , boolean bogus ) {
17
+ value = v ;
18
+ }
19
+
20
+ @ JsonCreator
21
+ public static Key3143 create (String v ) {
22
+ return new Key3143 (v , true );
23
+ }
24
+
25
+ public static Key3143 valueOf (String id ) {
26
+ return new Key3143 (id .toUpperCase (), false );
27
+ }
28
+ }
29
+
30
+ private final ObjectMapper MAPPER = newJsonMapper ();
31
+
32
+ // [databind#3143]
33
+ public void testKeyWithCreatorAndMultipleFactoryMethods () throws Exception
34
+ {
35
+ Map <Key3143 ,Integer > map = MAPPER .readValue ("{\" foo\" :3}" ,
36
+ new TypeReference <Map <Key3143 ,Integer >>() {} );
37
+ assertEquals (1 , map .size ());
38
+ assertEquals ("foo" , map .keySet ().iterator ().next ().value );
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments