Package org.fest.assertions.core
Interface ObjectEnumerableAssert<S extends ObjectEnumerableAssert<S,T>,T>
- Type Parameters:
S
- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation" for more details.T
- the type of elements of the "actual" value.
- All Superinterfaces:
EnumerableAssert<S,
T>
- All Known Subinterfaces:
IndexedObjectEnumerableAssert<S,
T>
- All Known Implementing Classes:
AbstractIterableAssert
,IterableAssert
,ListAssert
,ObjectArrayAssert
public interface ObjectEnumerableAssert<S extends ObjectEnumerableAssert<S,T>,T>
extends EnumerableAssert<S,T>
Assertions methods applicable to groups of objects (e.g. arrays or collections.)
- Author:
- Yvonne Wang, Alex Ruiz, Nicolas François, Mikhail Mazursky, Joel Costigliola, Nicolas François
-
Method Summary
Modifier and TypeMethodDescriptionVerifies that each element value satisfies the given conditionareAtLeast
(int n, Condition<? super T> condition) Verifies that there is at least n elements in the actual group satisfying the given condition.Verifies that there is at most n elements in the actual group satisfying the given condition.areExactly
(int n, Condition<? super T> condition) Verifies that there is exactly n elements in the actual group satisfying the given condition.Verifies that each element value not satisfies the given conditionareNotAtLeast
(int n, Condition<? super T> condition) Verifies that there is at least n elements in the actual group not satisfying the given condition.areNotAtMost
(int n, Condition<? super T> condition) Verifies that there is at most n elements in the actual group not satisfying the given condition.areNotExactly
(int n, Condition<? super T> condition) Verifies that there is exactly n elements in the actual group not satisfying the given condition.Verifies that the actual group contains the given values, in any order.containsAll
(Iterable<? extends T> iterable) Verifies that the actual group contains all the elements of givenIterable
, in any order.containsExactly
(T... values) Verifies that the actual group contains only the given values and nothing else, in order.
This assertion should only be used with Iterable that have a consistent iteration order (i.e.Verifies that the actual group contains at least a null element.containsOnly
(T... values) Verifies that the actual group contains only the given values and nothing else, in any order.containsSequence
(T... sequence) Verifies that the actual group contains the given sequence, without any other values between them.doesNotContain
(T... values) Verifies that the actual group does not contain the given values.Verifies that the actual group does not contain null elements.Verifies that the actual group does not contain duplicates.Verifies that each element value not satisfies the given conditiondoNotHaveAtLeast
(int n, Condition<? super T> condition) This method is an aliasareNotAtLeast(int, Condition)
.doNotHaveAtMost
(int n, Condition<? super T> condition) This method is an aliasareNotAtMost(int, Condition)
.doNotHaveExactly
(int n, Condition<? super T> condition) This method is an aliasareNotExactly(int, Condition)
.Verifies that the actual group ends with the given sequence of objects, without any other objects between them.Verifies that each element value satisfies the given conditionhaveAtLeast
(int n, Condition<? super T> condition) This method is an alias forareAtLeast(int, Condition)
.haveAtMost
(int n, Condition<? super T> condition) This method is an aliasareAtMost(int, Condition)
.haveExactly
(int n, Condition<? super T> condition) This method is an aliasareExactly(int, Condition)
.startsWith
(T... sequence) Verifies that the actual group starts with the given sequence of objects, without any other objects between them.Methods inherited from interface org.fest.assertions.core.EnumerableAssert
hasSameSizeAs, hasSameSizeAs, hasSize, isEmpty, isNotEmpty, isNullOrEmpty, usingDefaultElementComparator, usingElementComparator
-
Method Details
-
contains
Verifies that the actual group contains the given values, in any order.- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual group isnull
.AssertionError
- if the actual group does not contain the given values.
-
containsOnly
Verifies that the actual group contains only the given values and nothing else, in any order.- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual group isnull
.AssertionError
- if the actual group does not contain the given values, i.e. the actual group contains some or none of the given values, or the actual group contains more values than the given ones.
-
containsExactly
Verifies that the actual group contains only the given values and nothing else, in order.
This assertion should only be used with Iterable that have a consistent iteration order (i.e. don't use it withHashSet
, prefercontainsOnly(Object...)
in that case).Example :
Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya); // assertion will pass assertThat(elvesRings).containsExactly(vilya, nenya, narya); // assertion will fail as actual and expected orders differ. assertThat(elvesRings).containsExactly(nenya, vilya, narya);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual group isnull
.AssertionError
- if the actual group does not contain the given values with same order, i.e. the actual group contains some or none of the given values, or the actual group contains more values than the given ones or values are not in same order.
-
containsSequence
Verifies that the actual group contains the given sequence, without any other values between them.- Parameters:
sequence
- the sequence of objects to look for.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actual group isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual group does not contain the given sequence.
-
doesNotContain
Verifies that the actual group does not contain the given values.- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual group isnull
.AssertionError
- if the actual group contains any of the given values.
-
doesNotHaveDuplicates
S doesNotHaveDuplicates()Verifies that the actual group does not contain duplicates.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual group isnull
.AssertionError
- if the actual group contains duplicates.
-
startsWith
Verifies that the actual group 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 first element of the actual group.containsSequence(Object...)
- Parameters:
sequence
- the sequence of objects to look for.- Returns:
- this assertion object.
- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual group isnull
.AssertionError
- if the actual group does not start with the given sequence of objects.
-
endsWith
Verifies that the actual group 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 last element of the actual group.containsSequence(Object...)
- Parameters:
sequence
- the sequence of objects to look for.- Returns:
- this assertion object.
- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual group isnull
.AssertionError
- if the actual group does not end with the given sequence of objects.
-
containsNull
S containsNull()Verifies that the actual group contains at least a null element.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual group isnull
.AssertionError
- if the actual group does not contain a null element.
-
doesNotContainNull
S doesNotContainNull()Verifies that the actual group does not contain null elements.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual group isnull
.AssertionError
- if the actual group contains a null element.
-
are
Verifies that each element value satisfies the given condition- Parameters:
condition
- the given condition.- Returns:
this
object.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if a element cannot be cast to E.AssertionError
- if one or more element not satisfy the given condition.
-
areNot
Verifies that each element value not satisfies the given condition- Parameters:
condition
- the given condition.- Returns:
this
object.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if a element cannot be cast to E.AssertionError
- if one or more element satisfy the given condition.
-
have
Verifies that each element value satisfies the given condition- Parameters:
condition
- the given condition.- Returns:
this
object.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if a element cannot be cast to E.AssertionError
- if one or more element not satisfy the given condition.
-
doNotHave
Verifies that each element value not satisfies the given condition- Parameters:
condition
- the given condition.- Returns:
this
object.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if a element cannot be cast to E.AssertionError
- if one or more element satisfy the given condition.
-
areAtLeast
Verifies that there is at least n elements in the actual group satisfying the given condition.- Parameters:
n
- the minimum number of times the condition should be verified.condition
- the given condition.- Returns:
this
object.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if an element can not be cast to E.AssertionError
- if the number of elements satisfying the given condition is < n.
-
areNotAtLeast
Verifies that there is at least n elements in the actual group not satisfying the given condition.- Parameters:
n
- the number of times the condition should not be verified at least.condition
- the given condition.- Returns:
this
object.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if a element cannot be cast to E.AssertionError
- if the number of elements not satisfying the given condition is < n.
-
areAtMost
Verifies that there is at most n elements in the actual group satisfying the given condition.- Parameters:
n
- the number of times the condition should be at most verified.condition
- the given condition.- Returns:
this
object.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if a element cannot be cast to E.AssertionError
- if the number of elements satisfying the given condition is > n.
-
areNotAtMost
Verifies that there is at most n elements in the actual group not satisfying the given condition.- Parameters:
n
- the number of times the condition should not be verified at most.condition
- the given condition.- Returns:
this
object.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if a element cannot be cast to E.AssertionError
- if the number of elements not satisfying the given condition is > n.
-
areExactly
Verifies that there is exactly n elements in the actual group satisfying the given condition.- Parameters:
n
- the exact number of times the condition should be verified.condition
- the given condition.- Returns:
this
object.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if a element cannot be cast to E.AssertionError
- if the number of elements satisfying the given condition is ≠ n.
-
areNotExactly
Verifies that there is exactly n elements in the actual group not satisfying the given condition.- Parameters:
n
- the exact number of times the condition should not be verified.condition
- the given condition.- Returns:
this
object.- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if a element cannot be cast to E.AssertionError
- if the number of elements not satisfying the given condition is ≠ n.
-
haveAtLeast
This method is an alias forareAtLeast(int, Condition)
. -
doNotHaveAtLeast
This method is an aliasareNotAtLeast(int, Condition)
. -
haveAtMost
This method is an aliasareAtMost(int, Condition)
. -
doNotHaveAtMost
This method is an aliasareNotAtMost(int, Condition)
. -
haveExactly
This method is an aliasareExactly(int, Condition)
. -
doNotHaveExactly
This method is an aliasareNotExactly(int, Condition)
. -
containsAll
Verifies that the actual group contains all the elements of givenIterable
, in any order.- Parameters:
iterable
- the givenIterable
we will get elements from.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.AssertionError
- if the actual group isnull
.AssertionError
- if the actual group does not contain all the elements of givenIterable
.
-