Search in sources :

Example 6 with JsonSchema

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

the class JsonElementConversionFactoryTest method schemaWithIsNullable.

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

Example 7 with JsonSchema

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

the class JsonElementConversionFactoryTest method schemaWithMap.

@Test
public void schemaWithMap() throws Exception {
    String testName = "schemaWithMap";
    JsonObject schema = getSchemaData(testName).getAsJsonObject();
    JsonObject expected = getExpectedSchema(testName).getAsJsonObject();
    MapConverter converter = new MapConverter(new JsonSchema(schema), state);
    Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
Also used : 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 8 with JsonSchema

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

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

the class JsonElementConversionFactoryTest method schemaWithMapOfEnum.

@Test
public void schemaWithMapOfEnum() throws Exception {
    String testName = "schemaWithMapOfEnum";
    JsonObject schema = getSchemaData(testName).getAsJsonObject();
    JsonObject expected = getExpectedSchema(testName).getAsJsonObject();
    MapConverter converter = new MapConverter(new JsonSchema(schema), state);
    Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
Also used : 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 10 with JsonSchema

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

the class JsonElementConversionFactoryTest method schemaWithEnumIsNullable.

@Test
public void schemaWithEnumIsNullable() throws Exception {
    String testName = "schemaWithEnumIsNullable";
    JsonObject schema = getSchemaData(testName).getAsJsonObject();
    JsonArray expected = getExpectedSchema(testName).getAsJsonArray();
    EnumConverter converter = new EnumConverter(new JsonSchema(schema), "something");
    Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
Also used : JsonArray(com.google.gson.JsonArray) EnumConverter(org.apache.gobblin.converter.avro.JsonElementConversionFactory.EnumConverter) 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