Skip to content

Commit d98de9c

Browse files
committed
added composed model deserialization test
1 parent e682287 commit d98de9c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package io.swagger.models;
2+
3+
import io.swagger.util.Json;
4+
import org.testng.annotations.Test;
5+
6+
import static org.testng.Assert.assertNull;
7+
import static org.testng.Assert.assertTrue;
8+
9+
public class ComposedModelTest {
10+
@Test
11+
public void testDeserializeComposedModel() throws Exception {
12+
String json = "{\n" +
13+
" \"type\": \"object\",\n" +
14+
" \"allOf\": [\n" +
15+
" {\n" +
16+
" \"$ref\": \"#/definitions/Pet\"\n" +
17+
" },\n" +
18+
" {\n" +
19+
" \"$ref\": \"#/definitions/Furry\"\n" +
20+
" },\n" +
21+
" {\n" +
22+
" \"type\": \"object\",\n" +
23+
" \"properties\": {\n" +
24+
" \"propInt\": {\n" +
25+
" \"type\": \"string\"\n" +
26+
" }\n" +
27+
" }\n" +
28+
" },\n" +
29+
" {\n" +
30+
" \"type\": \"object\",\n" +
31+
" \"properties\": {\n" +
32+
" \"propEx\": {\n" +
33+
" \"type\": \"string\"\n" +
34+
" }\n" +
35+
" }\n" +
36+
" }\n" +
37+
" ]\n" +
38+
"}";
39+
40+
Model model = Json.mapper().readValue(json, Model.class);
41+
assertTrue(model instanceof ComposedModel);
42+
ComposedModel cm = (ComposedModel) model;
43+
44+
assertTrue(cm.getAllOf().size() == 4);
45+
assertTrue(cm.getAllOf().get(2).getProperties().containsKey("propInt"));
46+
assertTrue(cm.getAllOf().get(3).getProperties().containsKey("propEx"));
47+
48+
assertNull(cm.getProperties());
49+
}
50+
}

0 commit comments

Comments
 (0)