BackupCursors implements Iterator<BackupCursors.CursorAndType> { @Override public CursorAndType next() { if (cursorAndTypes.isEmpty()) throw new NoSuchElementException(); if (getCurrent().hasNext()) { getCurrentCursor().moveToNext(); } else if (getNextNonEmptyIndex() != -1) { index = getNextNonEmptyIndex(); getCurrentCursor().moveToFirst(); } else { throw new NoSuchElementException(); } return getCurrent(); } BackupCursors(); int count(); int count(DataType type); @Override boolean hasNext(); @Override CursorAndType next(); @Override void remove(); void close();  }
@Test(expected = NoSuchElementException.class) public void testEmptyCursorShouldThrowNoSuchElementException() { BackupCursors empty = new BackupCursors(); empty.next(); }