|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fest.assertions.Assert
org.fest.assertions.GenericAssert<T>
org.fest.assertions.GroupAssert<T>
org.fest.assertions.ArrayAssert<Object[]>
org.fest.assertions.ObjectArrayAssert
public class ObjectArrayAssert
Understands assertions for Object arrays. To create a new instance of this class use the
method .
Assertions.assertThat(Object[])
| Field Summary |
|---|
| Fields inherited from class org.fest.assertions.GenericAssert |
|---|
actual |
| Constructor Summary | |
|---|---|
protected |
ObjectArrayAssert(Object... actual)
Creates a new ObjectArrayAssert. |
| Method Summary | |
|---|---|
ObjectArrayAssert |
as(Description description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
ObjectArrayAssert |
as(String description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
ObjectArrayAssert |
contains(Object... objects)
Verifies that the actual Object array contains the given objects. |
ObjectArrayAssert |
containsOnly(Object... objects)
Verifies that the actual Object array contains the given objects only. |
ObjectArrayAssert |
describedAs(Description description)
Alias for , since "as" is a keyword in
Groovy. |
ObjectArrayAssert |
describedAs(String description)
Alias for , since "as" is a keyword in
Groovy. |
ObjectArrayAssert |
doesNotHaveDuplicates()
Verifies that the actual Object array does not have duplicates. |
ObjectArrayAssert |
doesNotSatisfy(Condition<Object[]> condition)
Verifies that the actual Object array does not satisfy the given condition. |
ObjectArrayAssert |
excludes(Object... objects)
Verifies that the actual Object array does not contain the given objects. |
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 |
hasSize(int expected)
Verifies that the number of elements in the actual Object array is equal to the given one. |
ObjectArrayAssert |
is(Condition<Object[]> condition)
Alias for . |
ObjectArrayAssert |
isEqualTo(Object[] expected)
Verifies that the actual Object array is equal to the given array. |
ObjectArrayAssert |
isNot(Condition<Object[]> condition)
Alias for . |
ObjectArrayAssert |
isNotEmpty()
Verifies that the actual Object array contains at least on element. |
ObjectArrayAssert |
isNotEqualTo(Object[] array)
Verifies that the actual Object array is not equal to the given array. |
ObjectArrayAssert |
isNotNull()
Verifies that the actual Object array is not null. |
ObjectArrayAssert |
isNotSameAs(Object[] expected)
Verifies that the actual Object array is not the same as the given array. |
ObjectArrayAssert |
isSameAs(Object[] expected)
Verifies that the actual Object array is the same as the given array. |
ObjectArrayAssert |
overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one. |
ObjectArrayAssert |
satisfies(Condition<Object[]> condition)
Verifies that the actual Object array satisfies the given condition. |
| Methods inherited from class org.fest.assertions.ArrayAssert |
|---|
actualGroupSize, actualInBrackets, assertContains, assertContainsOnly, assertExcludes, assertThatActualHasSize, assertThatActualIsNotEmpty, assertThatActualIsNotNull, isEmpty, isNullOrEmpty |
| Methods inherited from class org.fest.assertions.GenericAssert |
|---|
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, isNull |
| Methods inherited from class org.fest.assertions.Assert |
|---|
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected ObjectArrayAssert(Object... actual)
ObjectArrayAssert.
actual - the target to verify.| Method Detail |
|---|
public ObjectArrayAssert as(String description)
AssertionError
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion
failure will not show the provided description.
For example:
assertThat(val).as("name").isEqualTo("Frodo");
as in class GenericAssert<Object[]>description - the description of the actual value.
public ObjectArrayAssert describedAs(String description)
GenericAssert.as(String), since "as" is a keyword in
Groovy. This method should be called before any assertion
method, otherwise any assertion failure will not show the provided description.
For example:
assertThat(val).describedAs("name").isEqualTo("Frodo");
describedAs in class GenericAssert<Object[]>description - the description of the actual value.
public ObjectArrayAssert as(Description description)
AssertionError
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion
failure will not show the provided description.
For example:
assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");
as in class GenericAssert<Object[]>description - the description of the actual value.
public ObjectArrayAssert describedAs(Description description)
GenericAssert.as(Description), since "as" is a keyword in
Groovy. This method should be called before any assertion
method, otherwise any assertion failure will not show the provided description.
For example:
assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");
describedAs in class GenericAssert<Object[]>description - the description of the actual value.
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 contains(Object... objects)
Object array contains the given objects.
objects - the objects to look for.
AssertionError - if the actual Object array is null.
NullPointerException - if the given Object array is null.
AssertionError - if the actual Object array does not contain the given objects.public ObjectArrayAssert containsOnly(Object... objects)
Object array contains the given objects only.
objects - the objects to look for.
AssertionError - if the actual Object array is null.
NullPointerException - if the given Object array is null.
AssertionError - if the actual Object array does not contain the given objects, or if the actual
Object array contains elements other than the ones specified.public ObjectArrayAssert excludes(Object... objects)
Object array does not contain the given objects.
objects - the objects the array should exclude.
AssertionError - if the actual Object array is null.
NullPointerException - if the given Object array is null.
AssertionError - if the actual Object array contains any of the given objects.public ObjectArrayAssert doesNotHaveDuplicates()
Object array does not have duplicates.
AssertionError - if the actual Object array is null.
AssertionError - if the actual Object array has duplicates.public ObjectArrayAssert satisfies(Condition<Object[]> condition)
Object array satisfies the given condition.
satisfies in class GenericAssert<Object[]>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual Object array does not satisfy the given condition.is(Condition)public ObjectArrayAssert doesNotSatisfy(Condition<Object[]> condition)
Object array does not satisfy the given condition.
doesNotSatisfy in class GenericAssert<Object[]>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual Object array satisfies the given condition.isNot(Condition)public ObjectArrayAssert is(Condition<Object[]> condition)
satisfies(Condition).
is in class GenericAssert<Object[]>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual Object array does not satisfy the given condition.public ObjectArrayAssert isNot(Condition<Object[]> condition)
doesNotSatisfy(Condition).
isNot in class GenericAssert<Object[]>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual Object array satisfies the given condition.public ObjectArrayAssert isNotNull()
Object array is not null.
isNotNull in class GenericAssert<Object[]>AssertionError - if the actual Object array is null.public ObjectArrayAssert isNotEmpty()
Object array contains at least on element.
isNotEmpty in class GroupAssert<Object[]>AssertionError - if the actual Object array is null.
AssertionError - if the actual Object array is empty.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<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<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 hasSize(int expected)
Object array is equal to the given one.
hasSize in class GroupAssert<Object[]>expected - the expected number of elements in the actual Object array.
AssertionError - if the actual Object array is null.
AssertionError - if the number of elements in the actual Object array is not equal to the given
one.public ObjectArrayAssert isSameAs(Object[] expected)
Object array is the same as the given array.
isSameAs in class GenericAssert<Object[]>expected - the given array to compare the actual array to.
AssertionError - if the actual Object array is not the same as the given one.public ObjectArrayAssert isNotSameAs(Object[] expected)
Object array is not the same as the given array.
isNotSameAs in class GenericAssert<Object[]>expected - the given array to compare the actual array to.
AssertionError - if the actual Object array is the same as the given one.public ObjectArrayAssert overridingErrorMessage(String message)
For example, the following assertion:
assertThat("Hello").isEqualTo("Bye");
will fail with the default message "expected:<'[Bye]'> but was:<'[Hello]'>."
We can replace this message with our own:
assertThat("Hello").overridingErrorMessage("'Hello' should be equal to 'Bye'").isEqualTo("Bye");
in this case, the assertion will fail showing the message "'Hello' should be equal to 'Bye'".
overridingErrorMessage in class GenericAssert<Object[]>message - the given error message, which will replace the default one.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||