Search in sources :

Example 1 with ArrayConverter

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

the class JsonElementConversionFactoryTest method schemaWithArrayOfInts.

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

Example 2 with ArrayConverter

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

the class JsonElementConversionFactoryTest method schemaWithArrayIsNullable.

@Test
public void schemaWithArrayIsNullable() throws Exception {
    String testName = "schemaWithArrayIsNullable";
    JsonObject schema = getSchemaData(testName).getAsJsonObject();
    JsonArray expected = getExpectedSchema(testName).getAsJsonArray();
    ArrayConverter converter = new ArrayConverter(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) ArrayConverter(org.apache.gobblin.converter.avro.JsonElementConversionFactory.ArrayConverter) Test(org.testng.annotations.Test)

Example 3 with ArrayConverter

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

the class JsonElementConversionFactoryTest method schemaWithArrayOfEnums.

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

Example 4 with ArrayConverter

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

the class JsonElementConversionFactoryTest method schemaWithArrayOfMaps.

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

Example 5 with ArrayConverter

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

Aggregations

JsonObject (com.google.gson.JsonObject)5 ArrayConverter (org.apache.gobblin.converter.avro.JsonElementConversionFactory.ArrayConverter)5 JsonSchema (org.apache.gobblin.converter.json.JsonSchema)5 Test (org.testng.annotations.Test)5 JsonArray (com.google.gson.JsonArray)1