public void writeHeader() {
        Validate.validState(writer != null, "No writer set! Call setWriter() first!");
        StringBuilder row = new StringBuilder();
        for (int i = 0; i < columnCount; i++) {
            row.append(metadata.getColumnName(i));
            if (i < columnCount - 1) {
                row.append(separator);
            }
        }
        writer.println(row.toString());
    }
@Test
    public void testCsvSampleWriterConstructorWithWriter() throws Exception {
        try (Writer writer = new StringWriter();
             CsvSampleWriter csvWriter = new CsvSampleWriter(writer, metadata)) {
            csvWriter.writeHeader();
            csvWriter.flush();
            assertEquals("a,b" + LINE_SEP, writer.toString());
        }
    }