### Question:
IndexMapper extends RowTransformation { @Override public Row execute(Row row) { if (row == null) { return null; } row.getColumns().stream().forEach(col -> col.setIndex(-1)); this.orderedNames.stream(). filter(f -> orderedNames.contains(f)). forEach(e -> setIndex(row.getColumnByName(e), orderedNames.indexOf(e))); row.reindexColumns(); return row; } IndexMapper(); @Override Row execute(Row row);  }### Answer:
@Test public void testExecuteReIndexColumns() { indexMapper.orderedNames = new ArrayList<String>() {{ add("name"); add("age"); add("weight"); add("height");}}; Row actualRow = indexMapper.execute(row); assertEquals(0, actualRow.getColumnByName("name").getIndex()); assertEquals(1, actualRow.getColumnByName("age").getIndex()); assertEquals(2, actualRow.getColumnByName("weight").getIndex()); assertEquals(3, actualRow.getColumnByName("height").getIndex()); assertEquals(-1, actualRow.getColumnByName("resetIndexOne").getIndex()); assertEquals(-1, actualRow.getColumnByName("resetIndexTwo").getIndex()); Column nameColumn = actualRow.getColumnByIndex(0); assertEquals(0, nameColumn.getIndex()); Column ageColumn = actualRow.getColumnByIndex(1); assertEquals(1, ageColumn.getIndex()); Column weightColumn = actualRow.getColumnByIndex(2); assertEquals(2, weightColumn.getIndex()); Column heightColumn = actualRow.getColumnByIndex(3); assertEquals(3, heightColumn.getIndex()); Column columnByIndex = actualRow.getColumnByIndex(-1); }