org.fest.assertions
Class CollectionAssert
java.lang.Object
org.fest.assertions.Assert
org.fest.assertions.GenericAssert<S,A>
org.fest.assertions.GroupAssert<S,A>
org.fest.assertions.ItemGroupAssert<S,A>
org.fest.assertions.ObjectGroupAssert<CollectionAssert,Collection<?>>
org.fest.assertions.CollectionAssert
public class CollectionAssert
- extends ObjectGroupAssert<CollectionAssert,Collection<?>>
Assertions for Collections.
To create a new instance of this class invoke Assertions.assertThat(Collection).
- Author:
- Yvonne Wang, Alex Ruiz
| Methods inherited from class org.fest.assertions.GenericAssert |
as, as, describedAs, describedAs, doesNotSatisfy, is, isEqualTo, isIn, isIn, isNot, isNotEqualTo, isNotIn, isNotIn, isNotNull, isNotSameAs, isNull, isSameAs, overridingErrorMessage, satisfies |
| Methods inherited from class org.fest.assertions.Assert |
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith |
CollectionAssert
protected CollectionAssert(Collection<?> actual)
- Creates a new
CollectionAssert.
- Parameters:
actual - the target to verify.
actualGroupSize
protected int actualGroupSize()
- Returns the number of elements in the actual collection.
- Specified by:
actualGroupSize in class GroupAssert<CollectionAssert,Collection<?>>
- Returns:
- the number of elements in the actual collection.
- Throws:
AssertionError - if the actual collection is null.
onProperty
public CollectionAssert onProperty(String propertyName)
- Creates a new instance of
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
- Specified by:
onProperty in class ObjectGroupAssert<CollectionAssert,Collection<?>>
- Parameters:
propertyName - the name of the property to extract values from the actual collection to build a new
CollectionAssert.
- Returns:
- a new
CollectionAssert containing the values of the given property name from the elements of this
CollectionAssert's collection.
- Throws:
AssertionError - if the actual collection is null.
org.fest.util.IntrospectionError - if an element in the given collection does not have a matching property.- Since:
- 1.3
actualAsSet
protected Set<Object> actualAsSet()
- Returns the actual value as a
Set.
- Specified by:
actualAsSet in class ItemGroupAssert<CollectionAssert,Collection<?>>
- Returns:
- the actual value as a
Set.
actualAsList
protected List<Object> actualAsList()
- Returns the actual value as a
List.
- Specified by:
actualAsList in class ItemGroupAssert<CollectionAssert,Collection<?>>
- Returns:
- the actual value as a
List.
Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.