use of io.atlasmap.json.v2.JsonDocument in project atlasmap by atlasmap.
the class SchemaInspectorTest method doInspectJsonSchemaCalendar.
private void doInspectJsonSchemaCalendar(String instance) throws Exception {
JsonDocument document = inspectionService.inspectJsonSchema(instance);
List<Field> fields = document.getFields().getField();
JsonField f = (JsonField) fields.get(0);
assertEquals("dtstart", f.getName());
assertEquals("/dtstart", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(1);
assertEquals("dtend", f.getName());
assertEquals("/dtend", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(2);
assertEquals("summary", f.getName());
assertEquals("/summary", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(3);
assertEquals("location", f.getName());
assertEquals("/location", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(4);
assertEquals("url", f.getName());
assertEquals("/url", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(5);
assertEquals("duration", f.getName());
assertEquals("/duration", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(6);
assertEquals("rdate", f.getName());
assertEquals("/rdate", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(7);
assertEquals("rrule", f.getName());
assertEquals("/rrule", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(8);
assertEquals("category", f.getName());
assertEquals("/category", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(9);
assertEquals("description", f.getName());
assertEquals("/description", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonComplexType) fields.get(10);
assertEquals("geo", f.getName());
assertEquals("/geo", f.getPath());
assertEquals(FieldType.COMPLEX, f.getFieldType());
List<JsonField> geofields = ((JsonComplexType) f).getJsonFields().getJsonField();
f = geofields.get(0);
assertEquals("latitude", f.getName());
assertEquals("/geo/latitude", f.getPath());
assertEquals(FieldType.NUMBER, f.getFieldType());
f = geofields.get(1);
assertEquals("longitude", f.getName());
assertEquals("/geo/longitude", f.getPath());
assertEquals(FieldType.NUMBER, f.getFieldType());
}
use of io.atlasmap.json.v2.JsonDocument in project atlasmap by atlasmap.
the class SchemaInspectorTest method inspectJsonSchemaAddress.
@Test
public void inspectJsonSchemaAddress() throws Exception {
final String schema = new String(Files.readAllBytes(Paths.get("src/test/resources/inspect/schema/address.json")));
JsonDocument document = inspectionService.inspectJsonSchema(schema);
List<Field> fields = document.getFields().getField();
JsonField f = (JsonField) fields.get(0);
assertEquals("post-office-box", f.getName());
assertEquals("/post-office-box", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(1);
assertEquals("extended-address", f.getName());
assertEquals("/extended-address", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(2);
assertEquals("street-address", f.getName());
assertEquals("/street-address", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(3);
assertEquals("locality", f.getName());
assertEquals("/locality", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(4);
assertEquals("region", f.getName());
assertEquals("/region", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(5);
assertEquals("postal-code", f.getName());
assertEquals("/postal-code", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(6);
assertEquals("country-name", f.getName());
assertEquals("/country-name", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
}
Aggregations