### Question:
ColumnCopier extends RowTransformation { @Override public Row execute(Row row) { if (row == null) { return null; } List<Column> columnsToCopy = columnMappings.keySet().stream(). filter(f -> row.getColumnByName(f) != null). map(m -> row.getColumnByName(m)). collect(Collectors.toList()); columnsToCopy.forEach(c -> copyColumn(row, c, columnMappings.get(c.getName()))); return row; } ColumnCopier(Map<String, NameList> columnMappings);  ColumnCopier(); void addMapping(String columnName, List<String> targetNames); void addMapping(String columnName, String... targetNames); @Override Row execute(Row row); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test public void executeWithExistingMappings() { this.cut.columnMappings.put("duke", new ColumnCopier.NameList(Arrays.asList("java", "javaee"))); Row row = new Row(); row.addColumn(new Column(0, "duke", "42")); Row withCopiedColumns = this.cut.execute(row); assertFalse(withCopiedColumns.isEmpty()); assertThat(withCopiedColumns.getColumns().size(), is(3)); Column javaColumn = row.getColumnByName("java"); assertNotNull(javaColumn); Column javaeeColumn = row.getColumnByName("javaee"); assertNotNull(javaeeColumn); }
@Test public void executeWithoutMappings() { Row row = new Row(); row.addColumn(new Column(0, "duke", "42")); Row withCopiedColumns = this.cut.execute(row); assertFalse(withCopiedColumns.isEmpty()); assertThat(withCopiedColumns.getColumns().size(), is(1)); }
@Test public void executeEmptyRowWithMappings() { this.cut.columnMappings.put("duke", new ColumnCopier.NameList(Arrays.asList("java", "javaee"))); Row row = new Row(); Row withCopiedColumns = this.cut.execute(row); assertTrue(withCopiedColumns.isEmpty()); }