### Question:
MappedIterator implements Iterator<T> { public T next() { return function.call(iterator.next()); } MappedIterator(Iterator<? extends S> iterator, UnaryFunction<? super S, ? extends T> mapper); boolean hasNext(); T next(); void remove(); @Override String toString();  }### Answer:
@Test public void shouldMapTheValuesOfTheDelegateIteratorUsingTheSuppliedMapFunction() { Iterator<Integer> delegateIterator = iterableWith(1, 2, 3).iterator(); MappedIterator<Integer, String> iterator = new MappedIterator<Integer, String>( delegateIterator, stringValueMapFunction()); assertThat(iterator.next(), is("1")); assertThat(iterator.next(), is("2")); assertThat(iterator.next(), is("3")); }
@Test(expected = NoSuchElementException.class) public void shouldThrowANoSuchElementExceptionIfNoMoreElements() { Iterator<Integer> delegateIterator = iterableWith(1, 2, 3).iterator(); MappedIterator<Integer, String> iterator = new MappedIterator<Integer, String>( delegateIterator, stringValueMapFunction()); iterator.next(); iterator.next(); iterator.next(); iterator.next(); }