use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class SchemaInspectorTest method inspectFlatPrimitiveWithRoot.
@Test
public void inspectFlatPrimitiveWithRoot() throws Exception {
final String instance = new String(Files.readAllBytes(Paths.get("src/test/resources/inspect/schema/flatprimitive-base-rooted.json")));
JsonDocument document = inspectionService.inspectJsonSchema(instance);
assertNotNull(document);
assertEquals(1, document.getFields().getField().size());
JsonComplexType root = (JsonComplexType) document.getFields().getField().get(0);
assertNotNull(root);
assertEquals("SourceFlatPrimitive", root.getName());
assertEquals("/SourceFlatPrimitive", root.getPath());
assertEquals(FieldType.COMPLEX, root.getFieldType());
assertEquals(FieldStatus.SUPPORTED, root.getStatus());
assertEquals(5, root.getJsonFields().getJsonField().size());
List<JsonField> fields = root.getJsonFields().getJsonField();
JsonField field = fields.get(0);
assertEquals("booleanField", field.getName());
assertEquals("/SourceFlatPrimitive/booleanField", field.getPath());
assertEquals(FieldType.BOOLEAN, field.getFieldType());
assertEquals(FieldStatus.SUPPORTED, field.getStatus());
field = fields.get(1);
assertEquals("stringField", field.getName());
assertEquals("/SourceFlatPrimitive/stringField", field.getPath());
assertEquals(FieldType.STRING, field.getFieldType());
assertEquals(FieldStatus.SUPPORTED, field.getStatus());
field = fields.get(2);
assertEquals("numberField", field.getName());
assertEquals("/SourceFlatPrimitive/numberField", field.getPath());
assertEquals(FieldType.NUMBER, field.getFieldType());
assertEquals(FieldStatus.SUPPORTED, field.getStatus());
field = fields.get(3);
assertEquals("intField", field.getName());
assertEquals("/SourceFlatPrimitive/intField", field.getPath());
assertEquals(FieldType.INTEGER, field.getFieldType());
assertEquals(FieldStatus.SUPPORTED, field.getStatus());
field = fields.get(4);
assertEquals("nullField", field.getName());
assertEquals("/SourceFlatPrimitive/nullField", field.getPath());
assertEquals(FieldType.NONE, field.getFieldType());
assertEquals(FieldStatus.SUPPORTED, field.getStatus());
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class SchemaInspectorTest method inspectJsonSchemaSimpleString.
@Test
public void inspectJsonSchemaSimpleString() throws Exception {
final String schema = "{\"$schema\": \"http://json-schema.org/\", \"type\": \"string\"}";
JsonDocument document = inspectionService.inspectJsonSchema(schema);
assertNotNull(document);
assertEquals(1, document.getFields().getField().size());
JsonField jsonField = (JsonField) document.getFields().getField().get(0);
assertTrue(jsonField.getStatus().compareTo(FieldStatus.SUPPORTED) == 0);
assertEquals(FieldType.STRING, jsonField.getFieldType());
assertNull(jsonField.getName());
assertNull(jsonField.getPath());
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class SchemaInspectorTest method inspectJsonSchemaGeo.
// examples from json-schema.org
@Test
public void inspectJsonSchemaGeo() throws Exception {
final String schema = new String(Files.readAllBytes(Paths.get("src/test/resources/inspect/schema/geo.json")));
JsonDocument document = inspectionService.inspectJsonSchema(schema);
List<Field> fields = document.getFields().getField();
JsonField f = (JsonField) fields.get(0);
assertEquals("latitude", f.getName());
assertEquals("/latitude", f.getPath());
assertEquals(FieldType.NUMBER, f.getFieldType());
f = (JsonField) fields.get(1);
assertEquals("longitude", f.getName());
assertEquals("/longitude", f.getPath());
assertEquals(FieldType.NUMBER, f.getFieldType());
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class SchemaInspectorTest method doInspectJsonSchemaCard.
private void doInspectJsonSchemaCard(String schema) throws Exception {
JsonDocument document = inspectionService.inspectJsonSchema(schema);
List<Field> fields = document.getFields().getField();
JsonField f = (JsonField) fields.get(0);
assertEquals("fn", f.getName());
assertEquals("/fn", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(1);
assertEquals("familyName", f.getName());
assertEquals("/familyName", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(2);
assertEquals("givenName", f.getName());
assertEquals("/givenName", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(3);
assertEquals("additionalName", f.getName());
assertEquals("/additionalName", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
assertEquals(CollectionType.LIST, f.getCollectionType());
f = (JsonField) fields.get(4);
assertEquals("honorificPrefix", f.getName());
assertEquals("/honorificPrefix", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
assertEquals(CollectionType.LIST, f.getCollectionType());
f = (JsonField) fields.get(5);
assertEquals("honorificSuffix", f.getName());
assertEquals("/honorificSuffix", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
assertEquals(CollectionType.LIST, f.getCollectionType());
f = (JsonField) fields.get(6);
assertEquals("nickname", f.getName());
assertEquals("/nickname", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(7);
assertEquals("url", f.getName());
assertEquals("/url", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonComplexType) fields.get(8);
assertEquals("email", f.getName());
assertEquals("/email", f.getPath());
assertEquals(FieldType.COMPLEX, f.getFieldType());
List<JsonField> emailfields = ((JsonComplexType) f).getJsonFields().getJsonField();
f = emailfields.get(0);
assertEquals("type", f.getName());
assertEquals("/email/type", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = emailfields.get(1);
assertEquals("value", f.getName());
assertEquals("/email/value", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonComplexType) fields.get(9);
assertEquals("tel", f.getName());
assertEquals("/tel", f.getPath());
assertEquals(FieldType.COMPLEX, f.getFieldType());
List<JsonField> telfields = ((JsonComplexType) f).getJsonFields().getJsonField();
f = telfields.get(0);
assertEquals("type", f.getName());
assertEquals("/tel/type", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = telfields.get(1);
assertEquals("value", f.getName());
assertEquals("/tel/value", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonComplexType) fields.get(10);
assertEquals("adr", f.getName());
assertEquals("/adr", f.getPath());
assertEquals(FieldType.COMPLEX, f.getFieldType());
List<JsonField> addrfields = ((JsonComplexType) f).getJsonFields().getJsonField();
f = addrfields.get(0);
assertEquals("post-office-box", f.getName());
assertEquals("/adr/post-office-box", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = addrfields.get(1);
assertEquals("extended-address", f.getName());
assertEquals("/adr/extended-address", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = addrfields.get(2);
assertEquals("street-address", f.getName());
assertEquals("/adr/street-address", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = addrfields.get(3);
assertEquals("locality", f.getName());
assertEquals("/adr/locality", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = addrfields.get(4);
assertEquals("region", f.getName());
assertEquals("/adr/region", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = addrfields.get(5);
assertEquals("postal-code", f.getName());
assertEquals("/adr/postal-code", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = addrfields.get(6);
assertEquals("country-name", f.getName());
assertEquals("/adr/country-name", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonComplexType) fields.get(11);
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());
f = (JsonField) fields.get(12);
assertEquals("tz", f.getName());
assertEquals("/tz", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(13);
assertEquals("photo", f.getName());
assertEquals("/photo", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(14);
assertEquals("logo", f.getName());
assertEquals("/logo", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(15);
assertEquals("sound", f.getName());
assertEquals("/sound", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(16);
assertEquals("bday", f.getName());
assertEquals("/bday", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(17);
assertEquals("title", f.getName());
assertEquals("/title", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonField) fields.get(18);
assertEquals("role", f.getName());
assertEquals("/role", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = (JsonComplexType) fields.get(19);
assertEquals("org", f.getName());
assertEquals("/org", f.getPath());
assertEquals(FieldType.COMPLEX, f.getFieldType());
List<JsonField> orgfields = ((JsonComplexType) f).getJsonFields().getJsonField();
f = orgfields.get(0);
assertEquals("organizationName", f.getName());
assertEquals("/org/organizationName", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
f = orgfields.get(1);
assertEquals("organizationUnit", f.getName());
assertEquals("/org/organizationUnit", f.getPath());
assertEquals(FieldType.STRING, f.getFieldType());
}
use of io.atlasmap.json.v2.JsonField 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());
}
Aggregations