public class CollectionAssert extends ObjectGroupAssert<CollectionAssert,Collection<?>>
Collections.
To create a new instance of this class invoke .
Assertions.assertThat(Collection)
actual, myself| Modifier | Constructor and Description |
|---|---|
protected |
CollectionAssert(Collection<?> actual)
Creates a new
CollectionAssert. |
| 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 collection.
|
CollectionAssert |
onProperty(String propertyName)
Creates a new instance of
whose target collection contains the values of the
given property name from the elements of this CollectionAssert's collection. |
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 CollectionAssert(Collection<?> actual)
CollectionAssert.actual - the target to verify.protected int actualGroupSize()
actualGroupSize in class GroupAssert<CollectionAssert,Collection<?>>AssertionError - if the actual collection is null.public CollectionAssert onProperty(String propertyName)
CollectionAssert whose target collection contains the values of the
given property name from the elements of this CollectionAssert's collection. Property access works with
both simple properties like Person.age and nested properties Person.father.age.
For example, let's say we have a collection 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<CollectionAssert,Collection<?>>propertyName - the name of the property to extract values from the actual collection to build a new
CollectionAssert.CollectionAssert containing the values of the given property name from the elements of this
CollectionAssert's collection.AssertionError - if the actual collection is null.org.fest.util.IntrospectionError - if an element in the given collection does not have a matching property.protected Set<Object> actualAsSet()
Set.actualAsSet in class ItemGroupAssert<CollectionAssert,Collection<?>>Set.protected List<Object> actualAsList()
List.actualAsList in class ItemGroupAssert<CollectionAssert,Collection<?>>List.Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.