### Question:
MappedQueryResult implements QueryResult<T> { @Override public Iterator<T> iterator() { Iterator<T> transformed = Iterators.transform(rows.iterator(), row -> { T value = mapper.map(row); mapper.mappingComplete(); return value; }); mapper.mappingComplete(); return transformed; } MappedQueryResult(Iterable<Row> rows, RowMapper<T> mapper);  MappedQueryResult(ResultSet resultSet, RowMapper<T> mapper); @Override Iterator<T> iterator(); @Override List<T> list(); @Override T one(); @Override Stream<T> stream();  }### Answer:
@Test public void testIterator() { withSession(session -> { MappedQueryResult<String> resultSet = new MappedQueryResult<>(session.execute("select id, value from test"), row -> row.getString(1)); Iterator<String> iterator = resultSet.iterator(); assertEquals("one", iterator.next()); assertEquals("two", iterator.next()); assertEquals("three", iterator.next()); assertFalse(iterator.hasNext()); }); }
@Test public void testIterableOfRows() { withSession(session -> { MappedQueryResult<String> resultSet = new MappedQueryResult<>(session.execute("select id, value from test").all(), row -> row.getString(1)); Iterator<String> iterator = resultSet.iterator(); assertEquals("one", iterator.next()); assertEquals("two", iterator.next()); assertEquals("three", iterator.next()); assertFalse(iterator.hasNext()); }); }