SELF - the "self" type of this assertion class.ELEMENT - the type of elements.public abstract class AbstractIteratorAssert<SELF extends AbstractIteratorAssert<SELF,ELEMENT>,ELEMENT> extends AbstractAssert<SELF,Iterator<? extends ELEMENT>>
Base class for all implementations of assertions for Iterators.
Note that none of the assertions modify the actual iterator, i.e. they do not consume any elements.
In order to use consuming assertions, use toIterable().
actual, info, myself, throwUnsupportedExceptionOnEquals| Constructor and Description |
|---|
AbstractIteratorAssert(Iterator<? extends ELEMENT> actual,
Class<?> selfType)
Creates a new
. |
| Modifier and Type | Method and Description |
|---|---|
SELF |
hasNext()
Verifies that the actual
Iterator has at least one more element. |
SELF |
isExhausted()
Verifies that the actual
Iterator has no more elements. |
IterableAssert<ELEMENT> |
toIterable()
Creates a new
IterableAssert from this IteratorAssert which allows for
using any Iterable assertions like IterableAssert.contains(Object[]). |
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnErrorpublic AbstractIteratorAssert(Iterator<? extends ELEMENT> actual, Class<?> selfType)
AbstractIteratorAssert.actual - the actual value to verifyselfType - the "self type"public SELF hasNext()
Verifies that the actual Iterator has at least one more element.
Iterator<TolkienCharacter> elvesRingBearers = list(galadriel, elrond, gandalf).iterator();
assertThat(elvesRingBearers).hasNext();AssertionError - if the actual Iterator is null or does not have another element.public SELF isExhausted()
Verifies that the actual Iterator has no more elements.
Iterator<String> result = Collections.emptyList().iterator();
assertThat(result).isExhausted();AssertionError - if the actual Iterator is null or has another element.public IterableAssert<ELEMENT> toIterable()
Creates a new IterableAssert from this IteratorAssert which allows for
using any Iterable assertions like IterableAssert.contains(Object[]).
Iterator<String> bestBasketBallPlayers = getBestBasketBallPlayers();
assertThat(bestBasketBallPlayers).toIterable().contains("Jordan", "Magic", "Lebron");IterableAssert.Copyright © 2014–2019 AssertJ. All rights reserved.