public class ObjectArrayAssert extends ObjectGroupAssert<ObjectArrayAssert,Object[]>
Object arrays.
To create a new instance of this class invoke .
Assertions.assertThat(Object[])
actual, myself| Modifier | Constructor and Description |
|---|---|
protected |
ObjectArrayAssert(Object... actual)
Creates a new
ObjectArrayAssert. |
| 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 size of the actual group of values (array, collection, etc.)
|
ObjectArrayAssert |
hasAllElementsOfType(Class<?> type)
Verifies that all the elements in the actual
Object array belong to the specified type. |
ObjectArrayAssert |
hasAtLeastOneElementOfType(Class<?> type)
Verifies that at least one element in the actual
Object array belong to the specified type. |
ObjectArrayAssert |
isEqualTo(Object[] expected)
Verifies that the actual
Object array is equal to the given array. |
ObjectArrayAssert |
isNotEqualTo(Object[] array)
Verifies that the actual
Object array is not equal to the given array. |
ObjectArrayAssert |
onProperty(String propertyName)
Creates a new instance of
whose target array contains the values of the
given property name from the elements of this ObjectArrayAssert's array. |
contains, containsOnly, doesNotHaveDuplicates, excludesassertContains, assertContainsOnly, assertDoesNotHaveDuplicates, assertExcludes, validateIsNotNullhasSize, isEmpty, isNotEmpty, isNullOrEmptyas, as, describedAs, describedAs, doesNotSatisfy, is, isIn, isIn, isNot, isNotIn, isNotIn, isNotNull, isNotSameAs, isNull, isSameAs, overridingErrorMessage, satisfiescustomErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWithprotected ObjectArrayAssert(Object... actual)
ObjectArrayAssert.actual - the target to verify.public ObjectArrayAssert hasAllElementsOfType(Class<?> type)
Object array belong to the specified type. Matching
includes subclasses of the given type.
For example, consider the following code listing:
Number[] numbers = { 2, 6 ,8 };
assertThat(numbers).hasComponentType(Integer.class);
The assertion hasAllElementsOfType will be successful.
type - the expected type.NullPointerException - if the given type is null.AssertionError - if the component type of the actual Object array is not the same as the
specified one.public ObjectArrayAssert hasAtLeastOneElementOfType(Class<?> type)
Object array belong to the specified type. Matching
includes subclasses of the given type.type - the expected type.AssertionError - if the actual Object does not have any elements of the given type.public ObjectArrayAssert isEqualTo(Object[] expected)
Object array is equal to the given array. Array equality is checked by
Arrays.deepEquals(Object[], Object[]).isEqualTo in class GenericAssert<ObjectArrayAssert,Object[]>expected - the given array to compare the actual array to.AssertionError - if the actual Object array is not equal to the given one.public ObjectArrayAssert isNotEqualTo(Object[] array)
Object array is not equal to the given array. Array equality is checked by
Arrays.deepEquals(Object[], Object[]).isNotEqualTo in class GenericAssert<ObjectArrayAssert,Object[]>array - the given array to compare the actual array to.AssertionError - if the actual Object array is equal to the given one.public ObjectArrayAssert onProperty(String propertyName)
ObjectArrayAssert whose target array contains the values of the
given property name from the elements of this ObjectArrayAssert's array. Property access works with both
simple properties like Person.age and nested properties Person.father.age.
For example, let's say we have a array 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<ObjectArrayAssert,Object[]>propertyName - the name of the property to extract values from the actual array to build a new
ObjectArrayAssert.ObjectArrayAssert containing the values of the given property name from the elements of this
ObjectArrayAssert's array.AssertionError - if the actual array is null.org.fest.util.IntrospectionError - if an element in the given array does not have a matching property.protected Set<Object> actualAsSet()
Set.actualAsSet in class ItemGroupAssert<ObjectArrayAssert,Object[]>Set.protected List<Object> actualAsList()
List.actualAsList in class ItemGroupAssert<ObjectArrayAssert,Object[]>List.protected int actualGroupSize()
actualGroupSize in class GroupAssert<ObjectArrayAssert,Object[]>Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.