DataUtils { public static int getColumnIndex(Data data, String columnName) { List<String> columnNames = data.getColumnNames(); int firstColumnIndex = columnNames.indexOf(columnName); boolean columnExists = (firstColumnIndex != -1); if (!columnExists) { throw new IllegalArgumentException(String.format("No such column: %s", columnName)); } return firstColumnIndex; }  static int getColumnIndex(Data data, String columnName); static Object get(Data data, Row row, int columnIndex); static Object get(Data data, Row row, String columnName);  }
@Test(expected = IllegalArgumentException.class) public void testGetIndexForInvalidColumn() { getColumnIndex(createData(), "missing_column"); }
@Test public void testGetColumnIndex() { Data data = createData(); assertThat(getColumnIndex(data, "column_one"), equalTo(0)); assertThat(getColumnIndex(data, "column_two"), equalTo(1)); }