Search in sources :

Example 11 with RecordConverter

use of org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter in project incubator-gobblin by apache.

the class JsonElementConversionFactoryTest method schemaWithRecordOfEnumCheckNamespace.

@Test
public void schemaWithRecordOfEnumCheckNamespace() throws Exception {
    String testName = "schemaWithRecordOfEnumCheckNamespace";
    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);
    Assert.assertEquals(converter.schema().getField("someperson").schema().getNamespace(), "namespace.something.myrecord");
    Assert.assertEquals(converter.schema().getNamespace(), "namespace.something");
}
Also used : RecordConverter(org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter) JsonSchema(org.apache.gobblin.converter.json.JsonSchema) JsonObject(com.google.gson.JsonObject) Test(org.testng.annotations.Test)

Aggregations

RecordConverter (org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter)11 JsonSchema (org.apache.gobblin.converter.json.JsonSchema)11 JsonObject (com.google.gson.JsonObject)10 Test (org.testng.annotations.Test)10 JsonArray (com.google.gson.JsonArray)1 Schema (org.apache.avro.Schema)1 SchemaConversionException (org.apache.gobblin.converter.SchemaConversionException)1