|
||||||||||
| 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<List<?>>
org.fest.assertions.ListAssert
public class ListAssert
Understands assertions for s. To create a new instance of this class use the
method List.
Assertions.assertThat(List)
| Field Summary |
|---|
| Fields inherited from class org.fest.assertions.GenericAssert |
|---|
actual |
| Constructor Summary | |
|---|---|
protected |
ListAssert(List<?> actual)
Creates a new ListAssert. |
| Method Summary | |
|---|---|
protected int |
actualGroupSize()
Returns the number of elements in the actual . |
ListAssert |
as(Description description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
ListAssert |
as(String description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
ListAssert |
contains(Object... objects)
Verifies that the actual contains the given objects, in any order. |
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 |
containsOnly(Object... objects)
Verifies that the actual contains the given objects only, in any order. |
ListAssert |
containsSequence(Object... sequence)
Verifies that the actual contains the given sequence of objects, without any other
objects between them. |
ListAssert |
describedAs(Description description)
Alias for , since "as" is a keyword in
Groovy. |
ListAssert |
describedAs(String description)
Alias for , since "as" is a keyword in
Groovy. |
ListAssert |
doesNotHaveDuplicates()
Verifies that the actual does not have duplicates. |
ListAssert |
doesNotSatisfy(Condition<List<?>> condition)
Verifies that the actual does not satisfy the given condition. |
ListAssert |
endsWith(Object... sequence)
Verifies that the actual ends with the given sequence of objects, without any other
objects between them. |
ListAssert |
excludes(Object... objects)
Verifies that the actual does not contain the given objects. |
ListAssert |
hasSize(int expected)
Verifies that the number of elements in the actual is equal to the given one. |
ListAssert |
is(Condition<List<?>> condition)
Alias for . |
void |
isEmpty()
Verifies that the actual is empty (not null with zero elements.) |
ListAssert |
isEqualTo(List<?> expected)
Verifies that the actual is equal to the given one. |
ListAssert |
isNot(Condition<List<?>> condition)
Alias for . |
ListAssert |
isNotEmpty()
Verifies that the actual contains at least on element. |
ListAssert |
isNotEqualTo(List<?> other)
Verifies that the actual is not equal to the given one. |
ListAssert |
isNotNull()
Verifies that the actual is not null. |
ListAssert |
isNotSameAs(List<?> other)
Verifies that the actual is not the same as the given one. |
void |
isNullOrEmpty()
Verifies that the actual is null or empty. |
ListAssert |
isSameAs(List<?> expected)
Verifies that the actual is the same as the given one. |
ListAssert |
overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one. |
ListAssert |
satisfies(Condition<List<?>> condition)
Verifies that the actual satisfies the given condition. |
ListAssert |
startsWith(Object... sequence)
Verifies that the actual starts with the given sequence of objects, without any other
objects between them. |
| 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 ListAssert(List<?> actual)
ListAssert.
actual - the target to verify.| Method Detail |
|---|
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.public ListAssert contains(Object... objects)
List contains the given objects, in any order.
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 containsOnly(Object... objects)
List contains the given objects only, in any order.
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, or if the actual
List contains elements other than the ones specified.public ListAssert excludes(Object... objects)
List does not contain the given objects.
objects - the objects that the List should exclude.
AssertionError - if the actual List is null.
NullPointerException - if the given array is null.
AssertionError - if the actual List contains any of the given objects.public ListAssert doesNotHaveDuplicates()
List does not have duplicates.
AssertionError - if the actual List is null.
AssertionError - if the actual List has duplicates.public ListAssert 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<List<?>>description - the description of the actual value.
public ListAssert 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<List<?>>description - the description of the actual value.
public ListAssert 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<List<?>>description - the description of the actual value.
public ListAssert 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<List<?>>description - the description of the actual value.
public ListAssert satisfies(Condition<List<?>> condition)
List satisfies the given condition.
satisfies in class GenericAssert<List<?>>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual List does not satisfy the given condition.is(Condition)public ListAssert doesNotSatisfy(Condition<List<?>> condition)
List does not satisfy the given condition.
doesNotSatisfy in class GenericAssert<List<?>>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual List satisfies the given condition.isNot(Condition)public ListAssert is(Condition<List<?>> condition)
satisfies(Condition).
is in class GenericAssert<List<?>>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual List does not satisfy the given condition.public ListAssert isNot(Condition<List<?>> condition)
doesNotSatisfy(Condition).
isNot in class GenericAssert<List<?>>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual List satisfies the given condition.public ListAssert hasSize(int expected)
List is equal to the given one.
hasSize in class GroupAssert<List<?>>expected - the expected number of elements in the actual List.
AssertionError - if the actual List is null.
AssertionError - if the number of elements of the actual List is not equal to the given one.protected int actualGroupSize()
List.
actualGroupSize in class GroupAssert<List<?>>List.public void isEmpty()
List is empty (not null with zero elements.)
isEmpty in class GroupAssert<List<?>>AssertionError - if the actual List is null.
AssertionError - if the actual List is not empty.public ListAssert isNotEmpty()
List contains at least on element.
isNotEmpty in class GroupAssert<List<?>>AssertionError - if the actual List is null.
AssertionError - if the actual List is empty.public void isNullOrEmpty()
List is null or empty.
isNullOrEmpty in class GroupAssert<List<?>>AssertionError - if the actual List is not null or not empty.public ListAssert isNotNull()
List is not null.
isNotNull in class GenericAssert<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 isEqualTo(List<?> expected)
List is equal to the given one.
isEqualTo in class GenericAssert<List<?>>expected - the given List to compare the actual List to.
AssertionError - if the actual List is not equal to the given one.public ListAssert isNotEqualTo(List<?> other)
List is not equal to the given one.
isNotEqualTo in class GenericAssert<List<?>>other - the given List to compare the actual List to.
AssertionError - if the actual List is equal to the given one.public ListAssert isSameAs(List<?> expected)
List is the same as the given one.
isSameAs in class GenericAssert<List<?>>expected - the given List to compare the actual List to.
AssertionError - if the actual List is not the same as the given one.public ListAssert isNotSameAs(List<?> other)
List is not the same as the given one.
isNotSameAs in class GenericAssert<List<?>>other - the given List to compare the actual List to.
AssertionError - if the actual List is the same as the given one.public ListAssert 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<List<?>>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 | |||||||||