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 inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractIteratorAssert
(Iterator<? extends ELEMENT> actual, Class<?> selfType) Creates a new
.AbstractIteratorAssert
-
Method Summary
Modifier and TypeMethodDescriptionhasNext()
Verifies that the actualIterator
has at least one more element.Verifies that the actualIterator
has no more elements.Creates a newIterableAssert
from thisIteratorAssert
which allows for using any Iterable assertions likeAbstractIterableAssert.contains(Object[])
.Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, 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, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, 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, as, describedAs
-
Constructor Details
-
AbstractIteratorAssert
Creates a new
.AbstractIteratorAssert
- Parameters:
actual
- the actual value to verifyselfType
- the "self type"
-
-
Method Details
-
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
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
Creates a new
Example:IterableAssert
from thisIteratorAssert
which allows for using any Iterable assertions likeAbstractIterableAssert.contains(Object[])
.Iterator<String> bestBasketBallPlayers = getBestBasketBallPlayers(); assertThat(bestBasketBallPlayers).toIterable().contains("Jordan", "Magic", "Lebron");
- Returns:
- the new
IterableAssert
. - Since:
- 3.12.0
-