CSVResult { public List<String> getLines() { return lines; } CSVResult(List<String> headers, List<String> lines);  CSVResult(String separator, List<String> headers, List<List<String>> lines); List<String> getHeaders(); List<String> getLines();  }
@Test public void getLinesShouldReturnLinesSanitized() { CSVResult csv = csv( headers("name", "city"), lines( line("John", "Seattle"), line("John", "=Seattle"), line("John", "+Seattle"), line("-John", "Seattle"), line("@John", "Seattle"), line("John", "Seattle=") ) ); assertEquals( line( "John,Seattle", "John,'=Seattle", "John,'+Seattle", "'-John,Seattle", "'@John,Seattle", "John,Seattle=" ), csv.getLines() ); }
@Test public void getLinesShouldReturnLinesQuotedIfRequired() { CSVResult csv = csv(headers("name", "age"), lines(line("John,Smith", "30,,,"))); assertEquals( line("\"John,Smith\",\"30,,,\""), csv.getLines() ); }
@Test public void getLinesShouldReturnLinesBothSanitizedAndQuotedIfRequired() { CSVResult csv = csv( headers("name", "city"), lines( line("John", "Seattle"), line("John", "=Seattle"), line("John", "+Sea,ttle"), line(",-John", "Seattle"), line(",,,@John", "Seattle"), line("John", "Seattle=") ) ); assertEquals( line( "John,Seattle", "John,'=Seattle", "John,\"'+Sea,ttle\"", "\",-John\",Seattle", "\",,,@John\",Seattle", "John,Seattle=" ), csv.getLines() ); }