### Question:
CsvPrinter implements OutputPrinter { @Override public void finish() throws IOException { printRows(ImmutableList.of(), true); writer.flush(); checkError(); } CsvPrinter(List<String> fieldNames, Writer writer, CsvOutputFormat csvOutputFormat); @Override void printRows(List<List<?>> rows, boolean complete); @Override void finish();  }### Answer:
@Test public void testCsvPrintingNoRows() throws Exception { StringWriter writer = new StringWriter(); List<String> fieldNames = ImmutableList.of("first", "last"); OutputPrinter printer = new CsvPrinter(fieldNames, writer, STANDARD); printer.finish(); assertEquals(writer.getBuffer().toString(), "\"first\",\"last\"\n"); }
@Test public void testCsvPrintingNoRowsWithoutQuotes() throws Exception { StringWriter writer = new StringWriter(); List<String> fieldNames = ImmutableList.of("first", "last"); OutputPrinter printer = new CsvPrinter(fieldNames, writer, NO_QUOTES); printer.finish(); assertEquals(writer.getBuffer().toString(), "first,last\n"); }
@Test public void testCsvPrintingNoRowsWithNoHeaderAndWithoutQuotes() throws Exception { StringWriter writer = new StringWriter(); List<String> fieldNames = ImmutableList.of("first", "last", "quantity"); OutputPrinter printer = new CsvPrinter(fieldNames, writer, NO_HEADER_AND_QUOTES); printer.finish(); String expected = ""; assertEquals(writer.getBuffer().toString(), expected); }