### Question:
CSVMessageBodyWriter implements MessageBodyWriter<Object> { @Override public void writeTo(Object o, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream) throws IOException { Writer out = new OutputStreamWriter(entityStream, StandardCharsets.UTF_8); if (Iterable.class.isAssignableFrom(type)) { for (Object row : (Iterable<?>) o) { out.append(toCSV(row)).append('\n'); } } else { out.append(toCSV(o)).append('\n'); } out.flush(); }  @Override boolean isWriteable(Class<?> type,
                             Type genericType,
                             Annotation[] annotations,
                             MediaType mediaType); @Override long getSize(Object o,
                      Class<?> type,
                      Type genericType,
                      Annotation[] annotations,
                      MediaType mediaType); @Override void writeTo(Object o,
                      Class<?> type,
                      Type genericType,
                      Annotation[] annotations,
                      MediaType mediaType,
                      MultivaluedMap<String,Object> httpHeaders,
                      OutputStream entityStream);  }### Answer:
@Test public void testWrite() throws Exception { CSVMessageBodyWriter writer = new CSVMessageBodyWriter(); HasCSV foo = () -> "foo"; ByteArrayOutputStream out = new ByteArrayOutputStream(); writer.writeTo(foo, HasCSV.class, null, null, TEXT_CSV_TYPE, null, out); out.close(); assertEquals("foo\n", new String(out.toByteArray(), StandardCharsets.UTF_8)); HasCSV bar = () -> "bar"; ByteArrayOutputStream multiOut = new ByteArrayOutputStream(); writer.writeTo(Arrays.asList(foo, bar), Iterable.class, null, null, TEXT_CSV_TYPE, null, multiOut); multiOut.close(); assertEquals("foo\nbar\n", new String(multiOut.toByteArray(), StandardCharsets.UTF_8)); }