@Test public void to_csv_test() { MappingData data = new MappingData(); data.getEntries().add(new MappingEntry("pattern1", "replacement1", "comment1")); data.getEntries().add(new MappingEntry("pattern2", "replacement2", "comment2")); List<CSVRow> result = supportToTest.toCSVRows(data); assertEquals(3, result.size()); int row=0; CSVRow headline = result.get(row++); CSVRow row1 = result.get(row++); CSVRow row2 = result.get(row++); int col=0; assertEquals(3,headline.columns.size()); assertEquals(3,row1.columns.size()); assertEquals(3,row2.columns.size()); assertEquals("Pattern", headline.columns.get(col).cell); assertEquals("pattern1", row1.columns.get(col).cell); assertEquals("pattern2", row2.columns.get(col++).cell); assertEquals("Replacement", headline.columns.get(col).cell); assertEquals("replacement1", row1.columns.get(col).cell); assertEquals("replacement2", row2.columns.get(col++).cell); assertEquals("Comment", headline.columns.get(col).cell); assertEquals("comment1", row1.columns.get(col).cell); assertEquals("comment2", row2.columns.get(col).cell); }
public List<CSVRow> toCSVRows(MappingData data) { List<CSVRow> rows = new ArrayList<>(); CSVRow headline = new CSVRow(); rows.add(headline); headline.add("Pattern"); headline.add("Replacement"); headline.add("Comment"); for (MappingEntry entry: data.getEntries()) { CSVRow row = new CSVRow(); rows.add(row); row.add(entry.getPattern()); row.add(entry.getReplacement()); row.add(entry.getComment()); } return rows; }
MappingDataCSVSupport { public List<CSVRow> toCSVRows(MappingData data) { List<CSVRow> rows = new ArrayList<>(); CSVRow headline = new CSVRow(); rows.add(headline); headline.add("Pattern"); headline.add("Replacement"); headline.add("Comment"); for (MappingEntry entry: data.getEntries()) { CSVRow row = new CSVRow(); rows.add(row); row.add(entry.getPattern()); row.add(entry.getReplacement()); row.add(entry.getComment()); } return rows; } }
MappingDataCSVSupport { public List<CSVRow> toCSVRows(MappingData data) { List<CSVRow> rows = new ArrayList<>(); CSVRow headline = new CSVRow(); rows.add(headline); headline.add("Pattern"); headline.add("Replacement"); headline.add("Comment"); for (MappingEntry entry: data.getEntries()) { CSVRow row = new CSVRow(); rows.add(row); row.add(entry.getPattern()); row.add(entry.getReplacement()); row.add(entry.getComment()); } return rows; }  }
MappingDataCSVSupport { public List<CSVRow> toCSVRows(MappingData data) { List<CSVRow> rows = new ArrayList<>(); CSVRow headline = new CSVRow(); rows.add(headline); headline.add("Pattern"); headline.add("Replacement"); headline.add("Comment"); for (MappingEntry entry: data.getEntries()) { CSVRow row = new CSVRow(); rows.add(row); row.add(entry.getPattern()); row.add(entry.getReplacement()); row.add(entry.getComment()); } return rows; }  List<CSVRow> toCSVRows(MappingData data); MappingData fromCSVRows(List<CSVRow> rows, int headlines); }
MappingDataCSVSupport { public List<CSVRow> toCSVRows(MappingData data) { List<CSVRow> rows = new ArrayList<>(); CSVRow headline = new CSVRow(); rows.add(headline); headline.add("Pattern"); headline.add("Replacement"); headline.add("Comment"); for (MappingEntry entry: data.getEntries()) { CSVRow row = new CSVRow(); rows.add(row); row.add(entry.getPattern()); row.add(entry.getReplacement()); row.add(entry.getComment()); } return rows; }  List<CSVRow> toCSVRows(MappingData data); MappingData fromCSVRows(List<CSVRow> rows, int headlines);  }