Package org.assertj.core.api
Class AbstractIteratorAssert<SELF extends AbstractIteratorAssert<SELF,ELEMENT>,ELEMENT>
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,Iterator<? extends ELEMENT>>
-
- org.assertj.core.api.AbstractIteratorAssert<SELF,ELEMENT>
-
- Type Parameters:
SELF- the "self" type of this assertion class.ELEMENT- the type of elements.
- All Implemented Interfaces:
Assert<SELF,Iterator<? extends ELEMENT>>,Descriptable<SELF>,ExtensionPoints<SELF,Iterator<? extends ELEMENT>>
- Direct Known Subclasses:
IteratorAssert
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().- Since:
- 3.12.0
- Author:
- Stephan Windmüller
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Iteratorsiterators-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, info, myself, objects, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description AbstractIteratorAssert(Iterator<? extends ELEMENT> actual, Class<?> selfType)Creates a new.AbstractIteratorAssert
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SELFhasNext()Verifies that the actualIteratorhas at least one more element.SELFisExhausted()Verifies that the actualIteratorhas no more elements.IterableAssert<ELEMENT>toIterable()Creates a newIterableAssertfrom thisIteratorAssertwhich allows for using any Iterable assertions likeIterableAssert.contains(Object[]).-
Methods inherited from class org.assertj.core.api.AbstractAssert
as, as, asInstanceOf, 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, withAssertionState, withFailMessage, withRepresentation, withThreadDumpOnError
-
-
-
-
Field Detail
-
iterators
Iterators iterators
-
-
Constructor Detail
-
AbstractIteratorAssert
public AbstractIteratorAssert(Iterator<? extends ELEMENT> actual, Class<?> selfType)
Creates a new.AbstractIteratorAssert- Parameters:
actual- the actual value to verifyselfType- the "self type"
-
-
Method Detail
-
hasNext
public SELF hasNext()
Verifies that the actual
Example:Iteratorhas at least one more element.Iterator<TolkienCharacter> elvesRingBearers = list(galadriel, elrond, gandalf).iterator(); assertThat(elvesRingBearers).hasNext();- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualIteratorisnullor does not have another element.- Since:
- 3.12.0
-
isExhausted
public SELF isExhausted()
Verifies that the actual
Example:Iteratorhas no more elements.Iterator<String> result = Collections.emptyList().iterator(); assertThat(result).isExhausted();- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualIteratorisnullor has another element.- Since:
- 3.12.0
-
toIterable
public IterableAssert<ELEMENT> toIterable()
Creates a new
Example:IterableAssertfrom thisIteratorAssertwhich allows for using any Iterable assertions likeIterableAssert.contains(Object[]).Iterator<String> bestBasketBallPlayers = getBestBasketBallPlayers(); assertThat(bestBasketBallPlayers).toIterable().contains("Jordan", "Magic", "Lebron");- Returns:
- the new
IterableAssert. - Since:
- 3.12.0
-
-