Search in sources :

Example 1 with JsonSchema

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

the class JsonElementConversionFactoryTest method schemaWithRecordOfEnum.

@Test
public void schemaWithRecordOfEnum() throws Exception {
    String testName = "schemaWithRecordOfEnum";
    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 2 with JsonSchema

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

the class JsonElementConversionFactoryTest method schemaWithRecordOfRecord.

@Test
public void schemaWithRecordOfRecord() throws Exception {
    String testName = "schemaWithRecordOfRecord";
    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 3 with JsonSchema

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

the class JsonElementConversionFactoryTest method schemaWithMapOfArrays.

@Test
public void schemaWithMapOfArrays() throws Exception {
    String testName = "schemaWithMapOfArrays";
    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 4 with JsonSchema

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

the class JsonElementConversionFactoryTest method schemaWithRecord.

@Test
public void schemaWithRecord() throws DataConversionException, SchemaConversionException, UnsupportedDateTypeException {
    String testName = "schemaWithRecord";
    JsonObject schema = getSchemaData(testName).getAsJsonObject();
    JsonObject expected = getExpectedSchema(testName).getAsJsonObject();
    JsonSchema jsonSchema = new JsonSchema(schema);
    jsonSchema.setColumnName("dummy1");
    RecordConverter converter = new RecordConverter(jsonSchema, 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 5 with JsonSchema

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

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