|
4 | 4 | import static org.testng.Assert.fail;
|
5 | 5 | import static org.testng.Assert.assertEquals;
|
6 | 6 |
|
| 7 | +import com.fasterxml.jackson.annotation.JsonCreator; |
| 8 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
7 | 9 | import com.fasterxml.jackson.annotation.JsonProperty;
|
8 | 10 | import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
9 | 11 | import com.fasterxml.jackson.databind.ObjectMapper;
|
@@ -107,6 +109,14 @@ public void testIntArray() throws Exception {
|
107 | 109 | assertEquals(prop.getType(), "array");
|
108 | 110 | }
|
109 | 111 |
|
| 112 | + @Test |
| 113 | + public void testComplex() throws Exception { |
| 114 | + final Model model = context.resolve(ComplexBean.class); |
| 115 | + assertNotNull(model); |
| 116 | + final Map<String, Property> props = model.getProperties(); |
| 117 | + assertEquals(props.size(), 6); |
| 118 | + } |
| 119 | + |
110 | 120 | /*
|
111 | 121 | /**********************************************************
|
112 | 122 | /* Test methods
|
@@ -170,4 +180,48 @@ static class StringDateMapBean {
|
170 | 180 | static class IntArrayBean {
|
171 | 181 | public int[] b;
|
172 | 182 | }
|
| 183 | + |
| 184 | + |
| 185 | + static class ComplexBean { |
| 186 | + public String j; |
| 187 | + @JsonIgnore |
| 188 | + public SimpleBean simpleBean; |
| 189 | + |
| 190 | + @JsonCreator |
| 191 | + public ComplexBean(@JsonProperty("b") int b, |
| 192 | + @JsonProperty("c") long c, @JsonProperty("d") float d, @JsonProperty("e") double e, |
| 193 | + @JsonProperty("j") String j) { |
| 194 | + simpleBean = new SimpleBean(); |
| 195 | + simpleBean.b = b; |
| 196 | + simpleBean.c = c; |
| 197 | + simpleBean.d = d; |
| 198 | + simpleBean.e = e; |
| 199 | + this.j = j; |
| 200 | + } |
| 201 | + |
| 202 | + public SimpleBean getSimpleBean() { |
| 203 | + return simpleBean; |
| 204 | + } |
| 205 | + |
| 206 | + public String getA() { |
| 207 | + return simpleBean.getA(); |
| 208 | + } |
| 209 | + public int getB() { |
| 210 | + return simpleBean.b; |
| 211 | + } |
| 212 | + public long getC() { |
| 213 | + return simpleBean.c; |
| 214 | + } |
| 215 | + public float getD() { |
| 216 | + return simpleBean.d; |
| 217 | + } |
| 218 | + public double getE() { |
| 219 | + return simpleBean.e; |
| 220 | + } |
| 221 | + public String getJ() { |
| 222 | + return j; |
| 223 | + } |
| 224 | + } |
| 225 | + |
| 226 | + |
173 | 227 | }
|
0 commit comments