### Question:
QueryResultRows extends AbstractIterator<List<Object>> implements Iterable<List<Object>> { public static Builder queryResultRowsBuilder(Session session) { return new Builder(session); } private  QueryResultRows(Session session, Optional<List<ColumnAndType>> columns, List<Page> pages, Consumer<Throwable> exceptionConsumer); boolean isEmpty(); Optional<List<Column>> getColumns(); @VisibleForTesting long getTotalRowsCount(); Optional<Long> getUpdateCount(); @Override Iterator<List<Object>> iterator(); @Override String toString(); static QueryResultRows empty(Session session); static Builder queryResultRowsBuilder(Session session);  }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "columns and types size mismatch") public void shouldThrowWhenColumnsAndTypesSizeMismatch() { List<Column> columns = ImmutableList.of(INT_COLUMN.apply("_col0")); List<Type> types = ImmutableList.of(IntegerType.INTEGER, BooleanType.BOOLEAN); List<Page> pages = rowPagesBuilder(types) .row(0, null) .build(); queryResultRowsBuilder(getSession()) .addPages(pages) .withColumnsAndTypes(columns, types) .build(); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "columns and types must be present at the same time") public void shouldThrowWhenColumnsAreNull() { List<Type> types = ImmutableList.of(IntegerType.INTEGER, BooleanType.BOOLEAN); List<Page> pages = rowPagesBuilder(types) .row(0, null) .build(); queryResultRowsBuilder(getSession()) .addPages(pages) .withColumnsAndTypes(null, types) .build(); }
@Test public void shouldAcceptNullColumnsAndTypes() { queryResultRowsBuilder(getSession()) .withColumnsAndTypes(null, null) .build(); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "columns and types must be present at the same time") public void shouldThrowWhenTypesAreNull() { List<Column> columns = ImmutableList.of(INT_COLUMN.apply("_col0")); List<Type> types = ImmutableList.of(IntegerType.INTEGER, BooleanType.BOOLEAN); List<Page> pages = rowPagesBuilder(types) .row(0, null) .build(); queryResultRowsBuilder(getSession()) .addPages(pages) .withColumnsAndTypes(columns, null) .build(); }
@Test(expectedExceptions = VerifyException.class, expectedExceptionsMessageRegExp = "data present without columns and types") public void shouldThrowWhenDataIsPresentWithoutColumns() { List<Page> pages = rowPagesBuilder(ImmutableList.of(IntegerType.INTEGER, BooleanType.BOOLEAN)) .row(0, null) .build(); queryResultRowsBuilder(getSession()) .addPages(pages) .build(); }