Class MemorisingIterable<T>

  • Type Parameters:
    T - type of elements returned by this iterable
    All Implemented Interfaces:
    Iterable<T>

    public class MemorisingIterable<T>
    extends Object
    implements Iterable<T>
    Iterable which memorises all generated iterators so that test assertions can be performed. This iterable type generates MemorisingIterable.MemorisingIterator instances, so further data traversal analysis is possible.

    Example usage:

    
     public void testMyFunction() {
         // provided
         final MemorisingIterable<Integer> data = new MemorisingIterable<>(Arrays.asList(1, 2, 3, 4, 5));
    
         // when
         callMyFunction(data);
    
         // then
         assertThat(data.getGeneratedIterators(), hasSize(1));
         assertThat(data.getGeneratedIterators().get(0).getTraversedElements(), contains(1, 2, 3));
     }