RowStructureLoader { public static RowStructure loadRowStructure(final Parse headerRow) { Parse headerCell = headerRow.parts; int colNum = headerRow.parts.size(); String[] columnNames = new String[colNum]; boolean[] keyProperties = new boolean[colNum]; for (int i = 0; i < colNum; i++) { loadColumnStructure(headerCell, i, columnNames, keyProperties); headerCell = headerCell.more; } return new RowStructure(columnNames, keyProperties); }  static RowStructure loadRowStructure(final Parse headerRow);  }
@Test public void shouldLoadFromParseColumnNames() { Parse row = createRowParse("col1", "col2?", "col3"); RowStructure rs = RowStructureLoader.loadRowStructure(row); assertThat(rs.getColumnNames(), is(new String[] { "col1", "col2", "col3" })); }
@Test public void shouldLoadFromParseKeyPropertiesNames() { Parse row = createRowParse("col1", "col2?", "col3"); RowStructure rs = RowStructureLoader.loadRowStructure(row); assertThat(rs.getKeyProperties(), is(new boolean[] { true, false, true })); }
@Test(expected = UnsupportedOperationException.class) public void shouldRaiseExceptionOnEmptyColumnName() { Parse row = createRowParse("col1", "col2?", ""); RowStructureLoader.loadRowStructure(row); }
@Test(expected = UnsupportedOperationException.class) public void shouldRaiseExceptionOnNullColumnName() { Parse row = createRowParse("col1", null, "col3"); RowStructureLoader.loadRowStructure(row); }