Package org.assertj.core.api
Class ListAssert<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.AbstractListAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>
-
- org.assertj.core.api.FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
-
- org.assertj.core.api.ListAssert<ELEMENT>
-
- Type Parameters:
ELEMENT- the type of elements of the "actual" value.
- All Implemented Interfaces:
Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>,Descriptable<ListAssert<ELEMENT>>,EnumerableAssert<ListAssert<ELEMENT>,ELEMENT>,ExtensionPoints<ListAssert<ELEMENT>,List<? extends ELEMENT>>,IndexedObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>,ObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>
public class ListAssert<ELEMENT> extends FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
Assertion methods forLists.To create an instance of this class, invoke
.Assertions.assertThat(List)- Author:
- Yvonne Wang, Alex Ruiz, Joel Costigliola, Mikhail Mazursky
-
-
Field Summary
-
Fields inherited from class org.assertj.core.api.AbstractIterableAssert
iterables
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself
-
-
Constructor Summary
Constructors Modifier Constructor Description ListAssert(List<? extends ELEMENT> actual)protectedListAssert(BaseStream<? extends ELEMENT,STREAM> actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ListAssert<ELEMENT>contains(ELEMENT... values)Verifies that the actual group contains the given values, in any order.ListAssert<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.ListAssert<ELEMENT>containsExactlyInAnyOrder(ELEMENT... values)Verifies that the actual group contains exactly the given values and nothing else, in any order.ListAssert<ELEMENT>containsOnly(ELEMENT... values)Verifies that the actual group contains only the given values and nothing else, in any order.ListAssert<ELEMENT>containsOnlyOnce(ELEMENT... values)Verifies that the actual group contains the given values only once.ListAssert<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.ListAssert<ELEMENT>containsSubsequence(ELEMENT... sequence)Verifies that the actual group contains the given subsequence in the correct order (possibly with other values between them).ListAssert<ELEMENT>doesNotContain(ELEMENT... values)Verifies that the actual group does not contain the given values.ListAssert<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.ListAssert<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.ListAssert<ELEMENT>endsWith(ELEMENT... sequence)Verifies that the actual group ends with the given sequence of objects, without any other objects between them.ListAssert<ELEMENT>isEqualTo(Object expected)Verifies that the actual value is equal to the given one.ListAssert<ELEMENT>isExactlyInstanceOf(Class<?> type)Verifies that the actual value is exactly an instance of the given type.ListAssert<ELEMENT>isInstanceOf(Class<?> type)Verifies that the actual value is an instance of the given type.ListAssert<ELEMENT>isInstanceOfAny(Class<?>... types)Verifies that the actual value is an instance of any of the given types.ListAssert<ELEMENT>isNotExactlyInstanceOf(Class<?> type)Verifies that the actual value is not exactly an instance of given type.ListAssert<ELEMENT>isNotInstanceOf(Class<?> type)Verifies that the actual value is not an instance of the given type.ListAssert<ELEMENT>isNotInstanceOfAny(Class<?>... types)Verifies that the actual value is not an instance of any of the given types.ListAssert<ELEMENT>isNotOfAnyClassIn(Class<?>... types)Verifies that the actual value type is not in given types.ListAssert<ELEMENT>isNotSameAs(Object expected)Verifies that the actual value is not the same as the given one, ie using == comparison.ListAssert<ELEMENT>isOfAnyClassIn(Class<?>... types)Verifies that the actual value type is in given types.ListAssert<ELEMENT>isSameAs(Object expected)Verifies that the actual value is the same as the given one, ie using == comparison.ListAssert<ELEMENT>isSubsetOf(ELEMENT... values)Verifies that all the elements of actual are present in the given values.ListAssert<ELEMENT>startsWith(ELEMENT... sequence)Verifies that the actual group starts with the given sequence of objects, without any other objects between them.-
Methods inherited from class org.assertj.core.api.FactoryBasedNavigableListAssert
toAssert
-
Methods inherited from class org.assertj.core.api.AbstractListAssert
as, as, contains, describedAs, describedAs, doesNotContain, doesNotHave, doesNotHaveSameClassAs, has, has, hasSameClassAs, hasToString, is, is, isIn, isIn, isNot, isNotEqualTo, isNotIn, isNotIn, isNotNull, isSorted, isSortedAccordingTo, overridingErrorMessage, usingComparator, usingComparisonStrategy, usingDefaultComparator, usingDefaultElementComparator, usingElementComparator, withFailMessage, withThreadDumpOnError
-
Methods inherited from class org.assertj.core.api.AbstractIterableAssert
allMatch, allMatch, allSatisfy, anySatisfy, are, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, containsAll, containsExactlyElementsOf, containsNull, containsOnlyElementsOf, containsSequence, containsSubsequence, doesNotContainAnyElementsOf, doesNotContainNull, doesNotContainSequence, doesNotContainSubsequence, doesNotHaveDuplicates, doNotHave, element, extracting, extracting, extracting, extracting, extracting, extracting, extractingResultOf, extractingResultOf, filteredOn, filteredOn, filteredOn, filteredOn, filteredOnNull, first, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtracting, hasAtLeastOneElementOfType, hasOnlyElementsOfType, hasOnlyElementsOfTypes, hasOnlyOneElementSatisfying, hasSameElementsAs, hasSameSizeAs, hasSameSizeAs, hasSize, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, inBinary, inHexadecimal, isEmpty, isNotEmpty, isNullOrEmpty, isSubsetOf, last, navigationDescription, newListAssertInstance, size, toLazyIterable, usingComparatorForElementFieldsWithNames, usingComparatorForElementFieldsWithType, usingElementComparatorIgnoringFields, usingElementComparatorOnFields, usingFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparator
-
Methods inherited from class org.assertj.core.api.AbstractAssert
asList, asString, descriptionText, equals, failWithMessage, getWritableAssertionInfo, hashCode, isInstanceOfSatisfying, isNull, matches, matches, satisfies, setCustomRepresentation, throwAssertionError, withRepresentation
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.api.EnumerableAssert
hasSameSizeAs, hasSameSizeAs, hasSize, isEmpty, isNotEmpty, isNullOrEmpty
-
Methods inherited from interface org.assertj.core.api.ObjectEnumerableAssert
allMatch, allMatch, allSatisfy, anySatisfy, are, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, containsAll, containsExactlyElementsOf, containsNull, containsOnlyElementsOf, containsSequence, containsSubsequence, doesNotContainAnyElementsOf, doesNotContainNull, doesNotContainSequence, doesNotContainSubsequence, doesNotHaveDuplicates, doNotHave, hasAtLeastOneElementOfType, hasOnlyElementsOfType, hasOnlyElementsOfTypes, hasSameElementsAs, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, isSubsetOf
-
-
-
-
Constructor Detail
-
ListAssert
protected ListAssert(BaseStream<? extends ELEMENT,STREAM> actual)
-
-
Method Detail
-
isEqualTo
public ListAssert<ELEMENT> isEqualTo(Object expected)
Description copied from class:AbstractAssertVerifies 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:
isEqualToin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isEqualToin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
expected- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isInstanceOf
public ListAssert<ELEMENT> isInstanceOf(Class<?> type)
Description copied from class:AbstractAssertVerifies 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:
isInstanceOfin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isInstanceOfin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
type- the type to check the actual value against.- Returns:
- this assertion object.
-
isInstanceOfAny
public ListAssert<ELEMENT> isInstanceOfAny(Class<?>... types)
Description copied from class:AbstractAssertVerifies 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:
isInstanceOfAnyin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isInstanceOfAnyin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
types- the types to check the actual value against.- Returns:
- this assertion object.
-
isOfAnyClassIn
public ListAssert<ELEMENT> isOfAnyClassIn(Class<?>... types)
Description copied from class:AbstractAssertVerifies 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:
isOfAnyClassInin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isOfAnyClassInin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
types- the types to check the actual value against.- Returns:
- this assertion object.
-
isExactlyInstanceOf
public ListAssert<ELEMENT> isExactlyInstanceOf(Class<?> type)
Description copied from class:AbstractAssertVerifies 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:
isExactlyInstanceOfin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isExactlyInstanceOfin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
type- the type to check the actual value against.- Returns:
- this assertion object.
-
isNotInstanceOf
public ListAssert<ELEMENT> isNotInstanceOf(Class<?> type)
Description copied from class:AbstractAssertVerifies 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:
isNotInstanceOfin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isNotInstanceOfin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
type- the type to check the actual value against.- Returns:
- this assertion object.
-
isNotInstanceOfAny
public ListAssert<ELEMENT> isNotInstanceOfAny(Class<?>... types)
Description copied from class:AbstractAssertVerifies 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:
isNotInstanceOfAnyin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isNotInstanceOfAnyin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
types- the types to check the actual value against.- Returns:
- this assertion object.
-
isNotOfAnyClassIn
public ListAssert<ELEMENT> isNotOfAnyClassIn(Class<?>... types)
Description copied from class:AbstractAssertVerifies 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:
isNotOfAnyClassInin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isNotOfAnyClassInin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
types- the types to check the actual value against.- Returns:
- this assertion object.
-
isNotExactlyInstanceOf
public ListAssert<ELEMENT> isNotExactlyInstanceOf(Class<?> type)
Description copied from class:AbstractAssertVerifies 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:
isNotExactlyInstanceOfin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isNotExactlyInstanceOfin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
type- the type to check the actual value against.- Returns:
- this assertion object.
-
isSameAs
public ListAssert<ELEMENT> isSameAs(Object expected)
Description copied from class:AbstractAssertVerifies 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:
isSameAsin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isSameAsin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
expected- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isNotSameAs
public ListAssert<ELEMENT> isNotSameAs(Object expected)
Description copied from class:AbstractAssertVerifies 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:
isNotSameAsin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>- Overrides:
isNotSameAsin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
expected- the given value to compare the actual value to.- Returns:
thisassertion object.
-
startsWith
@SafeVarargs public final ListAssert<ELEMENT> startsWith(ELEMENT... sequence)
Description copied from class:AbstractIterableAssertVerifies 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:
startsWithin interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
startsWithin classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
sequence- the sequence of objects to look for.- Returns:
- this assertion object.
-
contains
@SafeVarargs public final ListAssert<ELEMENT> contains(ELEMENT... values)
Description copied from class:AbstractIterableAssertVerifies 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:
containsin interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
containsin classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
values- the given values.- Returns:
thisassertion object.
-
containsOnly
@SafeVarargs public final ListAssert<ELEMENT> containsOnly(ELEMENT... values)
Description copied from class:AbstractIterableAssertVerifies 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:
containsOnlyin interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
containsOnlyin classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
values- the given values.- Returns:
thisassertion object.
-
containsOnlyOnce
@SafeVarargs public final ListAssert<ELEMENT> containsOnlyOnce(ELEMENT... values)
Description copied from class:AbstractIterableAssertVerifies 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:
containsOnlyOncein interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
containsOnlyOncein classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
values- the given values.- Returns:
thisassertion object.
-
containsExactly
@SafeVarargs public final ListAssert<ELEMENT> containsExactly(ELEMENT... values)
Description copied from class:AbstractIterableAssertVerifies 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:
containsExactlyin interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
containsExactlyin classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
values- the given values.- Returns:
thisassertion object.
-
containsExactlyInAnyOrder
@SafeVarargs public final ListAssert<ELEMENT> containsExactlyInAnyOrder(ELEMENT... values)
Description copied from class:AbstractIterableAssertVerifies 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:
containsExactlyInAnyOrderin interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
containsExactlyInAnyOrderin classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
values- the given values.- Returns:
thisassertion object.
-
isSubsetOf
@SafeVarargs public final ListAssert<ELEMENT> isSubsetOf(ELEMENT... values)
Description copied from class:AbstractIterableAssertVerifies 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:
isSubsetOfin interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
isSubsetOfin classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
values- the values that should be used for checking the elements of actual.- Returns:
- this assertion object.
-
containsSequence
@SafeVarargs public final ListAssert<ELEMENT> containsSequence(ELEMENT... sequence)
Description copied from class:AbstractIterableAssertVerifies 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:
containsSequencein interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
containsSequencein classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
sequence- the sequence of objects to look for.- Returns:
- this assertion object.
-
doesNotContainSequence
@SafeVarargs public final ListAssert<ELEMENT> doesNotContainSequence(ELEMENT... sequence)
Description copied from class:AbstractIterableAssertVerifies 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:
doesNotContainSequencein interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
doesNotContainSequencein classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
sequence- the sequence of objects to look for.- Returns:
- this assertion object.
-
containsSubsequence
@SafeVarargs public final ListAssert<ELEMENT> containsSubsequence(ELEMENT... sequence)
Description copied from class:AbstractIterableAssertVerifies 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:
containsSubsequencein interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
containsSubsequencein classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
sequence- the sequence of objects to look for.- Returns:
- this assertion object.
-
doesNotContainSubsequence
@SafeVarargs public final ListAssert<ELEMENT> doesNotContainSubsequence(ELEMENT... sequence)
Description copied from class:AbstractIterableAssertVerifies 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:
doesNotContainSubsequencein interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
doesNotContainSubsequencein classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
sequence- the sequence of objects to look for.- Returns:
- this assertion object.
-
doesNotContain
@SafeVarargs public final ListAssert<ELEMENT> doesNotContain(ELEMENT... values)
Description copied from interface:ObjectEnumerableAssertVerifies 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:
doesNotContainin interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
doesNotContainin classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
values- the given values.- Returns:
thisassertion object.
-
endsWith
@SafeVarargs public final ListAssert<ELEMENT> endsWith(ELEMENT... sequence)
Description copied from class:AbstractIterableAssertVerifies 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:
endsWithin interfaceObjectEnumerableAssert<ListAssert<ELEMENT>,ELEMENT>- Overrides:
endsWithin classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>- Parameters:
sequence- the sequence of objects to look for.- Returns:
- this assertion object.
-
-