TupleIterator implements CloseableIterator<ITuple> { @Override public ITuple next() { if (isClosed) { throw new NoSuchElementException("Iterator has already been closed"); } if (next == null) { prepareNext(); } ITuple result = next; next = null; if (!hasNext()) { close(); } if (result == null) { throw new NoSuchElementException(); } return result; } TupleIterator(Connection connection, IRdbRelation relation); @Override boolean hasNext(); @Override ITuple next(); @Override void remove(); @Override void close();  }
@Test public void testNext() { ITuple tuple = iterator.next(); Assert.assertNotNull(tuple); Assert.assertEquals(2, tuple.size()); Assert.assertEquals(TupleIteratorTest.tuple, tuple); Assert.assertFalse(iterator.hasNext()); }
@Test(expected=NoSuchElementException.class) public void testIllegalNext() { iterator.next(); iterator.next(); }
@Test(expected = NoSuchElementException.class) public void testNextOnEmptyRelation() { CloseableIterator<ITuple> iterator = emptyRelation.iterator(); iterator.next(); }