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 inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractIteratorAssert(Iterator<? extends ELEMENT> actual, Class<?> selfType) Creates a new.AbstractIteratorAssert -
Method Summary
Modifier and TypeMethodDescriptionhasNext()Verifies that the actualIteratorhas at least one more element.Verifies that the actualIteratorhas no more elements.Verifies that the actual iterator is unmodifiable, i.e., throws anUnsupportedOperationExceptionwith any attempt to remove from the iterator.Creates a newIterableAssertfrom thisIteratorAssertwhich allows for using any Iterable assertions likeAbstractIterableAssert.contains(Object[]).Methods inherited from class org.assertj.core.api.AbstractAssert
actual, areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, 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, usingEquals, usingEquals, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs, 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: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
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
Creates a new
Example:IterableAssertfrom thisIteratorAssertwhich 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
-
isUnmodifiable
Verifies that the actual iterator is unmodifiable, i.e., throws anUnsupportedOperationExceptionwith any attempt to remove from the iterator.Example:
// assertions will pass assertThat(List.of().iterator()).isUnmodifiable(); assertThat(Set.of().iterator()).isUnmodifiable(); // assertions will fail assertThat(new ArrayList<>().iterator()).isUnmodifiable(); assertThat(new HashSet<>().iterator()).isUnmodifiable();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual iterator is modifiable.- Since:
- 3.26.0
-