Search in sources :

Example 6 with RecordConverter

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

the class JsonElementConversionFactoryTest method schemaWithMapValuesAsJsonNull.

@Test(expectedExceptions = UnsupportedOperationException.class)
public void schemaWithMapValuesAsJsonNull() throws Exception {
    String testName = "schemaWithMapValuesAsJsonNull";
    JsonObject schema = getSchemaData(testName).getAsJsonObject();
    new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "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)

Example 7 with RecordConverter

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

the class JsonElementConversionFactoryTest method schemaWithRecordIsNullable.

@Test
public void schemaWithRecordIsNullable() throws Exception {
    String testName = "schemaWithRecordIsNullable";
    JsonObject schema = getSchemaData(testName).getAsJsonObject();
    JsonArray expected = getExpectedSchema(testName).getAsJsonArray();
    RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something"));
    Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
Also used : JsonArray(com.google.gson.JsonArray) 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)

Example 8 with RecordConverter

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

the class JsonElementConversionFactoryTest method schemaWithRecordOfArray.

@Test
public void schemaWithRecordOfArray() throws Exception {
    String testName = "schemaWithRecordOfArray";
    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);
}
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)

Example 9 with RecordConverter

use of org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter 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);
}
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)

Example 10 with RecordConverter

use of org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter 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");
}
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