Package org.assertj.core.api
Class IterableAssert<ELEMENT>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractIterableAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>
org.assertj.core.api.FactoryBasedNavigableIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
org.assertj.core.api.IterableAssert<ELEMENT>
- Type Parameters:
ELEMENT
- the type of elements of the "actual" value.
- All Implemented Interfaces:
Assert<IterableAssert<ELEMENT>,
,Iterable<? extends ELEMENT>> Descriptable<IterableAssert<ELEMENT>>
,EnumerableAssert<IterableAssert<ELEMENT>,
,ELEMENT> ExtensionPoints<IterableAssert<ELEMENT>,
,Iterable<? extends ELEMENT>> ObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT>
public class IterableAssert<ELEMENT>
extends FactoryBasedNavigableIterableAssert<IterableAssert<ELEMENT>,Iterable<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
Assertion methods for
Iterable
.
To create an instance of this class, invoke
.
Assertions.assertThat(Iterable)
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.assertj.core.api.AbstractIterableAssert
iterables
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, conditions, info, myself, objects
-
Constructor Summary
ConstructorsConstructorDescriptionIterableAssert
(Iterable<? extends ELEMENT> actual) IterableAssert
(Iterator<? extends ELEMENT> actual) -
Method Summary
Modifier and TypeMethodDescriptionprivate AssertionError
actualDoesNotStartWithSequence
(AssertionInfo info, Iterable<?> actual, Object[] sequence) private IterableAssert.LazyIterable
final IterableAssert<ELEMENT>
Verifies that the actual group contains the given values, in any order.final IterableAssert<ELEMENT>
containsExactly
(ELEMENT... values) Verifies that the actual group contains only the given values and nothing else, in order.
This assertion should only be used with groups that have a consistent iteration order (i.e.final IterableAssert<ELEMENT>
containsExactlyInAnyOrder
(ELEMENT... values) Verifies that the actual group contains exactly the given values and nothing else, in any order.final IterableAssert<ELEMENT>
containsOnly
(ELEMENT... values) Verifies that the actual group contains only the given values and nothing else, in any order.final IterableAssert<ELEMENT>
containsOnlyOnce
(ELEMENT... values) Verifies that the actual group contains the given values only once.final IterableAssert<ELEMENT>
containsSequence
(ELEMENT... sequence) Verifies that the actual group contains the given sequence in the correct order and without extra values between the sequence values.final IterableAssert<ELEMENT>
containsSubsequence
(ELEMENT... sequence) Verifies that the actual group contains the given subsequence in the correct order (possibly with other values between them).final IterableAssert<ELEMENT>
doesNotContain
(ELEMENT... values) Verifies that the actual group does not contain the given values.final IterableAssert<ELEMENT>
doesNotContainSequence
(ELEMENT... sequence) Verifies that the actual group does not contain the given sequence, a sequence is defined by an ordered group of values without extra values between them.final IterableAssert<ELEMENT>
doesNotContainSubsequence
(ELEMENT... sequence) Verifies that the actual group does not contain the given subsequence, a subsequence is defined by an ordered group of values with possibly extra values between them.final IterableAssert<ELEMENT>
Verifies that the actual group ends with the given sequence of objects, without any other objects between them.Verifies that the actual value is equal to the given one.isExactlyInstanceOf
(Class<?> type) Verifies that the actual value is exactly an instance of the given type.isInstanceOf
(Class<?> type) Verifies that the actual value is an instance of the given type.isInstanceOfAny
(Class<?>... types) Verifies that the actual value is an instance of any of the given types.isNotExactlyInstanceOf
(Class<?> type) Verifies that the actual value is not exactly an instance of given type.isNotInstanceOf
(Class<?> type) Verifies that the actual value is not an instance of the given type.isNotInstanceOfAny
(Class<?>... types) Verifies that the actual value is not an instance of any of the given types.isNotOfAnyClassIn
(Class<?>... types) Verifies that the actual value type is not in given types.isNotSameAs
(Object expected) Verifies that the actual value is not the same as the given one, ie using == comparison.isOfAnyClassIn
(Class<?>... types) Verifies that the actual value type is in given types.Verifies that the actual value is the same as the given one, ie using == comparison.final IterableAssert<ELEMENT>
isSubsetOf
(ELEMENT... values) Verifies that all the elements of actual are present in the given values.final IterableAssert<ELEMENT>
startsWith
(ELEMENT... sequence) Verifies that the actual group starts with the given sequence of objects, without any other objects between them.private static <T> Iterable<T>
toIterable
(Iterator<T> iterator) Methods inherited from class org.assertj.core.api.FactoryBasedNavigableIterableAssert
toAssert
Methods inherited from class org.assertj.core.api.AbstractIterableAssert
allMatch, allMatch, allSatisfy, anySatisfy, are, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, as, as, containsAll, containsExactlyElementsOf, containsNull, containsOnlyElementsOf, containsSequence, containsSubsequence, describedAs, describedAs, doesNotContainAnyElementsOf, doesNotContainNull, doesNotContainSequence, doesNotContainSubsequence, doesNotHave, doesNotHaveDuplicates, doesNotHaveSameClassAs, doNotHave, element, extracting, extracting, extracting, extracting, extracting, extracting, extractingResultOf, extractingResultOf, filteredOn, filteredOn, filteredOn, filteredOn, filteredOnNull, first, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtracting, has, hasAtLeastOneElementOfType, hasOnlyElementsOfType, hasOnlyElementsOfTypes, hasOnlyOneElementSatisfying, hasSameClassAs, hasSameElementsAs, hasSameSizeAs, hasSameSizeAs, hasSize, hasToString, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, inBinary, inHexadecimal, is, isEmpty, isIn, isIn, isNot, isNotEmpty, isNotEqualTo, isNotIn, isNotIn, isNotNull, isNullOrEmpty, isSubsetOf, last, navigationDescription, newListAssertInstance, overridingErrorMessage, size, toLazyIterable, usingComparator, usingComparatorForElementFieldsWithNames, usingComparatorForElementFieldsWithType, usingComparisonStrategy, usingDefaultComparator, usingDefaultElementComparator, usingElementComparator, usingElementComparatorIgnoringFields, usingElementComparatorOnFields, usingFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparator, withFailMessage, withThreadDumpOnError
Methods inherited from class org.assertj.core.api.AbstractAssert
asList, asString, descriptionText, equals, failWithMessage, getWritableAssertionInfo, hashCode, isInstanceOfSatisfying, isNull, matches, matches, satisfies, setCustomRepresentation, throwAssertionError, withRepresentation
-
Constructor Details
-
IterableAssert
-
IterableAssert
-
-
Method Details
-
isEqualTo
Description copied from class:AbstractAssert
Verifies that the actual value is equal to the given one.Example:
// assertions will pass assertThat("abc").isEqualTo("abc"); assertThat(new HashMap<String, Integer>()).isEqualTo(new HashMap<String, Integer>()); // assertions will fail assertThat("abc").isEqualTo("123"); assertThat(new ArrayList<String>()).isEqualTo(1);
- Specified by:
isEqualTo
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isEqualTo
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
expected
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
isInstanceOf
Description copied from class:AbstractAssert
Verifies that the actual value is an instance of the given type.Example:
// assertions will pass assertThat("abc").isInstanceOf(String.class); assertThat(new HashMap<String, Integer>()).isInstanceOf(HashMap.class); assertThat(new HashMap<String, Integer>()).isInstanceOf(Map.class); // assertions will fail assertThat(1).isInstanceOf(String.class); assertThat(new ArrayList<String>()).isInstanceOf(LinkedList.class);
- Specified by:
isInstanceOf
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isInstanceOf
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
type
- the type to check the actual value against.- Returns:
- this assertion object.
-
isInstanceOfAny
Description copied from class:AbstractAssert
Verifies that the actual value is an instance of any of the given types.Example:
// assertions will pass assertThat("abc").isInstanceOfAny(String.class, Integer.class); assertThat(new ArrayList<String>()).isInstanceOfAny(LinkedList.class, ArrayList.class); assertThat(new HashMap<String, Integer>()).isInstanceOfAny(TreeMap.class, Map.class); // assertions will fail assertThat(1).isInstanceOfAny(Double.class, Float.class); assertThat(new ArrayList<String>()).isInstanceOfAny(LinkedList.class, Vector.class);
- Specified by:
isInstanceOfAny
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isInstanceOfAny
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
types
- the types to check the actual value against.- Returns:
- this assertion object.
-
isOfAnyClassIn
Description copied from class:AbstractAssert
Verifies that the actual value type is in given types.Example:
// assertions will pass assertThat(new HashMap<String, Integer>()).isOfAnyClassIn(HashMap.class, TreeMap.class); assertThat(new ArrayList<String>()).isOfAnyClassIn(ArrayList.class, LinkedList.class); // assertions will fail assertThat(new HashMap<String, Integer>()).isOfAnyClassIn(TreeMap.class, Map.class); assertThat(new ArrayList<String>()).isOfAnyClassIn(LinkedList.class, List.class);
- Specified by:
isOfAnyClassIn
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isOfAnyClassIn
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
types
- the types to check the actual value against.- Returns:
- this assertion object.
-
isExactlyInstanceOf
Description copied from class:AbstractAssert
Verifies that the actual value is exactly an instance of the given type.Example:
// assertions will pass assertThat("abc").isExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isExactlyInstanceOf(ArrayList.class); assertThat(new HashMap<String, Integer>()).isExactlyInstanceOf(HashMap.class); // assertions will fail assertThat(1).isExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isExactlyInstanceOf(List.class); assertThat(new HashMap<String, Integer>()).isExactlyInstanceOf(Map.class);
- Specified by:
isExactlyInstanceOf
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isExactlyInstanceOf
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
type
- the type to check the actual value against.- Returns:
- this assertion object.
-
isNotInstanceOf
Description copied from class:AbstractAssert
Verifies that the actual value is not an instance of the given type.Example:
// assertions will pass assertThat(1).isNotInstanceOf(Double.class); assertThat(new ArrayList<String>()).isNotInstanceOf(LinkedList.class); // assertions will fail assertThat("abc").isNotInstanceOf(String.class); assertThat(new HashMap<String, Integer>()).isNotInstanceOf(HashMap.class); assertThat(new HashMap<String, Integer>()).isNotInstanceOf(Map.class);
- Specified by:
isNotInstanceOf
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isNotInstanceOf
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
type
- the type to check the actual value against.- Returns:
- this assertion object.
-
isNotInstanceOfAny
Description copied from class:AbstractAssert
Verifies that the actual value is not an instance of any of the given types.Example:
// assertions will pass assertThat(1).isNotInstanceOfAny(Double.class, Float.class); assertThat(new ArrayList<String>()).isNotInstanceOfAny(LinkedList.class, Vector.class); // assertions will fail assertThat(1).isNotInstanceOfAny(Double.class, Integer.class); assertThat(new ArrayList<String>()).isNotInstanceOfAny(LinkedList.class, ArrayList.class); assertThat(new HashMap<String, Integer>()).isNotInstanceOfAny(TreeMap.class, Map.class);
- Specified by:
isNotInstanceOfAny
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isNotInstanceOfAny
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
types
- the types to check the actual value against.- Returns:
- this assertion object.
-
isNotOfAnyClassIn
Description copied from class:AbstractAssert
Verifies that the actual value type is not in given types.Example:
// assertions will pass assertThat(new HashMap<String, Integer>()).isNotOfAnyClassIn(Map.class, TreeMap.class); assertThat(new ArrayList<String>()).isNotOfAnyClassIn(LinkedList.class, List.class); // assertions will fail assertThat(new HashMap<String, Integer>()).isNotOfAnyClassIn(HashMap.class, TreeMap.class); assertThat(new ArrayList<String>()).isNotOfAnyClassIn(ArrayList.class, LinkedList.class);
- Specified by:
isNotOfAnyClassIn
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isNotOfAnyClassIn
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
types
- the types to check the actual value against.- Returns:
- this assertion object.
-
isNotExactlyInstanceOf
Description copied from class:AbstractAssert
Verifies that the actual value is not exactly an instance of given type.Example:
// assertions will pass assertThat(1).isNotExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isNotExactlyInstanceOf(List.class); assertThat(new HashMap<String, Integer>()).isNotExactlyInstanceOf(Map.class); // assertions will fail assertThat("abc").isNotExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isNotExactlyInstanceOf(ArrayList.class); assertThat(new HashMap<String, Integer>()).isNotExactlyInstanceOf(HashMap.class);
- Specified by:
isNotExactlyInstanceOf
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isNotExactlyInstanceOf
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
type
- the type to check the actual value against.- Returns:
- this assertion object.
-
isSameAs
Description copied from class:AbstractAssert
Verifies that the actual value is the same as the given one, ie using == comparison.Example:
// Name is a class with first and last fields, two Names are equals if both first and last are equals. Name tyrion = new Name("Tyrion", "Lannister"); Name alias = tyrion; Name clone = new Name("Tyrion", "Lannister"); // assertions succeed: assertThat(tyrion).isSameAs(alias) .isEqualTo(clone); // assertion fails: assertThat(tyrion).isSameAs(clone);
- Specified by:
isSameAs
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isSameAs
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
expected
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
isNotSameAs
Description copied from class:AbstractAssert
Verifies that the actual value is not the same as the given one, ie using == comparison.Example:
// Name is a class with first and last fields, two Names are equals if both first and last are equals. Name tyrion = new Name("Tyrion", "Lannister"); Name alias = tyrion; Name clone = new Name("Tyrion", "Lannister"); // assertions succeed: assertThat(clone).isNotSameAs(tyrion) .isEqualTo(tyrion); // assertion fails: assertThat(alias).isNotSameAs(tyrion);
- Specified by:
isNotSameAs
in interfaceAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>> - Overrides:
isNotSameAs
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
expected
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
startsWith
Description copied from class:AbstractIterableAssert
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.ObjectEnumerableAssert.containsSequence(Object...)
Example :
// an Iterable is used in the example but it would also work with an array Iterable<String> abc = newArrayList("a", "b", "c"); // assertions will pass assertThat(abc).startsWith("a") .startsWith("a", "b"); // assertion will fail assertThat(abc).startsWith("c");
- Specified by:
startsWith
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
startsWith
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
sequence
- the sequence of objects to look for.- Returns:
- this assertion object.
-
actualDoesNotStartWithSequence
private AssertionError actualDoesNotStartWithSequence(AssertionInfo info, Iterable<?> actual, Object[] sequence) -
asLazyIterable
-
toIterable
-
contains
Description copied from class:AbstractIterableAssert
Verifies that the actual group contains the given values, in any order.Example :
Iterable<String> abc = newArrayList("a", "b", "c"); // assertions will pass assertThat(abc).contains("b", "a"); assertThat(abc).contains("b", "a", "b"); // assertion will fail assertThat(abc).contains("d");
- Specified by:
contains
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
contains
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
values
- the given values.- Returns:
this
assertion object.
-
containsOnly
Description copied from class:AbstractIterableAssert
Verifies that the actual group contains only the given values and nothing else, in any order.Example :
Iterable<String> abc = newArrayList("a", "b", "c"); // assertion will pass assertThat(abc).containsOnly("c", "b", "a"); // assertion will fail because "c" is missing assertThat(abc).containsOnly("a", "b");
- Specified by:
containsOnly
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
containsOnly
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
values
- the given values.- Returns:
this
assertion object.
-
containsOnlyOnce
Description copied from class:AbstractIterableAssert
Verifies that the actual group contains the given values only once.Examples :
// lists are used in the examples but it would also work with arrays // assertions will pass assertThat(newArrayList("winter", "is", "coming")).containsOnlyOnce("winter"); assertThat(newArrayList("winter", "is", "coming")).containsOnlyOnce("coming", "winter"); // assertions will fail assertThat(newArrayList("winter", "is", "coming")).containsOnlyOnce("Lannister"); assertThat(newArrayList("Arya", "Stark", "daughter", "of", "Ned", "Stark")).containsOnlyOnce("Stark"); assertThat(newArrayList("Arya", "Stark", "daughter", "of", "Ned", "Stark")).containsOnlyOnce("Stark", "Lannister", "Arya");
- Specified by:
containsOnlyOnce
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
containsOnlyOnce
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
values
- the given values.- Returns:
this
assertion object.
-
containsExactly
Description copied from class:AbstractIterableAssert
Verifies that the actual group contains only the given values and nothing else, in order.
This assertion should only be used with groups that have a consistent iteration order (i.e. don't use it withHashSet
, preferObjectEnumerableAssert.containsOnly(Object...)
in that case).Example :
// an Iterable is used in the example but it would also work with an array Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya); // assertion will pass assertThat(elvesRings).containsExactly(vilya, nenya, narya); // assertion will fail as actual and expected order differ assertThat(elvesRings).containsExactly(nenya, vilya, narya);
- Specified by:
containsExactly
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
containsExactly
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
values
- the given values.- Returns:
this
assertion object.
-
containsExactlyInAnyOrder
Description copied from class:AbstractIterableAssert
Verifies that the actual group contains exactly the given values and nothing else, in any order.
Example :
// an Iterable is used in the example but it would also work with an array Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya, vilya); // assertion will pass assertThat(elvesRings).containsExactlyInAnyOrder(vilya, vilya, nenya, narya); // assertion will fail as vilya is contained twice in elvesRings. assertThat(elvesRings).containsExactlyInAnyOrder(nenya, vilya, narya);
- Specified by:
containsExactlyInAnyOrder
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
containsExactlyInAnyOrder
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
values
- the given values.- Returns:
this
assertion object.
-
isSubsetOf
Description copied from class:AbstractIterableAssert
Verifies that all the elements of actual are present in the given values.Example:
// an Iterable is used in the example but it would also work with an array Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya); // assertions will pass: assertThat(elvesRings).isSubsetOf(vilya, nenya, narya) .isSubsetOf(vilya, nenya, narya, dwarfRing); // assertions will fail: assertThat(elvesRings).isSubsetOf(vilya, nenya); assertThat(elvesRings).isSubsetOf(vilya, nenya, dwarfRing);
- Specified by:
isSubsetOf
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
isSubsetOf
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
values
- the values that should be used for checking the elements of actual.- Returns:
- this assertion object.
-
containsSequence
Description copied from class:AbstractIterableAssert
Verifies that the actual group contains the given sequence in the correct order and without extra values between the sequence values.Use
ObjectEnumerableAssert.containsSubsequence(Object...)
to allow values between the expected sequence values.Example:
// an Iterable is used in the example but it would also work with an array Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya); // assertions will pass assertThat(elvesRings).containsSequence(vilya, nenya) .containsSequence(nenya, narya); // assertions will fail, the elements order is correct but there is a value between them (nenya) assertThat(elvesRings).containsSequence(vilya, narya); assertThat(elvesRings).containsSequence(nenya, vilya);
- Specified by:
containsSequence
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
containsSequence
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
sequence
- the sequence of objects to look for.- Returns:
- this assertion object.
-
doesNotContainSequence
Description copied from class:AbstractIterableAssert
Verifies that the actual group does not contain the given sequence, a sequence is defined by an ordered group of values without extra values between them.Use
ObjectEnumerableAssert.doesNotContainSubsequence(Object...)
to also ensure the sequence does not exist with values between the expected sequence values.Example:
// an Iterable is used in the example but it would also work with an array Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya); // assertions will pass, the elements order is correct but there is a value between them (nenya) assertThat(elvesRings).doesNotContainSequence(vilya, narya) .doesNotContainSequence(nenya, vilya); // assertions will fail assertThat(elvesRings).doesNotContainSequence(vilya, nenya); assertThat(elvesRings).doesNotContainSequence(nenya, narya);
- Specified by:
doesNotContainSequence
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
doesNotContainSequence
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
sequence
- the sequence of objects to look for.- Returns:
- this assertion object.
-
containsSubsequence
Description copied from class:AbstractIterableAssert
Verifies that the actual group contains the given subsequence in the correct order (possibly with other values between them).Example:
// an Iterable is used in the example but it would also work with an array Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya); // assertions will pass assertThat(elvesRings).containsSubsequence(vilya, nenya) .containsSubsequence(vilya, narya); // assertion will fail assertThat(elvesRings).containsSubsequence(nenya, vilya);
- Specified by:
containsSubsequence
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
containsSubsequence
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
sequence
- the sequence of objects to look for.- Returns:
- this assertion object.
-
doesNotContainSubsequence
Description copied from class:AbstractIterableAssert
Verifies that the actual group does not contain the given subsequence, a subsequence is defined by an ordered group of values with possibly extra values between them.Example:
// an Iterable is used in the example but it would also work with an array Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya); // assertions will pass assertThat(elvesRings).doesNotContainSubsequence(nenya, vilya) .doesNotContainSubsequence(narya, vilya); // assertion will fail assertThat(elvesRings).doesNotContainSubsequence(vilya, nenya); assertThat(elvesRings).doesNotContainSubsequence(vilya, narya);
- Specified by:
doesNotContainSubsequence
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
doesNotContainSubsequence
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
sequence
- the sequence of objects to look for.- Returns:
- this assertion object.
-
doesNotContain
Description copied from interface:ObjectEnumerableAssert
Verifies that the actual group does not contain the given values.Example :
// an Iterable is used in the example but it would also work with an array Iterable<String> abc = newArrayList("a", "b", "c"); // assertions will pass assertThat(abc).doesNotContain("d") .doesNotContain("d", "e"); // assertions will fail assertThat(abc).doesNotContain("a"); assertThat(abc).doesNotContain("a", "b"); assertThat(abc).doesNotContain("c", "d");
- Specified by:
doesNotContain
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
doesNotContain
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
values
- the given values.- Returns:
this
assertion object.
-
endsWith
Description copied from class:AbstractIterableAssert
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.ObjectEnumerableAssert.containsSequence(Object...)
Example :
// an Iterable is used in the example but it would also work with an array Iterable<String> abc = newArrayList("a", "b", "c"); // assertions will pass assertThat(abc).endsWith("c") .endsWith("b", "c"); // assertions will fail assertThat(abc).endsWith("a"); assertThat(abc).endsWith("a", "b");
- Specified by:
endsWith
in interfaceObjectEnumerableAssert<IterableAssert<ELEMENT>,
ELEMENT> - Overrides:
endsWith
in classAbstractIterableAssert<IterableAssert<ELEMENT>,
Iterable<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
sequence
- the sequence of objects to look for.- Returns:
- this assertion object.
-