Ejemplo n.º 1
0
 @Test(expected = IllegalStateException.class)
 public void shouldRequireNextOnCursorToBeCalledBeforeGettingValueUsingColumnName() {
   results = new QueryResults(columns, statistics, tuples, context.getProblems(), null);
   Cursor cursor = results.getCursor();
   assertThat(cursor.hasNext(), is(true));
   cursor.getValue("colA");
 }
Ejemplo n.º 2
0
 @Test
 public void shouldReturnCursorThatAccessesTuples() {
   results = new QueryResults(columns, statistics, tuples, context.getProblems(), null);
   Cursor cursor = results.getCursor();
   Iterator<Object[]> expectedIter = tuples.iterator();
   int rowNumber = 0;
   while (cursor.hasNext() && expectedIter.hasNext()) {
     cursor.next();
     Object[] tuple = expectedIter.next();
     // Check the column values by column name and index ...
     for (Column column : results.getColumns().getColumns()) {
       String columnName = column.getColumnName();
       int columnIndex = columns.getColumnIndexForName(columnName);
       assertThat(cursor.getValue(columnName), is(tuple[columnIndex]));
       assertThat(cursor.getValue(columnIndex), is(tuple[columnIndex]));
       // Get the location for this column ...
       int locationIndex = columns.getLocationIndex(column.selectorName().name());
       Location location = (Location) tuple[locationIndex];
       assertThat(cursor.getLocation(columnIndex), is(location));
     }
     // Check the locations by selector name and index ...
     for (String selectorName : results.getColumns().getSelectorNames()) {
       int locationIndex = columns.getLocationIndex(selectorName);
       Location location = (Location) tuple[locationIndex];
       assertThat(cursor.getLocation(selectorName), is(location));
       assertThat(location.getPath(), is(notNullValue()));
     }
     // Check the row index ...
     assertThat(cursor.getRowIndex(), is(rowNumber++));
   }
   assertThat(cursor.hasNext(), is(false));
   assertThat(expectedIter.hasNext(), is(false));
 }