Package org.assertj.core.internal
Class Iterables
java.lang.Object
org.assertj.core.internal.Iterables
Reusable assertions for
Iterable
s.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ComparisonStrategy
(package private) Conditions
(package private) Failures
private static final Iterables
(package private) Predicates
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate AssertionError
actualContainsSubsequence
(AssertionInfo info, Iterable<?> actual, Object[] subsequence, int index) private AssertionError
actualDoesContainSequence
(AssertionInfo info, Iterable<?> actual, Object[] sequence, int index) private AssertionError
actualDoesNotContainSequence
(AssertionInfo info, Iterable<?> actual, Object[] sequence) private AssertionError
actualDoesNotContainSubsequence
(AssertionInfo info, Iterable<?> actual, Object[] subsequence, int subsequenceIndex) private AssertionError
actualDoesNotEndWithSequence
(AssertionInfo info, Iterable<?> actual, Object[] sequence) private AssertionError
actualDoesNotStartWithSequence
(AssertionInfo info, Iterable<?> actual, Object[] sequence) private static <E> boolean
areAllConsumersSatisfied
(Queue<ElementsSatisfyingConsumer<E>> satisfiedElementsPerConsumer) private boolean
<E> void
assertAllMatch
(AssertionInfo info, Iterable<? extends E> actual, Predicate<? super E> predicate, PredicateDescription predicateDescription) <E> void
assertAllSatisfy
(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E> requirements) <E> void
assertAnyMatch
(AssertionInfo info, Iterable<? extends E> actual, Predicate<? super E> predicate, PredicateDescription predicateDescription) <E> void
assertAnySatisfy
(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E> requirements) <T> void
assertAre
(AssertionInfo info, Iterable<? extends T> actual, Condition<? super T> condition) Assert that each element of givenIterable
satisfies the given condition.<E> void
assertAreAtLeast
(AssertionInfo info, Iterable<? extends E> actual, int times, Condition<? super E> condition) Assert that there are at least n elements in the actualIterable
satisfying the given condition.<E> void
assertAreAtMost
(AssertionInfo info, Iterable<? extends E> actual, int n, Condition<? super E> condition) Assert that there are at most n elements in the actualIterable
satisfying the given condition.<E> void
assertAreExactly
(AssertionInfo info, Iterable<? extends E> actual, int times, Condition<? super E> condition) Verifies that there are exactly n elements in the actualIterable
satisfying the given condition.<E> void
assertAreNot
(AssertionInfo info, Iterable<? extends E> actual, Condition<? super E> condition) Assert that each element of givenIterable
not satisfies the given condition.void
assertContains
(AssertionInfo info, Iterable<?> actual, Object[] values) Asserts that the givenIterable
contains the given values, in any order.void
assertContainsAll
(AssertionInfo info, Iterable<?> actual, Iterable<?> other) Asserts that the givenIterable
contains all the elements of the otherIterable
, in any order.void
assertContainsAnyOf
(AssertionInfo info, Iterable<?> actual, Object[] values) Asserts that the givenIterable
contains at least one of the givenvalues
.void
assertContainsExactly
(AssertionInfo info, Iterable<?> actual, Object[] values) Asserts that the givenIterable
contains exactly the given values and nothing else, in order.void
assertContainsExactlyInAnyOrder
(AssertionInfo info, Iterable<?> actual, Object[] values) void
assertContainsNull
(AssertionInfo info, Iterable<?> actual) Asserts that the givenIterable
contains at least a null element.void
assertContainsOnly
(AssertionInfo info, Iterable<?> actual, Object[] expectedValues) Asserts that the givenIterable
contains only the given values and nothing else, in any order.void
assertContainsOnlyNulls
(AssertionInfo info, Iterable<?> actual) Asserts that the givenIterable
contains only null elements and nothing else.void
assertContainsOnlyOnce
(AssertionInfo info, Iterable<?> actual, Object[] values) Asserts that the givenIterable
contains the given values and only once.void
assertContainsSequence
(AssertionInfo info, Iterable<?> actual, Object[] sequence) Verifies that the given
contains the given sequence of objects, without any other objects between them.Iterable
void
assertContainsSubsequence
(AssertionInfo info, Iterable<?> actual, Object[] subsequence) Verifies that the given
contains the given subsequence of objects (possibly with other values between them).Iterable
void
assertDoesNotContain
(AssertionInfo info, Iterable<?> actual, Object[] values) Asserts that the givenIterable
does not contain the given values.<T> void
assertDoesNotContainAnyElementsOf
(AssertionInfo info, Iterable<? extends T> actual, Iterable<? extends T> iterable) Asserts that the givenIterable
does not contain the given values.void
assertDoesNotContainNull
(AssertionInfo info, Iterable<?> actual) Asserts that the givenIterable
does not contain null elements.void
assertDoesNotContainSequence
(AssertionInfo info, Iterable<?> actual, Object[] sequence) Verifies that the given
does not contain the given sequence of objects in order.Iterable
void
assertDoesNotContainSubsequence
(AssertionInfo info, Iterable<?> actual, Object[] subsequence) Verifies that the given
does not contain the given subsequence of objects (possibly with other values between them).Iterable
void
assertDoesNotHaveDuplicates
(AssertionInfo info, Iterable<?> actual) Asserts that the givenIterable
does not have duplicate values.<E> void
assertDoNotHave
(AssertionInfo info, Iterable<? extends E> actual, Condition<? super E> condition) Assert that each element of givenIterable
not satisfies the given condition.private void
assertElementOrder
(AssertionInfo info, Iterable<?> actual, Object[] values, List<Object> actualAsList) void
assertEmpty
(AssertionInfo info, Iterable<?> actual) Asserts that the givenIterable
is empty.void
assertEndsWith
(AssertionInfo info, Iterable<?> actual, Object[] sequence) Verifies that the givenIterable
ends with the given sequence of objects, without any other objects between them.void
assertEndsWith
(AssertionInfo info, Iterable<?> actual, Object first, Object[] rest) Verifies that the givenIterable
ends with the given sequence of objects, without any other objects between them.private void
assertEquivalency
(AssertionInfo info, Iterable<?> actual, Object[] values, List<Object> actualAsList) <T> void
assertHasOnlyOneElementSatisfying
(AssertionInfo info, Iterable<? extends T> actual, Consumer<? super T> consumer) void
assertHasSameSizeAs
(AssertionInfo info, Iterable<?> actual, Iterable<?> other) Assert that the actualIterable
has the same size as the otherIterable
.void
assertHasSameSizeAs
(AssertionInfo info, Iterable<?> actual, Object other) Assert that the actualIterable
has the same size as the other array.void
assertHasSize
(AssertionInfo info, Iterable<?> actual, int expectedSize) Asserts that the number of elements in the givenIterable
is equal to the expected one.void
assertHasSizeBetween
(AssertionInfo info, Iterable<?> actual, int lowerBoundary, int higherBoundary) Asserts that the number of elements in the givenIterable
is between the given lower and higher boundary (inclusive).void
assertHasSizeGreaterThan
(AssertionInfo info, Iterable<?> actual, int boundary) Asserts that the number of elements in the givenIterable
is greater than the boundary.void
assertHasSizeGreaterThanOrEqualTo
(AssertionInfo info, Iterable<?> actual, int boundary) Asserts that the number of elements in the givenIterable
is greater than or equal to the boundary.void
assertHasSizeLessThan
(AssertionInfo info, Iterable<?> actual, int boundary) Asserts that the number of elements in the givenIterable
is less than the boundary.void
assertHasSizeLessThanOrEqualTo
(AssertionInfo info, Iterable<?> actual, int boundary) Asserts that the number of elements in the givenIterable
is less than or equal to the boundary.<E> void
assertHave
(AssertionInfo info, Iterable<? extends E> actual, Condition<? super E> condition) Assert that each element of givenIterable
satisfies the given condition.<E> void
assertHaveAtLeast
(AssertionInfo info, Iterable<? extends E> actual, int times, Condition<? super E> condition) An alias method ofassertAreAtLeast(AssertionInfo, Iterable, int, Condition)
to provide a richer fluent api (same logic, only error message differs).<E> void
assertHaveAtMost
(AssertionInfo info, Iterable<? extends E> actual, int times, Condition<? super E> condition) An alias method ofassertAreAtMost(AssertionInfo, Iterable, int, Condition)
to provide a richer fluent api (same logic, only error message differs).<E> void
assertHaveExactly
(AssertionInfo info, Iterable<? extends E> actual, int times, Condition<? super E> condition) An alias method ofassertAreExactly(AssertionInfo, Iterable, int, Condition)
to provide a richer fluent api (same logic, only error message differs).void
assertIsSubsetOf
(AssertionInfo info, Iterable<?> actual, Iterable<?> values) Verifies that the actualIterable
is a subset of valuesIterable
.private void
assertIterableContainsGivenValues
(Class<? extends Iterable> clazz, Iterable<?> actual, Object[] values, AssertionInfo info) <E> void
assertNoneMatch
(AssertionInfo info, Iterable<? extends E> actual, Predicate<? super E> predicate, PredicateDescription predicateDescription) <E> void
assertNoneSatisfy
(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E> restrictions) void
assertNotEmpty
(AssertionInfo info, Iterable<?> actual) Asserts that the givenIterable
is not empty.(package private) void
assertNotNull
(AssertionInfo info, Iterable<?> actual) void
assertNullOrEmpty
(AssertionInfo info, Iterable<?> actual) Asserts that the given
isIterable
null
or empty.<E> void
assertSatisfiesExactly
(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E>[] allRequirements) <E> void
assertSatisfiesExactlyInAnyOrder
(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E>[] consumers) <E> void
assertSatisfiesOnlyOnce
(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E> requirements) void
assertStartsWith
(AssertionInfo info, Iterable<?> actual, Object[] sequence) Verifies that the givenIterable
starts with the given sequence of objects, without any other objects between them.<ACTUAL_ELEMENT,
OTHER_ELEMENT>
voidassertZipSatisfy
(AssertionInfo info, Iterable<? extends ACTUAL_ELEMENT> actual, Iterable<OTHER_ELEMENT> other, BiConsumer<? super ACTUAL_ELEMENT, OTHER_ELEMENT> zipRequirements) static <T> Predicate
<T> byPassingAssertions
(Consumer<? super T> assertions) private static void
checkIsNotEmptySequence
(Object[] sequence) private static void
checkIsNotEmptySubsequence
(Object[] subsequence) private void
checkNotNullIterables
(AssertionInfo info, Iterable<?> actual, Object[] sequence) private boolean
commonCheckThatIterableAssertionSucceeds
(AssertionInfo info, Iterable<?> actual, Object[] sequence) private List
<IndexedDiff> compareOrder
(Object[] values, List<Object> actualAsList) private <E> boolean
conditionIsSatisfiedAtLeastNTimes
(Iterable<? extends E> actual, int n, Condition<? super E> condition) private <E> boolean
conditionIsSatisfiedAtMostNTimes
(Iterable<? extends E> actual, Condition<? super E> condition, int n) private <E> boolean
conditionIsSatisfiedNTimes
(Iterable<? extends E> actual, Condition<? super E> condition, int times) private boolean
containsSequenceAtGivenIndex
(List<?> actualAsList, Object[] sequence, int startingIndex) Return true if actualAsList contains exactly the given sequence at given starting index, false otherwise.private static Collection
<?> ensureActualCanBeReadMultipleTimes
(Iterable<?> actual) private static <E> Optional
<UnsatisfiedRequirement> failsRequirements
(Consumer<? super E> requirements, E element) private <E> Optional
<E> failsRestrictions
(E element, Consumer<? super E> restrictions) private <ACTUAL_ELEMENT,
OTHER_ELEMENT>
Optional<ZippedElementsShouldSatisfy.ZipSatisfyError> failsZipRequirements
(ACTUAL_ELEMENT actualElement, OTHER_ELEMENT otherElement, BiConsumer<ACTUAL_ELEMENT, OTHER_ELEMENT> zipRequirements) Comparator
<?> static Iterables
instance()
Returns the singleton instance of this class based onStandardComparisonStrategy
.private boolean
iterableContains
(Iterable<?> actual, Object value) private void
iterablesRemove
(Iterable<?> actual, Object value) private void
iterablesRemoveFirst
(Iterable<?> actual, Object value) private <E> List
<E> notSatisfyingCondition
(Iterable<? extends E> actual, Condition<? super E> condition) private static <E> Queue
<ElementsSatisfyingConsumer<E>> removeElement
(Queue<ElementsSatisfyingConsumer<E>> satisfiedElementsPerConsumer, E element) private static <E> Deque
<ElementsSatisfyingConsumer<E>> satisfiedElementsPerConsumer
(Iterable<? extends E> actual, Consumer<? super E>... consumers) private <E> List
<E> satisfiesCondition
(Iterable<? extends E> actual, Condition<? super E> condition) private AssertionError
shouldContainExactlyWithDiffAssertionError
(IterableDiff<Object> diff, Iterable<?> actual, Object[] values, AssertionInfo info) private AssertionError
shouldContainExactlyWithIndexAssertionError
(Iterable<?> actual, Object[] values, List<IndexedDiff> indexedDiffs, AssertionInfo info)
-
Field Details
-
INSTANCE
-
comparisonStrategy
-
failures
Failures failures -
conditions
Conditions conditions -
predicates
Predicates predicates
-
-
Constructor Details
-
Iterables
Iterables() -
Iterables
-
-
Method Details
-
instance
Returns the singleton instance of this class based onStandardComparisonStrategy
.- Returns:
- the singleton instance of this class based on
StandardComparisonStrategy
.
-
getComparator
-
getComparisonStrategy
-
assertNullOrEmpty
Asserts that the given
isIterable
null
or empty.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.- Throws:
AssertionError
- if the givenIterable
is notnull
*and* contains one or more elements.
-
assertEmpty
Asserts that the givenIterable
is empty.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.- Throws:
AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
is not empty.
-
assertNotEmpty
Asserts that the givenIterable
is not empty.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.- Throws:
AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
is empty.
-
assertHasSize
Asserts that the number of elements in the givenIterable
is equal to the expected one.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.expectedSize
- the expected size ofactual
.- Throws:
AssertionError
- if the givenIterable
isnull
.AssertionError
- if the number of elements in the givenIterable
is different from the expected one.
-
assertHasOnlyOneElementSatisfying
public <T> void assertHasOnlyOneElementSatisfying(AssertionInfo info, Iterable<? extends T> actual, Consumer<? super T> consumer) Asserts that the unique element of theIterable
satisfies the given assertions expressed as aConsumer
,- Type Parameters:
T
- the type of elements in actual.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.consumer
- the given requirements.- Throws:
AssertionError
- if theIterable
does not have a unique element.AssertionError
- if theIterable
's unique element does not satisfies the given assertions.
-
assertHasSizeGreaterThan
Asserts that the number of elements in the givenIterable
is greater than the boundary.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.boundary
- the given value to compare the size ofactual
to.- Throws:
AssertionError
- if the givenIterable
isnull
.AssertionError
- if the number of elements in the givenIterable
is greater than the boundary.
-
assertHasSizeGreaterThanOrEqualTo
Asserts that the number of elements in the givenIterable
is greater than or equal to the boundary.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.boundary
- the given value to compare the size ofactual
to.- Throws:
AssertionError
- if the givenIterable
isnull
.AssertionError
- if the number of elements in the givenIterable
is greater than or equal to the boundary.
-
assertHasSizeLessThan
Asserts that the number of elements in the givenIterable
is less than the boundary.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.boundary
- the given value to compare the size ofactual
to.- Throws:
AssertionError
- if the givenIterable
isnull
.AssertionError
- if the number of elements in the givenIterable
is less than the expected one.
-
assertHasSizeLessThanOrEqualTo
Asserts that the number of elements in the givenIterable
is less than or equal to the boundary.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.boundary
- the given value to compare the size ofactual
to.- Throws:
AssertionError
- if the givenIterable
isnull
.AssertionError
- if the number of elements in the givenIterable
is less than or equal to the boundary.
-
assertHasSizeBetween
public void assertHasSizeBetween(AssertionInfo info, Iterable<?> actual, int lowerBoundary, int higherBoundary) Asserts that the number of elements in the givenIterable
is between the given lower and higher boundary (inclusive).- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.lowerBoundary
- the lower boundary compared to which actual size should be greater than or equal to.higherBoundary
- the higher boundary compared to which actual size should be less than or equal to.- Throws:
AssertionError
- if the given array isnull
.AssertionError
- if the number of elements in the given array is not between the boundaries.
-
assertHasSameSizeAs
Assert that the actualIterable
has the same size as the other array.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.other
- the given array to compare.- Throws:
AssertionError
- if the actual group isnull
.AssertionError
- if the other group isnull
.AssertionError
- if actualIterable
and other array don't have the same size.
-
assertHasSameSizeAs
Assert that the actualIterable
has the same size as the otherIterable
.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.other
- the givenIterable
.- Throws:
AssertionError
- if the actual group isnull
.AssertionError
- if the other group isnull
.AssertionError
- if actual and otherIterable
don't have the same size.
-
assertContains
Asserts that the givenIterable
contains the given values, in any order.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.values
- the values that are expected to be in the givenIterable
.- Throws:
NullPointerException
- if the array of values isnull
.IllegalArgumentException
- if the array of values is empty.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not contain the given values.
-
ensureActualCanBeReadMultipleTimes
-
assertIterableContainsGivenValues
private void assertIterableContainsGivenValues(Class<? extends Iterable> clazz, Iterable<?> actual, Object[] values, AssertionInfo info) -
iterableContains
-
iterablesRemoveFirst
-
iterablesRemove
-
assertContainsOnly
Asserts that the givenIterable
contains only the given values and nothing else, in any order.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.expectedValues
- the values that are expected to be in the givenIterable
.- Throws:
NullPointerException
- if the array of values isnull
.IllegalArgumentException
- if the array of values is empty.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not contain the given values or if the givenIterable
contains values that are not in the given array.
-
assertContainsOnlyOnce
Asserts that the givenIterable
contains the given values and only once.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.values
- the values that are expected to be in the givenIterable
.- Throws:
NullPointerException
- if the array of values isnull
.IllegalArgumentException
- if the array of values is empty.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not contain the given values or if the givenIterable
contains values that are not in the given array.
-
assertContainsOnlyNulls
Asserts that the givenIterable
contains only null elements and nothing else.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.- Throws:
AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not contain at least a null element or if the givenIterable
contains values that are not null elements.
-
assertContainsSequence
Verifies that the given
contains the given sequence of objects, without any other objects between them.Iterable
- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.sequence
- the sequence of objects to look for.- Throws:
AssertionError
- if the givenIterable
isnull
.NullPointerException
- if the given sequence isnull
.IllegalArgumentException
- if the given sequence is empty.AssertionError
- if the givenIterable
does not contain the given sequence of objects.
-
assertDoesNotContainSequence
Verifies that the given
does not contain the given sequence of objects in order.Iterable
- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.sequence
- the sequence of objects to look for.- Throws:
AssertionError
- if the givenIterable
isnull
.NullPointerException
- if the given sequence isnull
.IllegalArgumentException
- if the given sequence is empty.AssertionError
- if the givenIterable
does contain the given sequence of objects.
-
assertContainsSubsequence
Verifies that the given
contains the given subsequence of objects (possibly with other values between them).Iterable
- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.subsequence
- the subsequence of objects to look for.- Throws:
AssertionError
- if the givenIterable
isnull
.NullPointerException
- if the given sequence isnull
.IllegalArgumentException
- if the given subsequence is empty.AssertionError
- if the givenIterable
does not contain the given subsequence of objects.
-
assertDoesNotContainSubsequence
public void assertDoesNotContainSubsequence(AssertionInfo info, Iterable<?> actual, Object[] subsequence) Verifies that the given
does not contain the given subsequence of objects (possibly with other values between them).Iterable
- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.subsequence
- the subsequence of objects to look for.- Throws:
AssertionError
- if the givenIterable
isnull
.NullPointerException
- if the given sequence isnull
.IllegalArgumentException
- if the given subsequence is empty.AssertionError
- if the givenIterable
contains the given subsequence of objects.
-
assertIsSubsetOf
Verifies that the actualIterable
is a subset of valuesIterable
.
Both actual and given iterable are treated as sets, therefore duplicates on either of them are ignored.- Parameters:
info
- contains information about the assertion.actual
- the actualIterable
.values
- theIterable
that should contain all actual elements.- Throws:
AssertionError
- if the actualIterable
isnull
.NullPointerException
- if the given Iterable isnull
.AssertionError
- if the actualIterable
is not subset of setIterable
-
containsSequenceAtGivenIndex
private boolean containsSequenceAtGivenIndex(List<?> actualAsList, Object[] sequence, int startingIndex) Return true if actualAsList contains exactly the given sequence at given starting index, false otherwise.- Parameters:
actualAsList
- the list to look sequence insequence
- the sequence to look forstartingIndex
- the index of actual list at which we start looking for sequence.- Returns:
- true if actualAsList contains exactly the given sequence at given starting index, false otherwise.
-
areEqual
-
actualDoesNotContainSequence
private AssertionError actualDoesNotContainSequence(AssertionInfo info, Iterable<?> actual, Object[] sequence) -
actualDoesContainSequence
private AssertionError actualDoesContainSequence(AssertionInfo info, Iterable<?> actual, Object[] sequence, int index) -
actualDoesNotContainSubsequence
private AssertionError actualDoesNotContainSubsequence(AssertionInfo info, Iterable<?> actual, Object[] subsequence, int subsequenceIndex) -
actualContainsSubsequence
private AssertionError actualContainsSubsequence(AssertionInfo info, Iterable<?> actual, Object[] subsequence, int index) -
assertDoesNotContain
Asserts that the givenIterable
does not contain the given values.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.values
- the values that are expected not to be in the givenIterable
.- Throws:
NullPointerException
- if the array of values isnull
.IllegalArgumentException
- if the array of values is empty.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
contains any of given values.
-
assertDoesNotContainAnyElementsOf
public <T> void assertDoesNotContainAnyElementsOf(AssertionInfo info, Iterable<? extends T> actual, Iterable<? extends T> iterable) Asserts that the givenIterable
does not contain the given values.- Type Parameters:
T
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.iterable
- the values that are expected not to be in the givenIterable
.- Throws:
NullPointerException
- if the array of values isnull
.IllegalArgumentException
- if the array of values is empty.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
contains any of given values.
-
assertDoesNotHaveDuplicates
Asserts that the givenIterable
does not have duplicate values.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.- Throws:
NullPointerException
- if the array of values isnull
.IllegalArgumentException
- if the array of values is empty.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
contains duplicate values.
-
assertStartsWith
Verifies that the givenIterable
starts with the given sequence of objects, without any other objects between them. Similar to
, but it also verifies that the first element in the sequence is also the first element of the givenassertContainsSequence(AssertionInfo, Iterable, Object[])
Iterable
.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.sequence
- the sequence of objects to look for.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not start with the given sequence of objects.
-
actualDoesNotStartWithSequence
private AssertionError actualDoesNotStartWithSequence(AssertionInfo info, Iterable<?> actual, Object[] sequence) -
assertEndsWith
Verifies that the givenIterable
ends with the given sequence of objects, without any other objects between them. Similar to
, but it also verifies that the last element in the sequence is also the last element of the givenassertContainsSequence(AssertionInfo, Iterable, Object[])
Iterable
.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.first
- the first element of the end sequence.rest
- the optional next elements of the end sequence.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not end with the given sequence of objects.
-
assertEndsWith
Verifies that the givenIterable
ends with the given sequence of objects, without any other objects between them. Similar to
, but it also verifies that the last element in the sequence is also the last element of the givenassertContainsSequence(AssertionInfo, Iterable, Object[])
Iterable
.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.sequence
- the sequence of objects to look for.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not end with the given sequence of objects.
-
commonCheckThatIterableAssertionSucceeds
private boolean commonCheckThatIterableAssertionSucceeds(AssertionInfo info, Iterable<?> actual, Object[] sequence) -
checkNotNullIterables
-
assertContainsNull
Asserts that the givenIterable
contains at least a null element.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.- Throws:
AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not contain at least a null element.
-
assertDoesNotContainNull
Asserts that the givenIterable
does not contain null elements.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.- Throws:
AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
contains a null element.
-
assertAre
public <T> void assertAre(AssertionInfo info, Iterable<? extends T> actual, Condition<? super T> condition) Assert that each element of givenIterable
satisfies the given condition.- Type Parameters:
T
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.condition
- the givenCondition
.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element cannot be cast to T.AssertionError
- if one or more elements do not satisfy the given condition.
-
assertAreNot
public <E> void assertAreNot(AssertionInfo info, Iterable<? extends E> actual, Condition<? super E> condition) Assert that each element of givenIterable
not satisfies the given condition.- Type Parameters:
E
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.condition
- the givenCondition
.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element cannot be cast to E.AssertionError
- if one or more elements satisfy the given condition.
-
assertHave
public <E> void assertHave(AssertionInfo info, Iterable<? extends E> actual, Condition<? super E> condition) Assert that each element of givenIterable
satisfies the given condition.- Type Parameters:
E
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.condition
- the givenCondition
.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element cannot be cast to E.AssertionError
- if one or more elements do not satisfy the given condition.
-
assertDoNotHave
public <E> void assertDoNotHave(AssertionInfo info, Iterable<? extends E> actual, Condition<? super E> condition) Assert that each element of givenIterable
not satisfies the given condition.- Type Parameters:
E
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.condition
- the givenCondition
.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element cannot be cast to E.AssertionError
- if one or more elements satisfy the given condition.
-
assertAreAtLeast
public <E> void assertAreAtLeast(AssertionInfo info, Iterable<? extends E> actual, int times, Condition<? super E> condition) Assert that there are at least n elements in the actualIterable
satisfying the given condition.- Type Parameters:
E
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.times
- the minimum number of times the condition should be verified.condition
- the givenCondition
.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element cannot be cast to E.AssertionError
- if the number of elements satisfying the given condition is < n.
-
conditionIsSatisfiedAtLeastNTimes
-
assertAreAtMost
public <E> void assertAreAtMost(AssertionInfo info, Iterable<? extends E> actual, int n, Condition<? super E> condition) Assert that there are at most n elements in the actualIterable
satisfying the given condition.- Type Parameters:
E
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.n
- the number of times the condition should be at most verified.condition
- the givenCondition
.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element cannot be cast to E.AssertionError
- if the number of elements satisfying the given condition is > n.
-
conditionIsSatisfiedAtMostNTimes
-
assertAreExactly
public <E> void assertAreExactly(AssertionInfo info, Iterable<? extends E> actual, int times, Condition<? super E> condition) Verifies that there are exactly n elements in the actualIterable
satisfying the given condition.- Type Parameters:
E
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.times
- the exact number of times the condition should be verified.condition
- the givenCondition
.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element cannot be cast to E.AssertionError
- if the number of elements satisfying the given condition is ≠ n.
-
conditionIsSatisfiedNTimes
-
assertHaveAtLeast
public <E> void assertHaveAtLeast(AssertionInfo info, Iterable<? extends E> actual, int times, Condition<? super E> condition) An alias method ofassertAreAtLeast(AssertionInfo, Iterable, int, Condition)
to provide a richer fluent api (same logic, only error message differs).- Type Parameters:
E
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.times
- the minimum number of times the condition should be verified.condition
- the givenCondition
.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element cannot be cast to E.AssertionError
- if the number of elements satisfying the given condition is < n.
-
assertHaveAtMost
public <E> void assertHaveAtMost(AssertionInfo info, Iterable<? extends E> actual, int times, Condition<? super E> condition) An alias method ofassertAreAtMost(AssertionInfo, Iterable, int, Condition)
to provide a richer fluent api (same logic, only error message differs).- Type Parameters:
E
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.times
- the number of times the condition should be at most verified.condition
- the givenCondition
.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element cannot be cast to E.AssertionError
- if the number of elements satisfying the given condition is > n.
-
assertHaveExactly
public <E> void assertHaveExactly(AssertionInfo info, Iterable<? extends E> actual, int times, Condition<? super E> condition) An alias method ofassertAreExactly(AssertionInfo, Iterable, int, Condition)
to provide a richer fluent api (same logic, only error message differs).- Type Parameters:
E
- the type of actual elements- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.times
- the exact number of times the condition should be verified.condition
- the givenCondition
.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element cannot be cast to E.AssertionError
- if the number of elements satisfying the given condition is ≠ n.
-
assertContainsAll
Asserts that the givenIterable
contains all the elements of the otherIterable
, in any order.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.other
- the otherIterable
.- Throws:
NullPointerException
- ifIterable
isnull
.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not contain all the elements of the otherIterable
, in any order.
-
assertContainsExactly
Asserts that the givenIterable
contains exactly the given values and nothing else, in order.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.values
- the values that are expected to be in the givenIterable
in order.- Throws:
NullPointerException
- if the array of values isnull
.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not contain the given values or if the givenIterable
contains values that are not in the given array, in order.
-
assertEquivalency
private void assertEquivalency(AssertionInfo info, Iterable<?> actual, Object[] values, List<Object> actualAsList) -
assertElementOrder
private void assertElementOrder(AssertionInfo info, Iterable<?> actual, Object[] values, List<Object> actualAsList) -
compareOrder
-
shouldContainExactlyWithIndexAssertionError
private AssertionError shouldContainExactlyWithIndexAssertionError(Iterable<?> actual, Object[] values, List<IndexedDiff> indexedDiffs, AssertionInfo info) -
shouldContainExactlyWithDiffAssertionError
private AssertionError shouldContainExactlyWithDiffAssertionError(IterableDiff<Object> diff, Iterable<?> actual, Object[] values, AssertionInfo info) -
assertAllSatisfy
public <E> void assertAllSatisfy(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E> requirements) -
failsRequirements
private static <E> Optional<UnsatisfiedRequirement> failsRequirements(Consumer<? super E> requirements, E element) -
assertSatisfiesExactly
public <E> void assertSatisfiesExactly(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E>[] allRequirements) -
assertSatisfiesExactlyInAnyOrder
public <E> void assertSatisfiesExactlyInAnyOrder(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E>[] consumers) -
assertSatisfiesOnlyOnce
public <E> void assertSatisfiesOnlyOnce(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E> requirements) -
satisfiedElementsPerConsumer
@SafeVarargs private static <E> Deque<ElementsSatisfyingConsumer<E>> satisfiedElementsPerConsumer(Iterable<? extends E> actual, Consumer<? super E>... consumers) -
areAllConsumersSatisfied
private static <E> boolean areAllConsumersSatisfied(Queue<ElementsSatisfyingConsumer<E>> satisfiedElementsPerConsumer) -
removeElement
private static <E> Queue<ElementsSatisfyingConsumer<E>> removeElement(Queue<ElementsSatisfyingConsumer<E>> satisfiedElementsPerConsumer, E element) -
assertZipSatisfy
public <ACTUAL_ELEMENT,OTHER_ELEMENT> void assertZipSatisfy(AssertionInfo info, Iterable<? extends ACTUAL_ELEMENT> actual, Iterable<OTHER_ELEMENT> other, BiConsumer<? super ACTUAL_ELEMENT, OTHER_ELEMENT> zipRequirements) -
failsZipRequirements
private <ACTUAL_ELEMENT,OTHER_ELEMENT> Optional<ZippedElementsShouldSatisfy.ZipSatisfyError> failsZipRequirements(ACTUAL_ELEMENT actualElement, OTHER_ELEMENT otherElement, BiConsumer<ACTUAL_ELEMENT, OTHER_ELEMENT> zipRequirements) -
assertAnySatisfy
public <E> void assertAnySatisfy(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E> requirements) -
assertAllMatch
public <E> void assertAllMatch(AssertionInfo info, Iterable<? extends E> actual, Predicate<? super E> predicate, PredicateDescription predicateDescription) -
assertNoneSatisfy
public <E> void assertNoneSatisfy(AssertionInfo info, Iterable<? extends E> actual, Consumer<? super E> restrictions) -
failsRestrictions
-
assertAnyMatch
public <E> void assertAnyMatch(AssertionInfo info, Iterable<? extends E> actual, Predicate<? super E> predicate, PredicateDescription predicateDescription) -
assertNoneMatch
public <E> void assertNoneMatch(AssertionInfo info, Iterable<? extends E> actual, Predicate<? super E> predicate, PredicateDescription predicateDescription) -
assertContainsAnyOf
Asserts that the givenIterable
contains at least one of the givenvalues
.- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.values
- the values that, at least one of which is expected to be in the givenIterable
.- Throws:
NullPointerException
- if the array of values isnull
.IllegalArgumentException
- if the array of values is empty and givenIterable
is not empty.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the givenIterable
does not contain any of givenvalues
.
-
assertContainsExactlyInAnyOrder
public void assertContainsExactlyInAnyOrder(AssertionInfo info, Iterable<?> actual, Object[] values) -
assertNotNull
-
actualDoesNotEndWithSequence
private AssertionError actualDoesNotEndWithSequence(AssertionInfo info, Iterable<?> actual, Object[] sequence) -
notSatisfyingCondition
-
satisfiesCondition
-
byPassingAssertions
-
checkIsNotEmptySequence
-
checkIsNotEmptySubsequence
-