Search in sources :

Example 16 with JsonSchema

use of org.apache.gobblin.converter.json.JsonSchema 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 17 with JsonSchema

use of org.apache.gobblin.converter.json.JsonSchema 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 18 with JsonSchema

use of org.apache.gobblin.converter.json.JsonSchema in project incubator-gobblin by apache.

the class JsonElementConversionFactoryTest method schemaWithMapIsNullable.

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

Example 19 with JsonSchema

use of org.apache.gobblin.converter.json.JsonSchema 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 20 with JsonSchema

use of org.apache.gobblin.converter.json.JsonSchema 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)

Aggregations

JsonSchema (org.apache.gobblin.converter.json.JsonSchema)26 JsonObject (com.google.gson.JsonObject)25 Test (org.testng.annotations.Test)24 RecordConverter (org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter)11 JsonArray (com.google.gson.JsonArray)7 ArrayConverter (org.apache.gobblin.converter.avro.JsonElementConversionFactory.ArrayConverter)5 MapConverter (org.apache.gobblin.converter.avro.JsonElementConversionFactory.MapConverter)5 UnionConverter (org.apache.gobblin.converter.avro.JsonElementConversionFactory.UnionConverter)2 Schema (org.apache.avro.Schema)1 SchemaConversionException (org.apache.gobblin.converter.SchemaConversionException)1 EnumConverter (org.apache.gobblin.converter.avro.JsonElementConversionFactory.EnumConverter)1 StringConverter (org.apache.gobblin.converter.avro.JsonElementConversionFactory.StringConverter)1