use of io.atlasmap.json.v2.JsonComplexType in project atlasmap by atlasmap.
the class JsonDocumentInspectionServiceTest method inspectJsonDocumentHighlyComplexNestedObject.
@Test
public void inspectJsonDocumentHighlyComplexNestedObject() throws Exception {
final String instance = new String(Files.readAllBytes(Paths.get("src/test/resources/inspect/highly-complex-nested-object.json")));
JsonDocument document = inspectionService.inspectJsonDocument(instance);
Assert.assertNotNull(document);
Assert.assertThat(document.getFields().getField().size(), Is.is(1));
JsonComplexType items = (JsonComplexType) document.getFields().getField().get(0);
Assert.assertNotNull(items);
Assert.assertThat(items.getFieldType(), Is.is(FieldType.COMPLEX));
Assert.assertThat(items.getStatus(), Is.is(FieldStatus.SUPPORTED));
Assert.assertThat(items.getName(), Is.is("items"));
Assert.assertThat(items.getJsonFields().getJsonField().size(), Is.is(1));
JsonComplexType item = (JsonComplexType) items.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(item);
Assert.assertThat(item.getFieldType(), Is.is(FieldType.COMPLEX));
Assert.assertThat(item.getJsonFields().getJsonField().size(), Is.is(38));
JsonField itemId = item.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(itemId);
Assert.assertThat(itemId.getName(), Is.is("id"));
Assert.assertThat(itemId.getValue(), Is.is("0001"));
Assert.assertThat(itemId.getPath(), Is.is("/items/item/id"));
Assert.assertThat(itemId.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(itemId.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField itemValue = item.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(itemValue);
Assert.assertThat(itemValue.getName(), Is.is("type"));
Assert.assertThat(itemValue.getValue(), Is.is("donut"));
Assert.assertThat(itemValue.getPath(), Is.is("/items/item/type"));
Assert.assertThat(itemValue.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(itemValue.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField itemName = item.getJsonFields().getJsonField().get(2);
Assert.assertNotNull(itemName);
Assert.assertThat(itemName.getName(), Is.is("name"));
Assert.assertThat(itemName.getValue(), Is.is("Cake"));
Assert.assertThat(itemName.getPath(), Is.is("/items/item/name"));
Assert.assertThat(itemName.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(itemName.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField itemPPU = item.getJsonFields().getJsonField().get(3);
Assert.assertNotNull(itemPPU);
Assert.assertThat(itemPPU.getName(), Is.is("ppu"));
Assert.assertThat(itemPPU.getPath(), Is.is("/items/item/ppu"));
Assert.assertThat(itemPPU.getValue(), Is.is(0.55));
Assert.assertThat(itemPPU.getFieldType(), Is.is(FieldType.DOUBLE));
Assert.assertThat(itemPPU.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonComplexType itemBattersComplexType = (JsonComplexType) item.getJsonFields().getJsonField().get(4);
Assert.assertNotNull(itemBattersComplexType);
Assert.assertThat(itemBattersComplexType.getFieldType(), Is.is(FieldType.COMPLEX));
Assert.assertThat(itemBattersComplexType.getName(), Is.is("batters"));
Assert.assertThat(itemBattersComplexType.getJsonFields().getJsonField().size(), Is.is(1));
JsonComplexType itemBatterComplexType = (JsonComplexType) itemBattersComplexType.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(itemBatterComplexType);
Assert.assertThat(itemBatterComplexType.getFieldType(), Is.is(FieldType.COMPLEX));
Assert.assertThat(itemBatterComplexType.getName(), Is.is("batter"));
Assert.assertThat(itemBatterComplexType.getJsonFields().getJsonField().size(), Is.is(8));
JsonField batterId = itemBatterComplexType.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(batterId);
Assert.assertThat(batterId.getName(), Is.is("id"));
Assert.assertThat(batterId.getValue(), Is.is("1001"));
Assert.assertThat(batterId.getPath(), Is.is("/items/item/batters/batter/id"));
Assert.assertThat(batterId.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(batterId.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField batterType = itemBatterComplexType.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(batterType);
Assert.assertThat(batterType.getName(), Is.is("type"));
Assert.assertThat(batterType.getValue(), Is.is("Regular"));
Assert.assertThat(batterType.getPath(), Is.is("/items/item/batters/batter/type"));
Assert.assertThat(batterType.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(batterType.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField batterId1 = itemBatterComplexType.getJsonFields().getJsonField().get(2);
Assert.assertNotNull(batterId1);
Assert.assertThat(batterId1.getName(), Is.is("id"));
Assert.assertThat(batterId1.getValue(), Is.is("1002"));
Assert.assertThat(batterId1.getPath(), Is.is("/items/item/batters/batter[1]/id"));
Assert.assertThat(batterId1.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(batterId1.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField batterType1 = itemBatterComplexType.getJsonFields().getJsonField().get(3);
Assert.assertNotNull(batterType1);
Assert.assertThat(batterType1.getName(), Is.is("type"));
Assert.assertThat(batterType1.getValue(), Is.is("Chocolate"));
Assert.assertThat(batterType1.getPath(), Is.is("/items/item/batters/batter[1]/type"));
Assert.assertThat(batterType1.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(batterType1.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField batterId2 = itemBatterComplexType.getJsonFields().getJsonField().get(4);
Assert.assertNotNull(batterId2);
Assert.assertThat(batterId2.getName(), Is.is("id"));
Assert.assertThat(batterId2.getValue(), Is.is("1003"));
Assert.assertThat(batterId2.getPath(), Is.is("/items/item/batters/batter[2]/id"));
Assert.assertThat(batterId2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(batterId2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField batterType2 = itemBatterComplexType.getJsonFields().getJsonField().get(5);
Assert.assertNotNull(batterType2);
Assert.assertThat(batterType2.getName(), Is.is("type"));
Assert.assertThat(batterType2.getValue(), Is.is("Blueberry"));
Assert.assertThat(batterType2.getPath(), Is.is("/items/item/batters/batter[2]/type"));
Assert.assertThat(batterType2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(batterType2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField batterId3 = itemBatterComplexType.getJsonFields().getJsonField().get(6);
Assert.assertNotNull(batterId3);
Assert.assertThat(batterId3.getName(), Is.is("id"));
Assert.assertThat(batterId3.getValue(), Is.is("1004"));
Assert.assertThat(batterId3.getPath(), Is.is("/items/item/batters/batter[3]/id"));
Assert.assertThat(batterId3.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(batterId3.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField batterType3 = itemBatterComplexType.getJsonFields().getJsonField().get(7);
Assert.assertNotNull(batterType3);
Assert.assertThat(batterType3.getName(), Is.is("type"));
Assert.assertThat(batterType3.getValue(), Is.is("Devil's Food"));
Assert.assertThat(batterType3.getPath(), Is.is("/items/item/batters/batter[3]/type"));
Assert.assertThat(batterType3.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(batterType3.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonComplexType itemToppingComplexType = (JsonComplexType) item.getJsonFields().getJsonField().get(5);
Assert.assertNotNull(itemToppingComplexType);
Assert.assertThat(itemToppingComplexType.getFieldType(), Is.is(FieldType.COMPLEX));
Assert.assertThat(itemToppingComplexType.getName(), Is.is("topping"));
Assert.assertThat(itemToppingComplexType.getJsonFields().getJsonField().size(), Is.is(14));
JsonField toppingID = itemToppingComplexType.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(toppingID);
Assert.assertThat(toppingID.getName(), Is.is("id"));
Assert.assertThat(toppingID.getValue(), Is.is("5001"));
Assert.assertThat(toppingID.getPath(), Is.is("/items/item/topping/id"));
Assert.assertThat(toppingID.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType = itemToppingComplexType.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(toppingType);
Assert.assertThat(toppingType.getName(), Is.is("type"));
Assert.assertThat(toppingType.getValue(), Is.is("None"));
Assert.assertThat(toppingType.getPath(), Is.is("/items/item/topping/type"));
Assert.assertThat(toppingType.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingID1 = itemToppingComplexType.getJsonFields().getJsonField().get(2);
Assert.assertNotNull(toppingID1);
Assert.assertThat(toppingID1.getName(), Is.is("id"));
Assert.assertThat(toppingID1.getValue(), Is.is("5002"));
Assert.assertThat(toppingID1.getPath(), Is.is("/items/item/topping/id[1]"));
Assert.assertThat(toppingID1.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID1.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType1 = itemToppingComplexType.getJsonFields().getJsonField().get(3);
Assert.assertNotNull(toppingType1);
Assert.assertThat(toppingType1.getName(), Is.is("type"));
Assert.assertThat(toppingType1.getValue(), Is.is("Glazed"));
Assert.assertThat(toppingType1.getPath(), Is.is("/items/item/topping/type[1]"));
Assert.assertThat(toppingType1.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType1.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingID2 = itemToppingComplexType.getJsonFields().getJsonField().get(4);
Assert.assertNotNull(toppingID2);
Assert.assertThat(toppingID2.getName(), Is.is("id"));
Assert.assertThat(toppingID2.getValue(), Is.is("5005"));
Assert.assertThat(toppingID2.getPath(), Is.is("/items/item/topping/id[2]"));
Assert.assertThat(toppingID2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType2 = itemToppingComplexType.getJsonFields().getJsonField().get(5);
Assert.assertNotNull(toppingType2);
Assert.assertThat(toppingType2.getName(), Is.is("type"));
Assert.assertThat(toppingType2.getValue(), Is.is("Sugar"));
Assert.assertThat(toppingType2.getPath(), Is.is("/items/item/topping/type[2]"));
Assert.assertThat(toppingType2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingID3 = itemToppingComplexType.getJsonFields().getJsonField().get(6);
Assert.assertNotNull(toppingID3);
Assert.assertThat(toppingID3.getName(), Is.is("id"));
Assert.assertThat(toppingID3.getValue(), Is.is("5007"));
Assert.assertThat(toppingID3.getPath(), Is.is("/items/item/topping/id[3]"));
Assert.assertThat(toppingID3.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID3.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType3 = itemToppingComplexType.getJsonFields().getJsonField().get(7);
Assert.assertNotNull(toppingType3);
Assert.assertThat(toppingType3.getName(), Is.is("type"));
Assert.assertThat(toppingType3.getValue(), Is.is("Powdered Sugar"));
Assert.assertThat(toppingType3.getPath(), Is.is("/items/item/topping/type[3]"));
Assert.assertThat(toppingType3.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType3.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingID4 = itemToppingComplexType.getJsonFields().getJsonField().get(8);
Assert.assertNotNull(toppingID4);
Assert.assertThat(toppingID4.getName(), Is.is("id"));
Assert.assertThat(toppingID4.getValue(), Is.is("5006"));
Assert.assertThat(toppingID4.getPath(), Is.is("/items/item/topping/id[4]"));
Assert.assertThat(toppingID4.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID4.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType4 = itemToppingComplexType.getJsonFields().getJsonField().get(9);
Assert.assertNotNull(toppingType4);
Assert.assertThat(toppingType4.getName(), Is.is("type"));
Assert.assertThat(toppingType4.getValue(), Is.is("Chocolate with Sprinkles"));
Assert.assertThat(toppingType4.getPath(), Is.is("/items/item/topping/type[4]"));
Assert.assertThat(toppingType4.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType4.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingID5 = itemToppingComplexType.getJsonFields().getJsonField().get(10);
Assert.assertNotNull(toppingID5);
Assert.assertThat(toppingID5.getName(), Is.is("id"));
Assert.assertThat(toppingID5.getValue(), Is.is("5003"));
Assert.assertThat(toppingID5.getPath(), Is.is("/items/item/topping/id[5]"));
Assert.assertThat(toppingID5.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID5.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType5 = itemToppingComplexType.getJsonFields().getJsonField().get(11);
Assert.assertNotNull(toppingType5);
Assert.assertThat(toppingType5.getName(), Is.is("type"));
Assert.assertThat(toppingType5.getValue(), Is.is("Chocolate"));
Assert.assertThat(toppingType5.getPath(), Is.is("/items/item/topping/type[5]"));
Assert.assertThat(toppingType5.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType5.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingID6 = itemToppingComplexType.getJsonFields().getJsonField().get(12);
Assert.assertNotNull(toppingID6);
Assert.assertThat(toppingID6.getName(), Is.is("id"));
Assert.assertThat(toppingID6.getValue(), Is.is("5004"));
Assert.assertThat(toppingID6.getPath(), Is.is("/items/item/topping/id[6]"));
Assert.assertThat(toppingID6.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID6.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType6 = itemToppingComplexType.getJsonFields().getJsonField().get(13);
Assert.assertNotNull(toppingType6);
Assert.assertThat(toppingType6.getName(), Is.is("type"));
Assert.assertThat(toppingType6.getValue(), Is.is("Maple"));
Assert.assertThat(toppingType6.getPath(), Is.is("/items/item/topping/type[6]"));
Assert.assertThat(toppingType6.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType6.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField item1 = item.getJsonFields().getJsonField().get(6);
Assert.assertNotNull(item1);
Assert.assertThat(item1.getName(), Is.is("id"));
Assert.assertThat(item1.getValue(), Is.is("0002"));
Assert.assertThat(item1.getPath(), Is.is("/items/item[1]/id"));
Assert.assertThat(item1.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(item1.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField itemValue1 = item.getJsonFields().getJsonField().get(7);
Assert.assertNotNull(itemValue1);
Assert.assertThat(itemValue1.getName(), Is.is("type"));
Assert.assertThat(itemValue1.getValue(), Is.is("donut"));
Assert.assertThat(itemValue1.getPath(), Is.is("/items/item[1]/type"));
Assert.assertThat(itemValue1.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(itemValue1.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField itemName1 = item.getJsonFields().getJsonField().get(8);
Assert.assertNotNull(itemName1);
Assert.assertThat(itemName1.getName(), Is.is("name"));
Assert.assertThat(itemName1.getValue(), Is.is("Raised"));
Assert.assertThat(itemName1.getPath(), Is.is("/items/item[1]/name"));
Assert.assertThat(itemName1.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(itemName1.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField itemPPU1 = item.getJsonFields().getJsonField().get(9);
Assert.assertNotNull(itemPPU1);
Assert.assertThat(itemPPU1.getName(), Is.is("ppu"));
Assert.assertThat(itemPPU1.getPath(), Is.is("/items/item[1]/ppu"));
Assert.assertThat(itemPPU1.getValue(), Is.is(0.55));
Assert.assertThat(itemPPU1.getFieldType(), Is.is(FieldType.DOUBLE));
Assert.assertThat(itemPPU1.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonComplexType itemBattersComplexType1 = (JsonComplexType) item.getJsonFields().getJsonField().get(10);
Assert.assertNotNull(itemBattersComplexType1);
Assert.assertThat(itemBattersComplexType1.getFieldType(), Is.is(FieldType.COMPLEX));
Assert.assertThat(itemBattersComplexType1.getName(), Is.is("batters"));
Assert.assertThat(itemBattersComplexType1.getJsonFields().getJsonField().size(), Is.is(1));
JsonComplexType itemBatterComplexType1 = (JsonComplexType) itemBattersComplexType1.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(itemBatterComplexType1);
Assert.assertThat(itemBatterComplexType1.getFieldType(), Is.is(FieldType.COMPLEX));
Assert.assertThat(itemBatterComplexType1.getName(), Is.is("batter"));
Assert.assertThat(itemBatterComplexType1.getJsonFields().getJsonField().size(), Is.is(2));
JsonField batterId10 = itemBatterComplexType1.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(batterId10);
Assert.assertThat(batterId10.getName(), Is.is("id"));
Assert.assertThat(batterId10.getValue(), Is.is("1001"));
Assert.assertThat(batterId10.getPath(), Is.is("/items/item[1]/batters/batter/id"));
Assert.assertThat(batterId10.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(batterId10.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField batterType10 = itemBatterComplexType1.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(batterType10);
Assert.assertThat(batterType10.getName(), Is.is("type"));
Assert.assertThat(batterType10.getValue(), Is.is("Regular"));
Assert.assertThat(batterType10.getPath(), Is.is("/items/item[1]/batters/batter/type"));
Assert.assertThat(batterType10.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(batterType10.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonComplexType itemToppingsComplexType1 = (JsonComplexType) item.getJsonFields().getJsonField().get(11);
Assert.assertNotNull(itemToppingsComplexType1);
Assert.assertThat(itemToppingsComplexType1.getFieldType(), Is.is(FieldType.COMPLEX));
Assert.assertThat(itemToppingsComplexType1.getName(), Is.is("topping"));
Assert.assertThat(itemToppingsComplexType1.getJsonFields().getJsonField().size(), Is.is(10));
JsonField toppingID11 = itemToppingsComplexType1.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(toppingID11);
Assert.assertThat(toppingID11.getName(), Is.is("id"));
Assert.assertThat(toppingID11.getValue(), Is.is("5001"));
Assert.assertThat(toppingID11.getPath(), Is.is("/items/item[1]/topping/id"));
Assert.assertThat(toppingID11.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID11.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType11 = itemToppingsComplexType1.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(toppingType11);
Assert.assertThat(toppingType11.getName(), Is.is("type"));
Assert.assertThat(toppingType11.getValue(), Is.is("None"));
Assert.assertThat(toppingType11.getPath(), Is.is("/items/item[1]/topping/type"));
Assert.assertThat(toppingType11.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType11.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingID12 = itemToppingsComplexType1.getJsonFields().getJsonField().get(2);
Assert.assertNotNull(toppingID12);
Assert.assertThat(toppingID12.getName(), Is.is("id"));
Assert.assertThat(toppingID12.getValue(), Is.is("5002"));
Assert.assertThat(toppingID12.getPath(), Is.is("/items/item[1]/topping/id[1]"));
Assert.assertThat(toppingID12.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID12.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType12 = itemToppingsComplexType1.getJsonFields().getJsonField().get(3);
Assert.assertNotNull(toppingType12);
Assert.assertThat(toppingType12.getName(), Is.is("type"));
Assert.assertThat(toppingType12.getValue(), Is.is("Glazed"));
Assert.assertThat(toppingType12.getPath(), Is.is("/items/item[1]/topping/type[1]"));
Assert.assertThat(toppingType12.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType12.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingID13 = itemToppingsComplexType1.getJsonFields().getJsonField().get(4);
Assert.assertNotNull(toppingID13);
Assert.assertThat(toppingID13.getName(), Is.is("id"));
Assert.assertThat(toppingID13.getValue(), Is.is("5005"));
Assert.assertThat(toppingID13.getPath(), Is.is("/items/item[1]/topping/id[2]"));
Assert.assertThat(toppingID13.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID13.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType13 = itemToppingsComplexType1.getJsonFields().getJsonField().get(5);
Assert.assertNotNull(toppingType13);
Assert.assertThat(toppingType13.getName(), Is.is("type"));
Assert.assertThat(toppingType13.getValue(), Is.is("Sugar"));
Assert.assertThat(toppingType13.getPath(), Is.is("/items/item[1]/topping/type[2]"));
Assert.assertThat(toppingType13.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType13.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingID14 = itemToppingsComplexType1.getJsonFields().getJsonField().get(6);
Assert.assertNotNull(toppingID14);
Assert.assertThat(toppingID14.getName(), Is.is("id"));
Assert.assertThat(toppingID14.getValue(), Is.is("5003"));
Assert.assertThat(toppingID14.getPath(), Is.is("/items/item[1]/topping/id[3]"));
Assert.assertThat(toppingID14.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID14.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType14 = itemToppingsComplexType1.getJsonFields().getJsonField().get(7);
Assert.assertNotNull(toppingType14);
Assert.assertThat(toppingType14.getName(), Is.is("type"));
Assert.assertThat(toppingType14.getValue(), Is.is("Chocolate"));
Assert.assertThat(toppingType14.getPath(), Is.is("/items/item[1]/topping/type[3]"));
Assert.assertThat(toppingType14.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType14.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingID15 = itemToppingsComplexType1.getJsonFields().getJsonField().get(8);
Assert.assertNotNull(toppingID15);
Assert.assertThat(toppingID15.getName(), Is.is("id"));
Assert.assertThat(toppingID15.getValue(), Is.is("5004"));
Assert.assertThat(toppingID15.getPath(), Is.is("/items/item[1]/topping/id[4]"));
Assert.assertThat(toppingID15.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingID15.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField toppingType15 = itemToppingsComplexType1.getJsonFields().getJsonField().get(9);
Assert.assertNotNull(toppingType15);
Assert.assertThat(toppingType15.getName(), Is.is("type"));
Assert.assertThat(toppingType15.getValue(), Is.is("Maple"));
Assert.assertThat(toppingType15.getPath(), Is.is("/items/item[1]/topping/type[4]"));
Assert.assertThat(toppingType15.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(toppingType15.getStatus(), Is.is(FieldStatus.SUPPORTED));
// etc....
// printDocument(document);
}
use of io.atlasmap.json.v2.JsonComplexType in project atlasmap by atlasmap.
the class JsonDocumentInspectionServiceTest method inspectRepeatingComplexObjectWithRoot.
@Test
public void inspectRepeatingComplexObjectWithRoot() throws Exception {
final String instance = new String(Files.readAllBytes(Paths.get("src/test/resources/inspect/complex-repeated-rooted.json")));
JsonDocument document = inspectionService.inspectJsonDocument(instance);
Assert.assertNotNull(document);
Assert.assertThat(document.getFields().getField().size(), Is.is(1));
JsonComplexType root = (JsonComplexType) document.getFields().getField().get(0);
Assert.assertNotNull(root);
Assert.assertThat(root.getJsonFields().getJsonField().size(), Is.is(3));
Assert.assertThat(root.getName(), Is.is("SourceOrderList"));
JsonComplexType orders = (JsonComplexType) root.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(orders);
Assert.assertThat(orders.getJsonFields().getJsonField().size(), Is.is(15));
Assert.assertThat(orders.getName(), Is.is("orders"));
JsonField orderBatchNumber = root.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(orderBatchNumber);
Assert.assertThat(orderBatchNumber.getName(), Is.is("orderBatchNumber"));
Assert.assertThat(orderBatchNumber.getValue(), Is.is(4123562));
Assert.assertThat(orderBatchNumber.getPath(), Is.is("/SourceOrderList/orderBatchNumber"));
Assert.assertThat(orderBatchNumber.getFieldType(), Is.is(FieldType.INTEGER));
Assert.assertThat(orderBatchNumber.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField numberOrders = root.getJsonFields().getJsonField().get(2);
Assert.assertNotNull(numberOrders);
Assert.assertThat(numberOrders.getName(), Is.is("numberOrders"));
Assert.assertThat(numberOrders.getValue(), Is.is(5));
Assert.assertThat(numberOrders.getPath(), Is.is("/SourceOrderList/numberOrders"));
Assert.assertThat(numberOrders.getFieldType(), Is.is(FieldType.INTEGER));
Assert.assertThat(numberOrders.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonComplexType complexAddress11 = (JsonComplexType) orders.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(complexAddress11);
Assert.assertThat(complexAddress11.getJsonFields().getJsonField().size(), Is.is(5));
Assert.assertThat(complexAddress11.getName(), Is.is("address"));
Assert.assertThat(complexAddress11.getPath(), Is.is("/SourceOrderList/orders/address"));
JsonField address11 = complexAddress11.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(address11);
Assert.assertThat(address11.getName(), Is.is("addressLine1"));
Assert.assertThat(address11.getValue(), Is.is("123 Main St"));
Assert.assertThat(address11.getPath(), Is.is("/SourceOrderList/orders/address/addressLine1"));
Assert.assertThat(address11.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(address11.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField address12 = complexAddress11.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(address12);
Assert.assertThat(address12.getName(), Is.is("addressLine2"));
Assert.assertThat(address12.getValue(), Is.is("Suite 42b"));
Assert.assertThat(address12.getPath(), Is.is("/SourceOrderList/orders/address/addressLine2"));
Assert.assertThat(address12.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(address12.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField city = complexAddress11.getJsonFields().getJsonField().get(2);
Assert.assertNotNull(city);
Assert.assertThat(city.getName(), Is.is("city"));
Assert.assertThat(city.getValue(), Is.is("Anytown"));
Assert.assertThat(city.getPath(), Is.is("/SourceOrderList/orders/address/city"));
Assert.assertThat(city.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(city.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField state = complexAddress11.getJsonFields().getJsonField().get(3);
Assert.assertNotNull(state);
Assert.assertThat(state.getName(), Is.is("state"));
Assert.assertThat(state.getValue(), Is.is("NY"));
Assert.assertThat(state.getPath(), Is.is("/SourceOrderList/orders/address/state"));
Assert.assertThat(state.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(state.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField postalCode = complexAddress11.getJsonFields().getJsonField().get(4);
Assert.assertNotNull(postalCode);
Assert.assertThat(postalCode.getName(), Is.is("zipCode"));
Assert.assertThat(postalCode.getValue(), Is.is("90210"));
Assert.assertThat(postalCode.getPath(), Is.is("/SourceOrderList/orders/address/zipCode"));
Assert.assertThat(postalCode.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(postalCode.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonComplexType complexContact11 = (JsonComplexType) orders.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(complexContact11);
Assert.assertThat(complexContact11.getJsonFields().getJsonField().size(), Is.is(4));
Assert.assertThat(complexContact11.getName(), Is.is("contact"));
Assert.assertThat(complexContact11.getPath(), Is.is("/SourceOrderList/orders/contact"));
JsonField firstName = complexContact11.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(firstName);
Assert.assertThat(firstName.getName(), Is.is("firstName"));
Assert.assertThat(firstName.getValue(), Is.is("Ozzie"));
Assert.assertThat(firstName.getPath(), Is.is("/SourceOrderList/orders/contact/firstName"));
Assert.assertThat(firstName.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(firstName.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField lastName = complexContact11.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(lastName);
Assert.assertThat(lastName.getName(), Is.is("lastName"));
Assert.assertThat(lastName.getValue(), Is.is("Smith"));
Assert.assertThat(lastName.getPath(), Is.is("/SourceOrderList/orders/contact/lastName"));
Assert.assertThat(lastName.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(lastName.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField phoneNumber = complexContact11.getJsonFields().getJsonField().get(2);
Assert.assertNotNull(phoneNumber);
Assert.assertThat(phoneNumber.getName(), Is.is("phoneNumber"));
Assert.assertThat(phoneNumber.getValue(), Is.is("5551212"));
Assert.assertThat(phoneNumber.getPath(), Is.is("/SourceOrderList/orders/contact/phoneNumber"));
Assert.assertThat(phoneNumber.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(phoneNumber.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField zipCode = complexContact11.getJsonFields().getJsonField().get(3);
Assert.assertNotNull(zipCode);
Assert.assertThat(zipCode.getName(), Is.is("zipCode"));
Assert.assertThat(zipCode.getValue(), Is.is("81111"));
Assert.assertThat(zipCode.getPath(), Is.is("/SourceOrderList/orders/contact/zipCode"));
Assert.assertThat(zipCode.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(zipCode.getStatus(), Is.is(FieldStatus.SUPPORTED));
// repeat
JsonComplexType complexAddress12 = (JsonComplexType) orders.getJsonFields().getJsonField().get(3);
Assert.assertNotNull(complexAddress12);
Assert.assertThat(complexAddress12.getJsonFields().getJsonField().size(), Is.is(5));
Assert.assertThat(complexAddress12.getName(), Is.is("address"));
Assert.assertThat(complexAddress12.getPath(), Is.is("/SourceOrderList/orders[1]/address"));
JsonField address2 = complexAddress12.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(address2);
Assert.assertThat(address2.getName(), Is.is("addressLine1"));
Assert.assertThat(address2.getValue(), Is.is("123 Main St"));
Assert.assertThat(address2.getPath(), Is.is("/SourceOrderList/orders[1]/address/addressLine1"));
Assert.assertThat(address2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(address2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField address22 = complexAddress12.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(address22);
Assert.assertThat(address22.getName(), Is.is("addressLine2"));
Assert.assertThat(address22.getValue(), Is.is("Suite 42b"));
Assert.assertThat(address22.getPath(), Is.is("/SourceOrderList/orders[1]/address/addressLine2"));
Assert.assertThat(address22.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(address22.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField city2 = complexAddress12.getJsonFields().getJsonField().get(2);
Assert.assertNotNull(city2);
Assert.assertThat(city2.getName(), Is.is("city"));
Assert.assertThat(city2.getValue(), Is.is("Anytown"));
Assert.assertThat(city2.getPath(), Is.is("/SourceOrderList/orders[1]/address/city"));
Assert.assertThat(city2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(city2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField state2 = complexAddress12.getJsonFields().getJsonField().get(3);
Assert.assertNotNull(state2);
Assert.assertThat(state2.getName(), Is.is("state"));
Assert.assertThat(state2.getValue(), Is.is("NY"));
Assert.assertThat(state2.getPath(), Is.is("/SourceOrderList/orders[1]/address/state"));
Assert.assertThat(state2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(state2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField postalCode2 = complexAddress12.getJsonFields().getJsonField().get(4);
Assert.assertNotNull(postalCode2);
Assert.assertThat(postalCode2.getName(), Is.is("zipCode"));
Assert.assertThat(postalCode2.getValue(), Is.is("90210"));
Assert.assertThat(postalCode2.getPath(), Is.is("/SourceOrderList/orders[1]/address/zipCode"));
Assert.assertThat(postalCode2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(postalCode2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonComplexType complexContact12 = (JsonComplexType) orders.getJsonFields().getJsonField().get(4);
Assert.assertNotNull(complexContact12);
Assert.assertThat(complexContact12.getJsonFields().getJsonField().size(), Is.is(4));
Assert.assertThat(complexContact12.getName(), Is.is("contact"));
Assert.assertThat(complexContact12.getPath(), Is.is("/SourceOrderList/orders[1]/contact"));
JsonField firstName2 = complexContact12.getJsonFields().getJsonField().get(0);
Assert.assertNotNull(firstName2);
Assert.assertThat(firstName2.getName(), Is.is("firstName"));
Assert.assertThat(firstName2.getValue(), Is.is("Ozzie"));
Assert.assertThat(firstName2.getPath(), Is.is("/SourceOrderList/orders[1]/contact/firstName"));
Assert.assertThat(firstName2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(firstName2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField lastName2 = complexContact12.getJsonFields().getJsonField().get(1);
Assert.assertNotNull(lastName2);
Assert.assertThat(lastName2.getName(), Is.is("lastName"));
Assert.assertThat(lastName2.getValue(), Is.is("Smith"));
Assert.assertThat(lastName2.getPath(), Is.is("/SourceOrderList/orders[1]/contact/lastName"));
Assert.assertThat(lastName2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(lastName2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField phoneNumber2 = complexContact12.getJsonFields().getJsonField().get(2);
Assert.assertNotNull(phoneNumber2);
Assert.assertThat(phoneNumber2.getName(), Is.is("phoneNumber"));
Assert.assertThat(phoneNumber2.getValue(), Is.is("5551212"));
Assert.assertThat(phoneNumber2.getPath(), Is.is("/SourceOrderList/orders[1]/contact/phoneNumber"));
Assert.assertThat(phoneNumber2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(phoneNumber2.getStatus(), Is.is(FieldStatus.SUPPORTED));
JsonField zipCode2 = complexContact12.getJsonFields().getJsonField().get(3);
Assert.assertNotNull(zipCode2);
Assert.assertThat(zipCode2.getName(), Is.is("zipCode"));
Assert.assertThat(zipCode2.getValue(), Is.is("81111"));
Assert.assertThat(zipCode2.getPath(), Is.is("/SourceOrderList/orders[1]/contact/zipCode"));
Assert.assertThat(zipCode2.getFieldType(), Is.is(FieldType.STRING));
Assert.assertThat(zipCode2.getStatus(), Is.is(FieldStatus.SUPPORTED));
// etc......
// printDocument(document);
}
use of io.atlasmap.json.v2.JsonComplexType in project atlasmap by atlasmap.
the class SchemaInspectorTest method inspectComplexObjectWithRoot.
@Test
public void inspectComplexObjectWithRoot() throws Exception {
final String schema = new String(Files.readAllBytes(Paths.get("src/test/resources/inspect/schema/complex-object-rooted.json")));
JsonDocument document = inspectionService.inspectJsonSchema(schema);
assertNotNull(document);
assertEquals(1, document.getFields().getField().size());
JsonComplexType root = (JsonComplexType) document.getFields().getField().get(0);
assertEquals(3, root.getJsonFields().getJsonField().size());
JsonComplexType address = (JsonComplexType) root.getJsonFields().getJsonField().get(0);
assertNotNull(address);
assertEquals(5, address.getJsonFields().getJsonField().size());
JsonField address1 = address.getJsonFields().getJsonField().get(0);
assertNotNull(address1);
assertEquals("addressLine1", address1.getName());
assertEquals("/order/address/addressLine1", address1.getPath());
assertEquals(FieldType.STRING, address1.getFieldType());
assertEquals(FieldStatus.SUPPORTED, address1.getStatus());
JsonField address2 = address.getJsonFields().getJsonField().get(1);
assertNotNull(address2);
assertEquals("addressLine2", address2.getName());
assertEquals("/order/address/addressLine2", address2.getPath());
assertEquals(FieldType.STRING, address2.getFieldType());
assertEquals(FieldStatus.SUPPORTED, address2.getStatus());
JsonField city = address.getJsonFields().getJsonField().get(2);
assertNotNull(city);
assertEquals("city", city.getName());
assertEquals("/order/address/city", city.getPath());
assertEquals(FieldType.STRING, city.getFieldType());
assertEquals(FieldStatus.SUPPORTED, city.getStatus());
JsonField state = address.getJsonFields().getJsonField().get(3);
assertNotNull(state);
assertEquals("state", state.getName());
assertEquals("/order/address/state", state.getPath());
assertEquals(FieldType.STRING, state.getFieldType());
assertEquals(FieldStatus.SUPPORTED, state.getStatus());
JsonField postalCode = address.getJsonFields().getJsonField().get(4);
assertNotNull(postalCode);
assertEquals("zipCode", postalCode.getName());
assertEquals("/order/address/zipCode", postalCode.getPath());
assertEquals(FieldType.STRING, postalCode.getFieldType());
assertEquals(FieldStatus.SUPPORTED, postalCode.getStatus());
JsonComplexType contact = (JsonComplexType) root.getJsonFields().getJsonField().get(1);
assertNotNull(contact);
assertEquals(4, contact.getJsonFields().getJsonField().size());
JsonField firstName = contact.getJsonFields().getJsonField().get(0);
assertNotNull(firstName);
assertEquals("firstName", firstName.getName());
assertEquals("/order/contact/firstName", firstName.getPath());
assertEquals(FieldType.STRING, firstName.getFieldType());
assertEquals(FieldStatus.SUPPORTED, firstName.getStatus());
JsonField lastName = contact.getJsonFields().getJsonField().get(1);
assertNotNull(lastName);
assertEquals("lastName", lastName.getName());
assertEquals("/order/contact/lastName", lastName.getPath());
assertEquals(FieldType.STRING, lastName.getFieldType());
assertEquals(FieldStatus.SUPPORTED, lastName.getStatus());
JsonField phoneNumber = contact.getJsonFields().getJsonField().get(2);
assertNotNull(phoneNumber);
assertEquals("phoneNumber", phoneNumber.getName());
assertEquals("/order/contact/phoneNumber", phoneNumber.getPath());
assertEquals(FieldType.STRING, phoneNumber.getFieldType());
assertEquals(FieldStatus.SUPPORTED, phoneNumber.getStatus());
JsonField zipCode = contact.getJsonFields().getJsonField().get(3);
assertNotNull(zipCode);
assertEquals("zipCode", zipCode.getName());
assertEquals("/order/contact/zipCode", zipCode.getPath());
assertEquals(FieldType.STRING, zipCode.getFieldType());
assertEquals(FieldStatus.SUPPORTED, zipCode.getStatus());
JsonField orderId = root.getJsonFields().getJsonField().get(2);
assertNotNull(orderId);
assertEquals("orderId", orderId.getName());
assertEquals("/order/orderId", orderId.getPath());
assertEquals(FieldType.INTEGER, orderId.getFieldType());
assertEquals(FieldStatus.SUPPORTED, orderId.getStatus());
}
use of io.atlasmap.json.v2.JsonComplexType in project atlasmap by atlasmap.
the class SchemaInspectorTest method inspectJsonSchemaRef.
@Test
public void inspectJsonSchemaRef() throws Exception {
final String schema = new String(Files.readAllBytes(Paths.get("src/test/resources/inspect/schema/ref.json")));
JsonDocument document = inspectionService.inspectJsonSchema(schema);
assertNotNull(document);
assertEquals(3, document.getFields().getField().size());
JsonField refA = (JsonField) document.getFields().getField().get(0);
assertNotNull(refA);
assertEquals("ref-a", refA.getName());
assertEquals("/ref-a", refA.getPath());
assertEquals(FieldType.STRING, refA.getFieldType());
assertEquals(FieldStatus.SUPPORTED, refA.getStatus());
JsonComplexType refB = (JsonComplexType) document.getFields().getField().get(1);
assertNotNull(refB);
assertEquals("ref-b", refB.getName());
assertEquals("/ref-b", refB.getPath());
assertEquals(FieldType.COMPLEX, refB.getFieldType());
assertEquals(FieldStatus.SUPPORTED, refB.getStatus());
assertEquals(2, refB.getJsonFields().getJsonField().size());
JsonComplexType refCFromB = (JsonComplexType) refB.getJsonFields().getJsonField().get(0);
assertNotNull(refCFromB);
assertEquals("ref-c-from-b", refCFromB.getName());
assertEquals("/ref-b/ref-c-from-b", refCFromB.getPath());
assertEquals(FieldType.COMPLEX, refCFromB.getFieldType());
assertEquals(FieldStatus.SUPPORTED, refCFromB.getStatus());
assertEquals(1, refCFromB.getJsonFields().getJsonField().size());
JsonField strCFromB = refCFromB.getJsonFields().getJsonField().get(0);
assertNotNull(strCFromB);
assertEquals("str-c", strCFromB.getName());
assertEquals("/ref-b/ref-c-from-b/str-c", strCFromB.getPath());
assertEquals(FieldType.STRING, strCFromB.getFieldType());
assertEquals(FieldStatus.SUPPORTED, strCFromB.getStatus());
JsonField strB = refB.getJsonFields().getJsonField().get(1);
assertNotNull(strB);
assertEquals("str-b", strB.getName());
assertEquals("/ref-b/str-b", strB.getPath());
assertEquals(FieldType.STRING, strB.getFieldType());
assertEquals(FieldStatus.SUPPORTED, strB.getStatus());
JsonComplexType refC = (JsonComplexType) document.getFields().getField().get(2);
assertNotNull(refC);
assertEquals("ref-c", refC.getName());
assertEquals("/ref-c", refC.getPath());
assertEquals(FieldType.COMPLEX, refC.getFieldType());
assertEquals(FieldStatus.SUPPORTED, refC.getStatus());
assertEquals(1, refC.getJsonFields().getJsonField().size());
JsonField strC = refC.getJsonFields().getJsonField().get(0);
assertNotNull(strC);
assertEquals("str-c", strC.getName());
assertEquals("/ref-c/str-c", strC.getPath());
assertEquals(FieldType.STRING, strC.getFieldType());
assertEquals(FieldStatus.SUPPORTED, strC.getStatus());
}
use of io.atlasmap.json.v2.JsonComplexType in project atlasmap by atlasmap.
the class SchemaInspectorTest method inspectComplexObjectNoRoot.
@Test
public void inspectComplexObjectNoRoot() throws Exception {
final String schema = new String(Files.readAllBytes(Paths.get("src/test/resources/inspect/schema/complex-object-unrooted.json")));
JsonDocument document = inspectionService.inspectJsonSchema(schema);
assertNotNull(document);
assertEquals(3, document.getFields().getField().size());
JsonComplexType address = (JsonComplexType) document.getFields().getField().get(0);
assertNotNull(address);
assertEquals(5, address.getJsonFields().getJsonField().size());
JsonField address1 = address.getJsonFields().getJsonField().get(0);
assertNotNull(address1);
assertEquals("addressLine1", address1.getName());
assertEquals("/address/addressLine1", address1.getPath());
assertEquals(FieldType.STRING, address1.getFieldType());
assertEquals(FieldStatus.SUPPORTED, address1.getStatus());
JsonField address2 = address.getJsonFields().getJsonField().get(1);
assertNotNull(address2);
assertEquals("addressLine2", address2.getName());
assertEquals("/address/addressLine2", address2.getPath());
assertEquals(FieldType.STRING, address2.getFieldType());
assertEquals(FieldStatus.SUPPORTED, address2.getStatus());
JsonField city = address.getJsonFields().getJsonField().get(2);
assertNotNull(city);
assertEquals("city", city.getName());
assertEquals("/address/city", city.getPath());
assertEquals(FieldType.STRING, city.getFieldType());
assertEquals(FieldStatus.SUPPORTED, city.getStatus());
JsonField state = address.getJsonFields().getJsonField().get(3);
assertNotNull(state);
assertEquals("state", state.getName());
assertEquals("/address/state", state.getPath());
assertEquals(FieldType.STRING, state.getFieldType());
assertEquals(FieldStatus.SUPPORTED, state.getStatus());
JsonField postalCode = address.getJsonFields().getJsonField().get(4);
assertNotNull(postalCode);
assertEquals("zipCode", postalCode.getName());
assertEquals("/address/zipCode", postalCode.getPath());
assertEquals(FieldType.STRING, postalCode.getFieldType());
assertEquals(FieldStatus.SUPPORTED, postalCode.getStatus());
JsonComplexType contact = (JsonComplexType) document.getFields().getField().get(1);
assertNotNull(contact);
assertEquals(4, contact.getJsonFields().getJsonField().size());
JsonField firstName = contact.getJsonFields().getJsonField().get(0);
assertNotNull(firstName);
assertEquals("firstName", firstName.getName());
assertEquals("/contact/firstName", firstName.getPath());
assertEquals(FieldType.STRING, firstName.getFieldType());
assertEquals(FieldStatus.SUPPORTED, firstName.getStatus());
JsonField lastName = contact.getJsonFields().getJsonField().get(1);
assertNotNull(lastName);
assertEquals("lastName", lastName.getName());
assertEquals("/contact/lastName", lastName.getPath());
assertEquals(FieldType.STRING, lastName.getFieldType());
assertEquals(FieldStatus.SUPPORTED, lastName.getStatus());
JsonField phoneNumber = contact.getJsonFields().getJsonField().get(2);
assertNotNull(phoneNumber);
assertEquals("phoneNumber", phoneNumber.getName());
assertEquals("/contact/phoneNumber", phoneNumber.getPath());
assertEquals(FieldType.STRING, phoneNumber.getFieldType());
assertEquals(FieldStatus.SUPPORTED, phoneNumber.getStatus());
JsonField zipCode = contact.getJsonFields().getJsonField().get(3);
assertNotNull(zipCode);
assertEquals("zipCode", zipCode.getName());
assertEquals("/contact/zipCode", zipCode.getPath());
assertEquals(FieldType.STRING, zipCode.getFieldType());
assertEquals(FieldStatus.SUPPORTED, zipCode.getStatus());
JsonField orderId = (JsonField) document.getFields().getField().get(2);
assertNotNull(orderId);
assertEquals("orderId", orderId.getName());
assertEquals("/orderId", orderId.getPath());
assertEquals(FieldType.INTEGER, orderId.getFieldType());
assertEquals(FieldStatus.SUPPORTED, orderId.getStatus());
}
Aggregations