|
||||||||||
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<T>,List<T>,T>
org.fest.assertions.api.ListAssert<T>
public class ListAssert<T>
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<T> actual)
|
Method Summary | |
---|---|
ListAssert<T> |
contains(T value,
Index index)
Verifies that the actual group contains the given object at the given index. |
ListAssert<T> |
doesNotContain(T value,
Index index)
Verifies that the actual group does not contain the given object at the given index. |
ListAssert<T> |
isSorted()
Verifies that the actual list is sorted into ascending order according to the natural ordering of its elements. |
ListAssert<T> |
isSortedAccordingTo(Comparator<? super T> comparator)
Verifies that the actual list is sorted according to the given comparator. |
ListAssert<T> |
usingDefaultElementComparator()
Revert to standard comparison for incoming assertion group element checks. |
ListAssert<T> |
usingElementComparator(Comparator<? super T> customComparator)
Use given custom comparator instead of relying on actual type A equals method to compare group
elements for incoming assertion checks. |
Methods inherited from class org.fest.assertions.api.AbstractIterableAssert |
---|
are, areAtLeast, areAtMost, areExactly, areNot, areNotAtLeast, areNotAtMost, areNotExactly, contains, containsAll, containsNull, containsOnly, containsSequence, doesNotContain, doesNotContainNull, doesNotHaveDuplicates, doNotHave, doNotHaveAtLeast, doNotHaveAtMost, doNotHaveExactly, endsWith, hasSameSizeAs, hasSameSizeAs, 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, usingComparator, usingDefaultComparator |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ListAssert(List<T> actual)
Method Detail |
---|
public ListAssert<T> contains(T value, Index index)
contains
in interface IndexedObjectEnumerableAssert<T>
value
- the object to look for.index
- the index where the object should be stored in the actual group.
public ListAssert<T> doesNotContain(T value, Index index)
doesNotContain
in interface IndexedObjectEnumerableAssert<T>
value
- the object to look for.index
- the index where the object should be stored in the actual group.
public ListAssert<T> 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<T> isSortedAccordingTo(Comparator<? super T> 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 comparable according to given Comparator.public ListAssert<T> usingElementComparator(Comparator<? super T> customComparator)
AbstractIterableAssert
equals
method to compare group
elements for incoming assertion checks.
Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy.
Examples :
// 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 falls back to standard comparison strategy // based on Invoice's equal method to compare invoiceList elements to lowestInvoice. assertThat(invoiceList).contains(lowestInvoice). // standard comparison : the fellowshipOfTheRing includes Gandalf but not Sauron (believe me) ... assertThat(fellowshipOfTheRing).contains(gandalf) .doesNotContain(sauron); // ... but if we compare only races, Sauron is in fellowshipOfTheRing because he's a Maia like Gandalf. assertThat(fellowshipOfTheRing).usingElementComparator(raceComparator) .contains(sauron);
usingElementComparator
in interface EnumerableAssert<ListAssert<T>,T>
usingElementComparator
in class AbstractIterableAssert<ListAssert<T>,List<T>,T>
customComparator
- the comparator to use for incoming assertion checks.
this
assertion object.public ListAssert<T> usingDefaultElementComparator()
AbstractIterableAssert
This method should be used to disable a custom comparison strategy set by calling
EnumerableAssert.usingElementComparator(Comparator)
.
usingDefaultElementComparator
in interface EnumerableAssert<ListAssert<T>,T>
usingDefaultElementComparator
in class AbstractIterableAssert<ListAssert<T>,List<T>,T>
this
assertion object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |