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>
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));
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Iterator which memorises all traversed elements. -
Constructor Summary
ConstructorsConstructorDescriptionMemorisingIterable
(@NotNull Iterable<T> iterable) Creates new instance of theMemorisingIterable
backed by the giveniterable
. -
Method Summary
Modifier and TypeMethodDescription@NotNull List<MemorisingIterable.MemorisingIterator<T>>
Returns a list of all iterators created by callingIterable.iterator()
on this object.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 Details
-
MemorisingIterable
Creates new instance of theMemorisingIterable
backed by the giveniterable
.
-
-
Method Details
-
iterator
-
getGeneratedIterators
Returns a list of all iterators created by callingIterable.iterator()
on this object.
-