public class ListAssert extends ObjectGroupAssert<ListAssert,List<?>>
Lists.
To create a new instance of this class invoke .
Assertions.assertThat(List)
actual, myself| Modifier | Constructor and Description |
|---|---|
protected |
ListAssert(List<?> actual)
Creates a new
ListAssert. |
| Modifier and Type | Method and Description |
|---|---|
protected List<Object> |
actualAsList()
Returns the actual value as a
List. |
protected Set<Object> |
actualAsSet()
Returns the actual value as a
Set. |
protected int |
actualGroupSize()
Returns the number of elements in the actual
. |
ListAssert |
contains(Object o,
Index index)
Verifies that the actual
contains the given object at the given index. |
ListAssert |
containsExactly(Object... objects)
Verifies that the actual
contains the given objects, in the same order. |
ListAssert |
containsSequence(Object... sequence)
Verifies that the actual
contains the given sequence of objects, without any other
objects between them. |
ListAssert |
endsWith(Object... sequence)
Verifies that the actual
ends with the given sequence of objects, without any other
objects between them. |
ListAssert |
onProperty(String propertyName)
Creates a new instance of
whose target list contains the values of the given
property name from the elements of this ListAssert's list. |
ListAssert |
startsWith(Object... sequence)
Verifies that the actual
starts with the given sequence of objects, without any other
objects between them. |
contains, containsOnly, doesNotHaveDuplicates, excludesassertContains, assertContainsOnly, assertDoesNotHaveDuplicates, assertExcludes, validateIsNotNullhasSize, isEmpty, isNotEmpty, isNullOrEmptyas, as, describedAs, describedAs, doesNotSatisfy, is, isEqualTo, isIn, isIn, isNot, isNotEqualTo, isNotIn, isNotIn, isNotNull, isNotSameAs, isNull, isSameAs, overridingErrorMessage, satisfiescustomErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWithprotected ListAssert(List<?> actual)
ListAssert.actual - the target to verify.public ListAssert contains(Object o, Index index)
List contains the given object at the given index.o - the object to look for.index - the index where the object should be stored in the actual List.NullPointerException - if the given Index is null.IndexOutOfBoundsException - if the value of the given Index is negative, or equal to or greater
than the size of the actual List.AssertionError - if the given List does not contain the given object at the given index.public ListAssert containsSequence(Object... sequence)
List contains the given sequence of objects, without any other
objects between them.sequence - the sequence of objects to look for.AssertionError - if the actual List is null.AssertionError - if the given array is null.AssertionError - if the actual List does not contain the given sequence of objects.public ListAssert startsWith(Object... sequence)
List starts with the given sequence of objects, without any other
objects between them. Same as containsSequence(java.lang.Object...), but verifies also that first given object is
also first element of List.sequence - the sequence of objects to look for.AssertionError - if the actual List is null.AssertionError - if the given array is null.AssertionError - if the actual List is not empty and with the given sequence of objects is
empty.AssertionError - if the actual List does not start with the given sequence of objects.public ListAssert endsWith(Object... sequence)
List ends with the given sequence of objects, without any other
objects between them. Same as containsSequence(java.lang.Object...), but verifies also that last given object is
also last element of List.sequence - the sequence of objects to look for.AssertionError - if the actual List is null.AssertionError - if the given array is null.AssertionError - if the actual List is not empty and with the given sequence of objects is
empty.AssertionError - if the actual List does not end with the given sequence of objects.protected int actualGroupSize()
List.actualGroupSize in class GroupAssert<ListAssert,List<?>>List.AssertionError - if the actual List is null.public ListAssert containsExactly(Object... objects)
List contains the given objects, in the same order. This method works
just like #isEqualTo(List), with the difference that internally the given array is converted
to a List.objects - the objects to look for.AssertionError - if the actual List is null.NullPointerException - if the given array is null.AssertionError - if the actual List does not contain the given objects.public ListAssert onProperty(String propertyName)
ListAssert whose target list contains the values of the given
property name from the elements of this ListAssert's list. Property access works with both simple
properties like Person.age and nested properties Person.father.age.
For example, let's say we have a list of Person objects and you want to verify their age:
assertThat(persons).onProperty("age").containsOnly(25, 16, 44, 37); // simple property
assertThat(persons).onProperty("father.age").containsOnly(55, 46, 74, 62); // nested property
onProperty in class ObjectGroupAssert<ListAssert,List<?>>propertyName - the name of the property to extract values from the actual list to build a new
ListAssert.ListAssert containing the values of the given property name from the elements of this
ListAssert's list.AssertionError - if the actual list is null.org.fest.util.IntrospectionError - if an element in the given list does not have a matching property.protected Set<Object> actualAsSet()
Set.actualAsSet in class ItemGroupAssert<ListAssert,List<?>>Set.protected List<Object> actualAsList()
List.actualAsList in class ItemGroupAssert<ListAssert,List<?>>List.Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.