use of org.apache.samza.sql.avro.schemas.ComplexRecord in project samza by apache.
the class TestAvroRelConversion method testComplexRecordConversion.
@Test
public void testComplexRecordConversion() throws IOException {
GenericData.Record record = new GenericData.Record(ComplexRecord.SCHEMA$);
record.put("id", id);
record.put("bool_value", boolValue);
record.put("double_value", doubleValue);
record.put("float_value0", floatValue);
record.put("string_value", testStrValue);
record.put("bytes_value", testBytes);
record.put("fixed_value", fixedBytes);
record.put("long_value", longValue);
record.put("array_values", arrayValue);
record.put("map_values", mapValue);
record.put("union_value", testStrValue);
ComplexRecord complexRecord = new ComplexRecord();
complexRecord.id = id;
complexRecord.bool_value = boolValue;
complexRecord.double_value = doubleValue;
complexRecord.float_value0 = floatValue;
complexRecord.string_value = testStrValue;
complexRecord.bytes_value = testBytes;
complexRecord.fixed_value = fixedBytes;
complexRecord.long_value = longValue;
complexRecord.array_values = new ArrayList<>();
complexRecord.array_values.addAll(arrayValue);
complexRecord.map_values = new HashMap<>();
complexRecord.map_values.putAll(mapValue);
complexRecord.union_value = testStrValue;
byte[] serializedData = bytesFromGenericRecord(record);
validateAvroSerializedData(serializedData, testStrValue);
serializedData = encodeAvroSpecificRecord(ComplexRecord.class, complexRecord);
validateAvroSerializedData(serializedData, testStrValue);
}
Aggregations