### Question:
FileWritingRecordsHandler implements ConsumerRecordsHandler<String, String> { @Override public void process(final ConsumerRecords<String, String> consumerRecords) { final List<String> valueList = new ArrayList<>(); consumerRecords.forEach(record -> valueList.add(record.value())); if (!valueList.isEmpty()) { try { Files.write(path, valueList, StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.APPEND); } catch (IOException e) { throw new RuntimeException(e); } } } FileWritingRecordsHandler(final Path path); @Override void process(final ConsumerRecords<String, String> consumerRecords);  }### Answer:
@Test public void testProcess() throws IOException { final Path tempFilePath = Files.createTempFile("test-handler", ".out"); try { final ConsumerRecordsHandler<String, String> recordsHandler = new FileWritingRecordsHandler(tempFilePath); recordsHandler.process(createConsumerRecords()); final List<String> expectedWords = Arrays.asList("it's but", "a flesh wound", "come back"); List<String> actualRecords = Files.readAllLines(tempFilePath); assertThat(actualRecords, equalTo(expectedWords)); } finally { Files.deleteIfExists(tempFilePath); } }