Search in sources :

Example 1 with UnionConverter

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

the class JsonElementConversionFactoryTest method schemaWithUnion.

@Test
public void schemaWithUnion() throws Exception {
    String testName = "schemaWithUnion";
    JsonObject schema = getSchemaData(testName).getAsJsonObject();
    JsonArray expected = getExpectedSchema(testName).getAsJsonArray();
    UnionConverter converter = new UnionConverter(new JsonSchema(schema), state);
    Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonSchema(org.apache.gobblin.converter.json.JsonSchema) JsonObject(com.google.gson.JsonObject) UnionConverter(org.apache.gobblin.converter.avro.JsonElementConversionFactory.UnionConverter) Test(org.testng.annotations.Test)

Example 2 with UnionConverter

use of org.apache.gobblin.converter.avro.JsonElementConversionFactory.UnionConverter 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);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonSchema(org.apache.gobblin.converter.json.JsonSchema) JsonObject(com.google.gson.JsonObject) UnionConverter(org.apache.gobblin.converter.avro.JsonElementConversionFactory.UnionConverter) Test(org.testng.annotations.Test)

Aggregations

JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 UnionConverter (org.apache.gobblin.converter.avro.JsonElementConversionFactory.UnionConverter)2 JsonSchema (org.apache.gobblin.converter.json.JsonSchema)2 Test (org.testng.annotations.Test)2