Package com.atlassian.bamboo.utils
Class MemorisingIterable<T>
- java.lang.Object
-
- com.atlassian.bamboo.utils.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 generatesMemorisingIterable.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)); }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MemorisingIterable.MemorisingIterator<T>
Iterator which memorises all traversed elements.
-
Constructor Summary
Constructors Constructor Description MemorisingIterable(@NotNull Iterable<T> iterable)
Creates new instance of theMemorisingIterable
backed by the giveniterable
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull List<MemorisingIterable.MemorisingIterator<T>>
getGeneratedIterators()
Returns a list of all iterators created by callingIterable.iterator()
on this object.@NotNull Iterator<T>
iterator()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
MemorisingIterable
public MemorisingIterable(@NotNull @NotNull Iterable<T> iterable)
Creates new instance of theMemorisingIterable
backed by the giveniterable
.
-
-
Method Detail
-
getGeneratedIterators
@NotNull public @NotNull List<MemorisingIterable.MemorisingIterator<T>> getGeneratedIterators()
Returns a list of all iterators created by callingIterable.iterator()
on this object.
-
-