### Question:
ResultSetIterator implements RelationalInput { @Override public List<String> next() throws InputIterationException { if (!nextCalled) { try { resultSet.next(); } catch (SQLException e) { throw new InputIterationException("Could not retrieve next row", e); } } nextCalled = false; List<String> resultRow = new ArrayList<>(); for (int columnIndex = 0; columnIndex < numberOfColumns; columnIndex++) { try { resultRow.add(resultSet.getString(columnIndex + 1)); } catch (SQLException e) { throw new InputIterationException("Could not retrieve values from result set", e); } } return resultRow; } ResultSetIterator(ResultSet resultSet);  ResultSetIterator(ResultSet resultSet, String relationName); @Override boolean hasNext(); @Override List<String> next(); @Override int numberOfColumns(); @Override String relationName(); @Override ImmutableList<String> columnNames(); @Override void close(); static final String UNKNOWN_RELATION_NAME; }### Answer:
@Test public void testNext() throws SQLException, InputIterationException { ResultSet resultSet = twoLinesResultSetFixture.getTestData(); ResultSetIterator resultSetIterator = new ResultSetIterator(resultSet); List<Boolean> expectedNextValues = twoLinesResultSetFixture.getExpectedNextValues(); List<ImmutableList<String>> expectedRecords = twoLinesResultSetFixture.getExpectedRecords(); for (int i = 0; i < twoLinesResultSetFixture.numberOfRows(); i++) { assertEquals(expectedNextValues.get(i), resultSetIterator.hasNext()); assertEquals(expectedRecords.get(i), resultSetIterator.next()); } assertEquals(expectedNextValues.get(twoLinesResultSetFixture.numberOfRows()), resultSetIterator.hasNext()); verify(resultSet, times(3)).next(); }
@Test public void testNextWithoutHasNext() throws SQLException, InputIterationException { ResultSet resultSet = twoLinesResultSetFixture.getTestData(); ResultSetIterator resultSetIterator = new ResultSetIterator(resultSet); List<ImmutableList<String>> expectedRecords = twoLinesResultSetFixture.getExpectedRecords(); for (int i = 0; i < twoLinesResultSetFixture.numberOfRows(); i++) { assertEquals(expectedRecords.get(i), resultSetIterator.next()); } verify(resultSet, times(2)).next(); }