Skip to content

Commit 4430918

Browse files
committed
Add a failing test for #3143
1 parent 8ce56fc commit 4430918

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
}

0 commit comments

Comments
 (0)