### Question:
WriteCSVResult extends AbstractRecordSetWriter implements RecordSetWriter, RawRecordWriter { @Override public void flush() throws IOException { printer.flush(); } WriteCSVResult(final CSVFormat csvFormat, final RecordSchema recordSchema, final SchemaAccessWriter schemaWriter, final OutputStream out,
        final String dateFormat, final String timeFormat, final String timestampFormat, final boolean includeHeaderLine, final String charSet); @Override void close(); @Override void flush(); @Override Map<String, String> writeRecord(final Record record); @Override WriteResult writeRawRecord(final Record record); @Override String getMimeType();  }### Answer:
@Test public void testExtraFieldInWriteRecord() throws IOException { final CSVFormat csvFormat = CSVFormat.DEFAULT.withEscape('\\').withQuoteMode(QuoteMode.NONE).withRecordSeparator("\n"); final List<RecordField> fields = new ArrayList<>(); fields.add(new RecordField("id", RecordFieldType.STRING.getDataType())); final RecordSchema schema = new SimpleRecordSchema(fields); final Map<String, Object> values = new HashMap<>(); values.put("id", "1"); values.put("name", "John"); final Record record = new MapRecord(schema, values); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final String output; try (final WriteCSVResult writer = new WriteCSVResult(csvFormat, schema, new SchemaNameAsAttribute(), baos, RecordFieldType.DATE.getDefaultFormat(), RecordFieldType.TIME.getDefaultFormat(), RecordFieldType.TIMESTAMP.getDefaultFormat(), true, "ASCII")) { writer.beginRecordSet(); writer.write(record); writer.finishRecordSet(); writer.flush(); output = baos.toString(); } assertEquals("id\n1\n", output); }