### Question:
LocalDocumentItemWriter implements DocumentItemWriter { @Override public void write(Document document) { try { bufferedWriter.write(json.writeValueAsString(document)); bufferedWriter.newLine(); if (firstDocument == null) firstDocument = document; lastDocument = document; } catch (IOException e) { throw new UncheckedIOException(e); } } LocalDocumentItemWriter(File outFile, ItemWriterListener itemWriterListener); @Override void write(Document document); @Override void revert(); @Override void close();  }### Answer:
@Test public void testWrite() throws Exception { itemWriterListener.onCompleted( cmp(new WriteCompletedEvent(outFile, DOCUMENT, DOCUMENT3), writeCompletedEventEqualityComparator(), EQUAL)); expectLastCall(); replayAll(); localDocumentItemWriter.write(DOCUMENT); localDocumentItemWriter.write(DOCUMENT2); localDocumentItemWriter.write(DOCUMENT3); localDocumentItemWriter.close(); List<Document> documentList = readBack(outFile); assertThat(documentList.size(), is(3)); assertThat(documentList.get(0).getString("id"), is(DOCUMENT.getString("id"))); assertThat(documentList.get(1).getString("id"), is(DOCUMENT2.getString("id"))); assertThat(documentList.get(2).getString("id"), is(DOCUMENT3.getString("id"))); }