@Test public void whenIterateSixTimesThenNextThrowException() { final int countIter = 6; for (int iter = 0; iter < countIter; iter++) { convertedIterator.next(); } try { convertedIterator.next(); } catch (NoSuchElementException nee) { assertThat(nee.getMessage(), is("No numbers in iterators.")); } }
@Override public Integer next() { Integer result; if (currentIterator.hasNext()) { result = currentIterator.next(); } else if (iterators.hasNext()) { currentIterator = iterators.next(); result = currentIterator.next(); } else { throw new NoSuchElementException("No numbers in iterators."); } return result; }
ConverterIterator implements Iterator<Integer>, Converter { @Override public Integer next() { Integer result; if (currentIterator.hasNext()) { result = currentIterator.next(); } else if (iterators.hasNext()) { currentIterator = iterators.next(); result = currentIterator.next(); } else { throw new NoSuchElementException("No numbers in iterators."); } return result; } }
ConverterIterator implements Iterator<Integer>, Converter { @Override public Integer next() { Integer result; if (currentIterator.hasNext()) { result = currentIterator.next(); } else if (iterators.hasNext()) { currentIterator = iterators.next(); result = currentIterator.next(); } else { throw new NoSuchElementException("No numbers in iterators."); } return result; }  }
ConverterIterator implements Iterator<Integer>, Converter { @Override public Integer next() { Integer result; if (currentIterator.hasNext()) { result = currentIterator.next(); } else if (iterators.hasNext()) { currentIterator = iterators.next(); result = currentIterator.next(); } else { throw new NoSuchElementException("No numbers in iterators."); } return result; }  @Override Iterator<Integer> convert(Iterator<Iterator<Integer>> it); @Override boolean hasNext(); @Override Integer next(); }
ConverterIterator implements Iterator<Integer>, Converter { @Override public Integer next() { Integer result; if (currentIterator.hasNext()) { result = currentIterator.next(); } else if (iterators.hasNext()) { currentIterator = iterators.next(); result = currentIterator.next(); } else { throw new NoSuchElementException("No numbers in iterators."); } return result; }  @Override Iterator<Integer> convert(Iterator<Iterator<Integer>> it); @Override boolean hasNext(); @Override Integer next();  }