Skip to content

Commit d0033cd

Browse files
committed
Add failing test for #2644
1 parent 4e827a7 commit d0033cd

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import java.math.BigDecimal;
4+
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.annotation.JsonSubTypes;
7+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
8+
import com.fasterxml.jackson.databind.*;
9+
10+
public class JDKNumberDeser2644Test extends BaseMapTest
11+
{
12+
// [databind#2644]
13+
static class NodeRoot2644 {
14+
public String type;
15+
16+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "type")
17+
@JsonSubTypes(value = {
18+
@JsonSubTypes.Type(value = NodeParent2644.class, name = "NodeParent")
19+
})
20+
public Node2644 node;
21+
}
22+
23+
public static class NodeParent2644 extends Node2644 { }
24+
25+
public static abstract class Node2644 {
26+
@JsonProperty("amount")
27+
BigDecimal val;
28+
29+
public BigDecimal getVal() {
30+
return val;
31+
}
32+
33+
public void setVal(BigDecimal val) {
34+
this.val = val;
35+
}
36+
}
37+
38+
// [databind#2644]
39+
public void testBigDecimalSubtypes() throws Exception
40+
{
41+
ObjectMapper mapper = newJsonMapper();
42+
mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
43+
mapper.registerSubtypes(NodeParent2644.class);
44+
45+
NodeRoot2644 root = mapper.readValue(
46+
"{\"type\": \"NodeParent\",\"node\": {\"amount\": 9999999999999999.99} }",
47+
NodeRoot2644.class
48+
);
49+
50+
assertEquals(new BigDecimal("9999999999999999.99"), root.node.getVal());
51+
52+
}
53+
54+
}

0 commit comments

Comments
 (0)