YamlRecordMapper implements RecordMapper<String, P> { @Override public Record<P> processRecord(Record<String> record) throws Exception { YamlReader reader = new YamlReader(record.getPayload()); P unmarshalledObject = reader.read(type); reader.close(); return new GenericRecord<>(record.getHeader(), unmarshalledObject); } YamlRecordMapper(Class<P> type); @Override Record<P> processRecord(Record<String> record);  }
@Test public void processRecord() throws Exception { Record<Contact> actual = recordMapper.processRecord(record); assertThat(actual).isNotNull(); Contact contact = actual.getPayload(); assertThat(contact).isNotNull(); assertThat(contact.getName()).isEqualTo("Foo"); assertThat(contact.getAge()).isEqualTo(28); }