public void testIteratorConstructorIteration_WithEmptyIterators() { List iteratorList = new ArrayList(); iteratorList.add(IteratorUtils.EMPTY_ITERATOR); iteratorList.add(list1.iterator()); iteratorList.add(IteratorUtils.EMPTY_ITERATOR); iteratorList.add(list2.iterator()); iteratorList.add(IteratorUtils.EMPTY_ITERATOR); iteratorList.add(list3.iterator()); iteratorList.add(IteratorUtils.EMPTY_ITERATOR); Iterator it = new ObjectGraphIterator(iteratorList.iterator()); for (int i = 0; i < 6; i++) { assertEquals(true, it.hasNext()); assertEquals(testArray[i], it.next()); } assertEquals(false, it.hasNext()); try { it.next(); fail(); } catch (NoSuchElementException ex) { } }
public void testIteration_IteratorOfIteratorsWithEmptyIterators() { List iteratorList = new ArrayList(); iteratorList.add(IteratorUtils.EMPTY_ITERATOR); iteratorList.add(list1.iterator()); iteratorList.add(IteratorUtils.EMPTY_ITERATOR); iteratorList.add(list2.iterator()); iteratorList.add(IteratorUtils.EMPTY_ITERATOR); iteratorList.add(list3.iterator()); iteratorList.add(IteratorUtils.EMPTY_ITERATOR); Iterator it = new ObjectGraphIterator(iteratorList.iterator(), null); for (int i = 0; i < 6; i++) { assertEquals(true, it.hasNext()); assertEquals(testArray[i], it.next()); } assertEquals(false, it.hasNext()); }
/** * Returns an <code>Iterator</code> that does not support modification * of the heap. */ @Override public Iterator<T> iterator() { return IteratorUtils.<T>unmodifiableIterator(heap.iterator()); }