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
Iterator
s.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) Iterators
iterators
-
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 SELF
hasNext()
Verifies that the actualIterator
has at least one more element.SELF
isExhausted()
Verifies that the actualIterator
has no more elements.IterableAssert<ELEMENT>
toIterable()
Creates a newIterableAssert
from thisIteratorAssert
which allows for using any Iterable assertions likeIterableAssert.contains(Object[])
.-
Methods inherited from class org.assertj.core.api.AbstractAssert
asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withAssertionState, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.api.Descriptable
as, as, describedAs
-
-
-
-
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:Iterator
has at least one more element.Iterator<TolkienCharacter> elvesRingBearers = list(galadriel, elrond, gandalf).iterator(); assertThat(elvesRingBearers).hasNext();
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualIterator
isnull
or does not have another element.- Since:
- 3.12.0
-
isExhausted
public SELF isExhausted()
Verifies that the actual
Example:Iterator
has no more elements.Iterator<String> result = Collections.emptyList().iterator(); assertThat(result).isExhausted();
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualIterator
isnull
or has another element.- Since:
- 3.12.0
-
toIterable
public IterableAssert<ELEMENT> toIterable()
Creates a new
Example:IterableAssert
from thisIteratorAssert
which 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
-
-