|
1 | 1 | package com.fasterxml.jackson.databind.deser;
|
2 | 2 |
|
3 |
| -import java.io.*; |
4 |
| - |
5 |
| -import com.fasterxml.jackson.annotation.*; |
| 3 | +import com.fasterxml.jackson.annotation.JsonAutoDetect; |
6 | 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
|
7 |
| -import com.fasterxml.jackson.core.*; |
8 |
| -import com.fasterxml.jackson.databind.*; |
| 5 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 6 | +import com.fasterxml.jackson.annotation.JsonUnwrapped; |
| 7 | +import com.fasterxml.jackson.core.JsonParser; |
| 8 | +import com.fasterxml.jackson.core.JsonProcessingException; |
| 9 | +import com.fasterxml.jackson.databind.BaseMapTest; |
| 10 | +import com.fasterxml.jackson.databind.DeserializationContext; |
| 11 | +import com.fasterxml.jackson.databind.MapperFeature; |
| 12 | +import com.fasterxml.jackson.databind.ObjectMapper; |
9 | 13 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
10 | 14 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
11 | 15 |
|
| 16 | +import java.io.IOException; |
| 17 | + |
12 | 18 | /**
|
13 | 19 | * This unit test suite tests use of basic Annotations for
|
14 | 20 | * bean deserialization; ones that indicate (non-constructor)
|
@@ -61,6 +67,32 @@ final static class SizeClassSetter3
|
61 | 67 | @JsonDeserialize public void x(int value) { _x = value; }
|
62 | 68 | }
|
63 | 69 |
|
| 70 | + static class Issue2088Bean { |
| 71 | + int x; |
| 72 | + int y; |
| 73 | + |
| 74 | + @JsonUnwrapped |
| 75 | + Issue2088UnwrappedBean w; |
| 76 | + |
| 77 | + public Issue2088Bean(@JsonProperty("x") int x, @JsonProperty("y") int y) { |
| 78 | + this.x = x; |
| 79 | + this.y = y; |
| 80 | + } |
| 81 | + |
| 82 | + public void setW(Issue2088UnwrappedBean w) { |
| 83 | + this.w = w; |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + static class Issue2088UnwrappedBean { |
| 88 | + int a; |
| 89 | + int b; |
| 90 | + |
| 91 | + public Issue2088UnwrappedBean(@JsonProperty("a") int a, @JsonProperty("b") int b) { |
| 92 | + this.a = a; |
| 93 | + this.b = b; |
| 94 | + } |
| 95 | + } |
64 | 96 |
|
65 | 97 | /// Classes for testing Setter discovery with inheritance
|
66 | 98 | static class BaseBean
|
@@ -181,6 +213,16 @@ public void testIssue442PrivateUnwrapped() throws Exception
|
181 | 213 | assertEquals(5, bean.w.i);
|
182 | 214 | }
|
183 | 215 |
|
| 216 | + // [databind#2088] |
| 217 | + public void testIssue2088UnwrappedFieldsAfterLastCreatorProp() throws Exception |
| 218 | + { |
| 219 | + Issue2088Bean bean = MAPPER.readValue("{\"x\":1,\"a\":2,\"y\":3,\"b\":4}", Issue2088Bean.class); |
| 220 | + assertEquals(1, bean.x); |
| 221 | + assertEquals(2, bean.w.a); |
| 222 | + assertEquals(3, bean.y); |
| 223 | + assertEquals(4, bean.w.b); |
| 224 | + } |
| 225 | + |
184 | 226 | /*
|
185 | 227 | /**********************************************************
|
186 | 228 | /* Test methods, annotations disabled
|
|
0 commit comments