CollectionRecordWriter implements RecordWriter<P> { @Override public void writeRecords(Batch<P> batch) { for (Record<P> record : batch) { collection.add(record.getPayload()); } } CollectionRecordWriter(final Collection<P> collection); @Override void writeRecords(Batch<P> batch);  }
@Test public void testWriteRecord() { writer.writeRecords(new Batch<>(record1, record2)); assertThat(items).containsExactly(payload1, payload2); }