|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fest.assertions.api.AbstractAssert<S,A>
org.fest.assertions.api.AbstractIterableAssert<ListAssert,List<?>>
org.fest.assertions.api.ListAssert
public class ListAssert
Assertion methods for
s.
List
To create an instance of this class, invoke
.
Assertions.assertThat(List)
Field Summary |
---|
Fields inherited from class org.fest.assertions.api.AbstractAssert |
---|
actual, myself |
Constructor Summary | |
---|---|
protected |
ListAssert(List<?> actual)
|
Method Summary | |
---|---|
ListAssert |
contains(Object value,
Index index)
Verifies that the actual group contains the given object at the given index. |
ListAssert |
doesNotContain(Object value,
Index index)
Verifies that the actual group does not contain the given object at the given index. |
ListAssert |
isSorted()
Verifies that the actual list is sorted into ascending order according to the natural ordering of its elements. |
ListAssert |
isSortedAccordingTo(Comparator<? extends Object> comparator)
Verifies that the actual list is sorted according to the given comparator. |
ListAssert |
usingComparator(Comparator<?> customComparator)
Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks. |
ListAssert |
usingDefaultComparator()
Revert to standard comparison for incoming assertion checks. |
Methods inherited from class org.fest.assertions.api.AbstractIterableAssert |
---|
are, areAtLeast, areAtMost, areExactly, areNot, areNotAtLeast, areNotAtMost, areNotExactly, contains, containsNull, containsOnly, containsSequence, doesNotContain, doesNotContainNull, doesNotHaveDuplicates, doNotHave, doNotHaveAtLeast, doNotHaveAtMost, doNotHaveExactly, endsWith, hasSize, have, haveAtLeast, haveAtMost, haveExactly, isEmpty, isNotEmpty, isNullOrEmpty, isSubsetOf, startsWith |
Methods inherited from class org.fest.assertions.api.AbstractAssert |
---|
as, as, describedAs, describedAs, descriptionText, doesNotHave, equals, has, hashCode, is, isEqualTo, isIn, isIn, isNot, isNotEqualTo, isNotIn, isNotIn, isNotNull, isNotSameAs, isNull, isSameAs |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ListAssert(List<?> actual)
Method Detail |
---|
public ListAssert contains(Object value, Index index)
contains
in interface IndexedObjectEnumerableAssert
value
- the object to look for.index
- the index where the object should be stored in the actual group.
public ListAssert doesNotContain(Object value, Index index)
doesNotContain
in interface IndexedObjectEnumerableAssert
value
- the object to look for.index
- the index where the object should be stored in the actual group.
public ListAssert isSorted()
All list elements must implement the Comparable
interface and must be mutually comparable (that is,
e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the list), examples :
this
assertion object.
AssertionError
- if the actual list is not sorted into ascending order according to the natural ordering of
its elements.
AssertionError
- if the actual list is null
.
AssertionError
- if the actual list element type does not implement Comparable
.
AssertionError
- if the actual list elements are not mutually Comparable
.public ListAssert isSortedAccordingTo(Comparator<? extends Object> comparator)
comparator
- the Comparator
used to compare list elements
this
assertion object.
AssertionError
- if the actual list is not sorted according to the given comparator.
AssertionError
- if the actual list is null
.
NullPointerException
- if the given comparator is null
.
AssertionError
- if the actual list elements are not mutually comparabe according to given Comparator.public ListAssert usingComparator(Comparator<?> customComparator)
AbstractAssert
// compares invoices by payee assertThat(invoiceList).usingComparator(invoicePayeeComparator).isEqualTo(expectedInvoiceList). // compares invoices by date, doesNotHaveDuplicates and contains both use the given invoice date comparator assertThat(invoiceList).usingComparator(invoiceDateComparator).doesNotHaveDuplicates().contains(may2010Invoice) // as assertThat(invoiceList) creates a new assertion, it uses standard comparison strategy (Invoice's equal method) to compare invoiceList elements to lowestInvoice. assertThat(invoiceList).contains(lowestInvoice).Custom comparator is not parameterized with actual type A (ie. Comparator<A>) because if it was, we could not write the following code :
// frodo and sam are instances of Character (a Character having a Race) // raceComparator implements Comparator<Character> // assertThat(frodo) returns an ObjectAssert and not a custom CharacterAssert implementing Assert<CharacterAssert, Character> assertThat(frodo).usingComparator(raceComparator).isEqualTo(sam); // won't compile ! The code does not compile because assertThat(frodo) returns an ObjectAssert, thus usingComparator expects a Comparator<Object> and Comparator<Character> is not a Comparator<Object> as generics are not reified. Note that, it would have worked if assertThat(frodo) returned a CharacterAssert implementing Assert<CharacterAssert, Character>.
usingComparator
in interface Assert<ListAssert,List<?>>
usingComparator
in class AbstractIterableAssert<ListAssert,List<?>>
customComparator
- the comparator to use for incoming assertion checks.
this
assertion object.public ListAssert usingDefaultComparator()
AbstractAssert
Assert.usingComparator(Comparator)
.
usingDefaultComparator
in interface Assert<ListAssert,List<?>>
usingDefaultComparator
in class AbstractIterableAssert<ListAssert,List<?>>
this
assertion object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |