|
4 | 4 |
|
5 | 5 | import org.junit.jupiter.api.Test;
|
6 | 6 |
|
| 7 | +import com.fasterxml.jackson.annotation.JsonCreator; |
7 | 8 | import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
8 | 9 | import com.fasterxml.jackson.core.StreamReadConstraints;
|
9 | 10 | import com.fasterxml.jackson.databind.JsonMappingException;
|
@@ -42,6 +43,24 @@ static class NestedFloatHolder2784 {
|
42 | 43 | public FloatHolder2784 holder;
|
43 | 44 | }
|
44 | 45 |
|
| 46 | + static class DeserializationIssue4917 { |
| 47 | + public DecimalHolder4917 decimalHolder; |
| 48 | + public double number; |
| 49 | + } |
| 50 | + |
| 51 | + static class DecimalHolder4917 { |
| 52 | + public BigDecimal value; |
| 53 | + |
| 54 | + private DecimalHolder4917(BigDecimal value) { |
| 55 | + this.value = value; |
| 56 | + } |
| 57 | + |
| 58 | + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) |
| 59 | + static DecimalHolder4917 of(BigDecimal value) { |
| 60 | + return new DecimalHolder4917(value); |
| 61 | + } |
| 62 | + } |
| 63 | + |
45 | 64 | /*
|
46 | 65 | /**********************************************************************
|
47 | 66 | /* Test methods
|
@@ -143,4 +162,18 @@ public void testFloatEdgeCase() throws Exception
|
143 | 162 | .readValue(DOC);
|
144 | 163 | assertEquals(Float.parseFloat("1.199999988079071"), result.holder.value);
|
145 | 164 | }
|
| 165 | + |
| 166 | + // [databind#4917] |
| 167 | + @Test |
| 168 | + public void bigDecimal4917() throws Exception |
| 169 | + { |
| 170 | + CsvSchema schema = MAPPER.schemaFor(DeserializationIssue4917.class).withHeader() |
| 171 | + .withStrictHeaders(true); |
| 172 | + DeserializationIssue4917 issue = MAPPER |
| 173 | + .readerFor(DeserializationIssue4917.class) |
| 174 | + .with(schema) |
| 175 | + .readValue("decimalHolder,number\n100.00,50\n"); |
| 176 | + assertEquals(new BigDecimal("100.00"), issue.decimalHolder.value); |
| 177 | + assertEquals(50.0, issue.number); |
| 178 | + } |
146 | 179 | }
|
0 commit comments