Search in sources :

Example 36 with JsonDocument

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());
}
Also used : Field(io.atlasmap.v2.Field) JsonField(io.atlasmap.json.v2.JsonField) JsonField(io.atlasmap.json.v2.JsonField) JsonDocument(io.atlasmap.json.v2.JsonDocument)

Example 37 with JsonDocument

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());
}
Also used : Field(io.atlasmap.v2.Field) JsonField(io.atlasmap.json.v2.JsonField) JsonField(io.atlasmap.json.v2.JsonField) JsonDocument(io.atlasmap.json.v2.JsonDocument) Test(org.junit.Test)

Aggregations

JsonDocument (io.atlasmap.json.v2.JsonDocument)34 JsonField (io.atlasmap.json.v2.JsonField)31 Test (org.junit.Test)29 JsonComplexType (io.atlasmap.json.v2.JsonComplexType)17 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 Field (io.atlasmap.v2.Field)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 IOException (java.io.IOException)2 Map (java.util.Map)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 JsonDocumentInspectionService (io.atlasmap.json.inspect.JsonDocumentInspectionService)1 JsonFields (io.atlasmap.json.v2.JsonFields)1 JsonInspectionRequest (io.atlasmap.json.v2.JsonInspectionRequest)1 JsonInspectionResponse (io.atlasmap.json.v2.JsonInspectionResponse)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 ApplicationPath (javax.ws.rs.ApplicationPath)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1