### Question:
MappingDataCSVSupport { public MappingData fromCSVRows(List<CSVRow> rows, int headlines) { MappingData data = new MappingData(); if (rows.size()<=headlines) { throw new IllegalStateException("Row count must be > headline count:"+headlines); } int count=0; for (CSVRow row: rows) { count++; if (count<=headlines) { continue; } if (row.columns.size()!=3) { throw new IllegalStateException("column count must be 3, but is:"+row.columns.size()); } int col=0; String pattern= row.columns.get(col++).cell; String replacement= row.columns.get(col++).cell; String comment= row.columns.get(col++).cell; data.getEntries().add(new MappingEntry(pattern,replacement,comment)); } return data; }  List<CSVRow> toCSVRows(MappingData data); MappingData fromCSVRows(List<CSVRow> rows, int headlines);  }### Answer:
@Test public void from_csv_test_no_headline() { MappingData expected = new MappingData(); expected.getEntries().add(new MappingEntry("pattern1", "replacement1", "comment1")); expected.getEntries().add(new MappingEntry("pattern2", "replacement2", "comment2")); List<CSVRow> rows = new ArrayList<>(); CSVRow row1 = new CSVRow(); row1.add("pattern1"); row1.add("replacement1"); row1.add("comment1"); CSVRow row2 = new CSVRow(); row2.add("pattern2"); row2.add("replacement2"); row2.add("comment2"); rows.add(row1); rows.add(row2); MappingData result = supportToTest.fromCSVRows(rows,0); assertEquals(expected.toJSON(), result.toJSON()); }
@Test public void from_csv_test_1_headline() { MappingData expected = new MappingData(); expected.getEntries().add(new MappingEntry("pattern1", "replacement1", "comment1")); expected.getEntries().add(new MappingEntry("pattern2", "replacement2", "comment2")); List<CSVRow> rows = new ArrayList<>(); CSVRow headline = new CSVRow(); headline.add("patterns"); headline.add("replacements"); headline.add("comments"); CSVRow row1 = new CSVRow(); row1.add("pattern1"); row1.add("replacement1"); row1.add("comment1"); CSVRow row2 = new CSVRow(); row2.add("pattern2"); row2.add("replacement2"); row2.add("comment2"); rows.add(row1); rows.add(row2); MappingData result = supportToTest.fromCSVRows(rows,0); assertEquals(expected.toJSON(), result.toJSON()); }