use of org.apache.gobblin.converter.json.JsonSchema in project incubator-gobblin by apache.
the class JsonElementConversionFactoryTest method schemaWithMapOfRecords.
@Test
public void schemaWithMapOfRecords() throws Exception {
String testName = "schemaWithMapOfRecords";
JsonObject schema = getSchemaData(testName).getAsJsonObject();
JsonObject expected = getExpectedSchema(testName).getAsJsonObject();
MapConverter converter = new MapConverter(new JsonSchema(schema), state);
Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
use of org.apache.gobblin.converter.json.JsonSchema in project incubator-gobblin by apache.
the class JsonElementConversionFactoryTest method schemaWithComplexUnion.
@Test
public void schemaWithComplexUnion() throws Exception {
String testName = "schemaWithComplexUnion";
JsonObject schema = getSchemaData(testName).getAsJsonObject();
JsonArray expected = getExpectedSchema(testName).getAsJsonArray();
UnionConverter converter = new UnionConverter(new JsonSchema(schema), state);
Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
use of org.apache.gobblin.converter.json.JsonSchema in project incubator-gobblin by apache.
the class JsonElementConversionFactoryTest method schemaWithRecordOfMap.
@Test
public void schemaWithRecordOfMap() throws Exception {
String testName = "schemaWithRecordOfMap";
JsonObject schema = getSchemaData(testName).getAsJsonObject();
JsonObject expected = getExpectedSchema(testName).getAsJsonObject();
RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something"));
Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
use of org.apache.gobblin.converter.json.JsonSchema in project incubator-gobblin by apache.
the class JsonElementConversionFactoryTest method schemaWithRecordOfRecordCheckNamespace.
@Test
public void schemaWithRecordOfRecordCheckNamespace() throws Exception {
String testName = "schemaWithRecordOfRecordCheckNamespace";
JsonObject schema = getSchemaData(testName).getAsJsonObject();
JsonObject expected = getExpectedSchema(testName).getAsJsonObject();
RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "person"));
Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
Assert.assertEquals(converter.schema().getField("someperson").schema().getNamespace(), "namespace.person.myrecord");
Assert.assertEquals(converter.schema().getNamespace(), "namespace.person");
}
use of org.apache.gobblin.converter.json.JsonSchema in project incubator-gobblin by apache.
the class JsonElementConversionFactoryTest method schemaWithArrayOfRecords.
@Test
public void schemaWithArrayOfRecords() throws Exception {
String testName = "schemaWithArrayOfRecords";
JsonObject schema = getSchemaData(testName).getAsJsonObject();
JsonObject expected = getExpectedSchema(testName).getAsJsonObject();
JsonSchema jsonSchema = new JsonSchema(schema);
jsonSchema.setColumnName("dummy1");
ArrayConverter converter = new ArrayConverter(jsonSchema, state);
Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
Aggregations