### Question:
BeanToCsv { public boolean write(MappingStrategy<T> mapper, Writer writer, List<?> objects) { return write(mapper, new CsvWriter(writer), objects); } BeanToCsv(); boolean write(MappingStrategy<T> mapper, Writer writer,
      List<?> objects); boolean write(MappingStrategy<T> mapper, CsvWriter csv,
      List<?> objects);  }### Answer:
@Test(expected = RuntimeException.class) public void throwRuntimeExceptionWhenExceptionIsThrown() { StringWriter sw = new StringWriter(); CsvWriter writer = new CsvWriter(sw); bean.write(createErrorMappingStrategy(), writer, testData); }
@Test public void beanReturnsFalseOnEmptyList() { ColumnPositionMappingStrategy<MockBean> strat = new ColumnPositionMappingStrategy<MockBean>(); strat.setType(MockBean.class); String[] columns = new String[]{"name", "orderNumber", "num"}; strat.setColumnMapping(columns); StringWriter sw = new StringWriter(); assertFalse(bean.write(strat, sw, new ArrayList<Object>())); }
@Test public void beanReturnsFalseOnNull() { ColumnPositionMappingStrategy<MockBean> strat = new ColumnPositionMappingStrategy<MockBean>(); strat.setType(MockBean.class); String[] columns = new String[]{"name", "orderNumber", "num"}; strat.setColumnMapping(columns); StringWriter sw = new StringWriter(); assertFalse(bean.write(strat, sw, null)); }
@Test public void testWriteQuotes() throws IOException { ColumnPositionMappingStrategy<MockBean> strat = new ColumnPositionMappingStrategy<MockBean>(); strat.setType(MockBean.class); String[] columns = new String[]{"name", "orderNumber", "num"}; strat.setColumnMapping(columns); StringWriter sw = new StringWriter(); boolean value = bean.write(strat, sw, testData); Assert.assertTrue(value); String content = sw.getBuffer().toString(); Assert.assertNotNull(content); Assert.assertEquals(TEST_STRING, content); }
@Test public void testWriteNulls() throws IOException { ColumnPositionMappingStrategy<MockBean> strat = new ColumnPositionMappingStrategy<MockBean>(); strat.setType(MockBean.class); String[] columns = new String[]{"name", "orderNumber", "num"}; strat.setColumnMapping(columns); StringWriter sw = new StringWriter(); boolean value = bean.write(strat, sw, nullData); Assert.assertTrue(value); String content = sw.getBuffer().toString(); Assert.assertNotNull(content); Assert.assertEquals(NULL_TEST_STRING, content); }