}
@Test
public void testRecordTypeFieldTypeEntries() throws Exception {
QName name = new QName("aNamespace", "aName");
SchemaId recordTypeId = new SchemaIdImpl(UUID.randomUUID());
RecordType recordType = new RecordTypeImpl(recordTypeId, name);
typeManager.newRecordType(recordTypeId, name);
expectLastCall().andReturn(recordType);
SchemaId fieldTypeId1 = new SchemaIdImpl(UUID.randomUUID());
SchemaId fieldTypeId2 = new SchemaIdImpl(UUID.randomUUID());
FieldTypeEntryImpl fieldTypeEntry1 = new FieldTypeEntryImpl(fieldTypeId1, true);
FieldTypeEntryImpl fieldTypeEntry2 = new FieldTypeEntryImpl(fieldTypeId2, false);
typeManager.newFieldTypeEntry(fieldTypeId1, true);
expectLastCall().andReturn(fieldTypeEntry1);
typeManager.newFieldTypeEntry(fieldTypeId2, false);
expectLastCall().andReturn(fieldTypeEntry2);
control.replay();
converter = new AvroConverter();
recordType.addFieldTypeEntry(fieldTypeEntry1);
recordType.addFieldTypeEntry(fieldTypeEntry2);
AvroRecordType avroRecordType = new AvroRecordType();
AvroSchemaId avroRecordTypeId = new AvroSchemaId();
avroRecordTypeId.idBytes = ByteBuffer.wrap(recordTypeId.getBytes());
avroRecordType.id = avroRecordTypeId;
AvroQName avroQName = new AvroQName();
avroQName.namespace = "aNamespace";
avroQName.name = "aName";
avroRecordType.name = avroQName;
// fieldTypeEntries and supertypes are by default empty instead of null
avroRecordType.fieldTypeEntries =
new GenericData.Array<AvroFieldTypeEntry>(0, Schema.createArray(AvroFieldTypeEntry.SCHEMA$));
AvroFieldTypeEntry avroFieldTypeEntry = new AvroFieldTypeEntry();
AvroSchemaId avroFieldTypeId1 = new AvroSchemaId();
avroFieldTypeId1.idBytes = ByteBuffer.wrap(fieldTypeId1.getBytes());
avroFieldTypeEntry.id = avroFieldTypeId1;
avroFieldTypeEntry.mandatory = true;
avroRecordType.fieldTypeEntries.add(avroFieldTypeEntry);
Set<AvroFieldTypeEntry> expectedFieldTypeEntries = new HashSet<AvroFieldTypeEntry>();
expectedFieldTypeEntries.add(avroFieldTypeEntry);
avroFieldTypeEntry = new AvroFieldTypeEntry();
AvroSchemaId avroFieldTypeId2 = new AvroSchemaId();
avroFieldTypeId2.idBytes = ByteBuffer.wrap(fieldTypeId2.getBytes());
avroFieldTypeEntry.id = avroFieldTypeId2;
avroFieldTypeEntry.mandatory = false;
avroRecordType.fieldTypeEntries.add(avroFieldTypeEntry);
expectedFieldTypeEntries.add(avroFieldTypeEntry);
avroRecordType.supertypes = new GenericData.Array<AvroSupertype>(0, Schema.createArray(AvroSupertype.SCHEMA$));