CSVFileOutputWriter implements OutputWriter { @Override public void writeFailure(ContentItem contentItem, String error, int attempts) { StringBuilder result = new StringBuilder(); result.append(FAILURE).append(","); result.append(contentItem.getSpaceId()).append(","); result.append(quote(contentItem.getContentId())).append(","); result.append("none").append(","); result.append(quote(error)).append(","); result.append(attempts).append(","); result.append(DATE_FORMAT.format(new Date())); writer.println(result.toString()); writer.flush(); } CSVFileOutputWriter(File workDir); @Override void writeSuccess(ContentItem contentItem,
                             String localFilePath,
                             int attempts); @Override void writeFailure(ContentItem contentItem,
                             String error,
                             int attempts); @Override void close();  }
@Test public void testWriteFailure() throws Exception { OutputWriter writer = new CSVFileOutputWriter(tempDir); File outputFile = getOutputFile(); String spaceId = "failureSpaceId"; String contentId = "failureContentId"; String errorText = "error text"; writer.writeFailure(new ContentItem(spaceId, contentId), errorText, 1); String outputFileContent = FileUtils.readFileToString(outputFile); assertTrue(outputFileContent.contains(CSVFileOutputWriter.FAILURE)); assertTrue(outputFileContent.contains(spaceId)); assertTrue(outputFileContent.contains(contentId)); assertTrue(outputFileContent.contains(errorText)); writer.close(); }