|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fest.assertions.api.AbstractAssert<ObjectArrayAssert,Object[]>
org.fest.assertions.api.ObjectArrayAssert
public class ObjectArrayAssert
Assertion methods for arrays of objects.
To create an instance of this class, invoke .
Assertions.assertThat(Object[])
| Field Summary |
|---|
| Fields inherited from class org.fest.assertions.api.AbstractAssert |
|---|
actual, myself |
| Constructor Summary | |
|---|---|
protected |
ObjectArrayAssert(Object[] actual)
|
| Method Summary | ||
|---|---|---|
|
are(Condition<E> condition)
Verifies that each element value satisfies the given condition |
|
|
areAtLeast(int times,
Condition<E> condition)
Verifies that there is at least n elements in the actual group satisfying the given condition. |
|
|
areAtMost(int times,
Condition<E> condition)
Verifies that there is at most n elements in the actual group satisfying the given condition. |
|
|
areExactly(int times,
Condition<E> condition)
Verifies that there is exactly n elements in the actual group satisfying the given condition. |
|
|
areNot(Condition<E> condition)
Verifies that each element value not satisfies the given condition |
|
|
areNotAtLeast(int times,
Condition<E> condition)
Verifies that there is at least n elements in the actual group not satisfying the given condition. |
|
|
areNotAtMost(int times,
Condition<E> condition)
Verifies that there is at most n elements in the actual group not satisfying the given condition. |
|
|
areNotExactly(int times,
Condition<E> condition)
Verifies that there is exactly n elements in the actual group not satisfying the given condition. |
|
ObjectArrayAssert |
contains(Object... values)
Verifies that the actual group contains the given values, in any order. |
|
ObjectArrayAssert |
contains(Object value,
Index index)
Verifies that the actual group contains the given object at the given index. |
|
ObjectArrayAssert |
containsNull()
Verifies that the actual group contains at least a null element. |
|
ObjectArrayAssert |
containsOnly(Object... values)
Verifies that the actual group contains only the given values and nothing else, in any order. |
|
ObjectArrayAssert |
containsSequence(Object... sequence)
Verifies that the actual group contains the given sequence, without any other values between them. |
|
ObjectArrayAssert |
doesNotContain(Object... values)
Verifies that the actual group does not contain the given values. |
|
ObjectArrayAssert |
doesNotContain(Object value,
Index index)
Verifies that the actual group does not contain the given object at the given index. |
|
ObjectArrayAssert |
doesNotContainNull()
Verifies that the actual group does not contain null elements. |
|
ObjectArrayAssert |
doesNotHaveDuplicates()
Verifies that the actual group does not contain duplicates. |
|
|
doNotHave(Condition<E> condition)
Verifies that each element value not satisfies the given condition |
|
|
doNotHaveAtLeast(int times,
Condition<E> condition)
This method is an alias ObjectEnumerableAssert.areNotAtLeast(int, Condition). |
|
|
doNotHaveAtMost(int times,
Condition<E> condition)
This method is an alias ObjectEnumerableAssert.areNotAtMost(int, Condition). |
|
|
doNotHaveExactly(int times,
Condition<E> condition)
This method is an alias ObjectEnumerableAssert.areNotExactly(int, Condition). |
|
ObjectArrayAssert |
endsWith(Object... sequence)
Verifies that the actual group ends with the given sequence of objects, without any other objects between them. |
|
ObjectArrayAssert |
hasSameSizeAs(Iterable<?> other)
Verifies that the actual group has the same size as given Iterable. |
|
ObjectArrayAssert |
hasSameSizeAs(Object[] other)
Verifies that the actual group has the same size as given array. |
|
ObjectArrayAssert |
hasSize(int expected)
Verifies that the number of values in the actual group is equal to the given one. |
|
|
have(Condition<E> condition)
Verifies that each element value satisfies the given condition |
|
|
haveAtLeast(int times,
Condition<E> condition)
This method is an alias for ObjectEnumerableAssert.areAtLeast(int, Condition). |
|
|
haveAtMost(int times,
Condition<E> condition)
This method is an alias ObjectEnumerableAssert.areAtMost(int, Condition). |
|
|
haveExactly(int times,
Condition<E> condition)
This method is an alias ObjectEnumerableAssert.areExactly(int, Condition). |
|
void |
isEmpty()
Verifies that the actual group of values is empty. |
|
ObjectArrayAssert |
isNotEmpty()
Verifies that the actual group of values is not empty. |
|
void |
isNullOrEmpty()
Verifies that the actual group of values is null or empty. |
|
ObjectArrayAssert |
isSorted()
Verifies that the actual array is sorted into ascending order according to the natural ordering of its elements. |
|
ObjectArrayAssert |
isSortedAccordingTo(Comparator<? extends Object> comparator)
Verifies that the actual array is sorted according to the given comparator. |
|
ObjectArrayAssert |
startsWith(Object... sequence)
Verifies that the actual group starts with the given sequence of objects, without any other objects between them. |
|
ObjectArrayAssert |
usingComparator(Comparator<?> customComparator)
Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks. |
|
ObjectArrayAssert |
usingDefaultComparator()
Revert to standard comparison for incoming assertion checks. |
|
| 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 ObjectArrayAssert(Object[] actual)
| Method Detail |
|---|
public void isNullOrEmpty()
null or empty.
isNullOrEmpty in interface EnumerableAssert<ObjectArrayAssert>public void isEmpty()
isEmpty in interface EnumerableAssert<ObjectArrayAssert>public ObjectArrayAssert isNotEmpty()
isNotEmpty in interface EnumerableAssert<ObjectArrayAssert>this assertion object.public ObjectArrayAssert hasSize(int expected)
hasSize in interface EnumerableAssert<ObjectArrayAssert>expected - the expected number of values in the actual group.
this assertion object.public ObjectArrayAssert hasSameSizeAs(Object[] other)
hasSameSizeAs in interface ObjectEnumerableAssert<ObjectArrayAssert>other - the array to compare size with actual group.
this assertion object.public ObjectArrayAssert hasSameSizeAs(Iterable<?> other)
Iterable.
hasSameSizeAs in interface ObjectEnumerableAssert<ObjectArrayAssert>other - the Iterable to compare size with actual group.
this assertion object.public ObjectArrayAssert contains(Object... values)
contains in interface ObjectEnumerableAssert<ObjectArrayAssert>values - the given values.
this assertion object.public ObjectArrayAssert containsOnly(Object... values)
containsOnly in interface ObjectEnumerableAssert<ObjectArrayAssert>values - the given values.
this assertion object.public ObjectArrayAssert containsSequence(Object... sequence)
containsSequence in interface ObjectEnumerableAssert<ObjectArrayAssert>sequence - the sequence of objects to look for.
public ObjectArrayAssert contains(Object value,
Index index)
contains in interface IndexedObjectEnumerableAssertvalue - the object to look for.index - the index where the object should be stored in the actual group.
public ObjectArrayAssert doesNotContain(Object value,
Index index)
doesNotContain in interface IndexedObjectEnumerableAssertvalue - the object to look for.index - the index where the object should be stored in the actual group.
public ObjectArrayAssert doesNotContain(Object... values)
doesNotContain in interface ObjectEnumerableAssert<ObjectArrayAssert>values - the given values.
this assertion object.public ObjectArrayAssert doesNotHaveDuplicates()
doesNotHaveDuplicates in interface ObjectEnumerableAssert<ObjectArrayAssert>this assertion object.public ObjectArrayAssert startsWith(Object... sequence)
ObjectEnumerableAssert.containsSequence(Object...), but it also verifies that the first element in the
sequence is also first element of the actual group.
startsWith in interface ObjectEnumerableAssert<ObjectArrayAssert>sequence - the sequence of objects to look for.
public ObjectArrayAssert endsWith(Object... sequence)
ObjectEnumerableAssert.containsSequence(Object...), but it also verifies that the last element in the
sequence is also last element of the actual group.
endsWith in interface ObjectEnumerableAssert<ObjectArrayAssert>sequence - the sequence of objects to look for.
public ObjectArrayAssert containsNull()
containsNull in interface ObjectEnumerableAssert<ObjectArrayAssert>this assertion object.public ObjectArrayAssert doesNotContainNull()
doesNotContainNull in interface ObjectEnumerableAssert<ObjectArrayAssert>this assertion object.public <E> ObjectArrayAssert are(Condition<E> condition)
are in interface ObjectEnumerableAssert<ObjectArrayAssert>condition - the given condition.
this object.public <E> ObjectArrayAssert areNot(Condition<E> condition)
areNot in interface ObjectEnumerableAssert<ObjectArrayAssert>condition - the given condition.
this object.public <E> ObjectArrayAssert have(Condition<E> condition)
have in interface ObjectEnumerableAssert<ObjectArrayAssert>condition - the given condition.
this object.public <E> ObjectArrayAssert doNotHave(Condition<E> condition)
doNotHave in interface ObjectEnumerableAssert<ObjectArrayAssert>condition - the given condition.
this object.
public <E> ObjectArrayAssert areAtLeast(int times,
Condition<E> condition)
areAtLeast in interface ObjectEnumerableAssert<ObjectArrayAssert>times - the minimum number of times the condition should be verified.condition - the given condition.
this object.
public <E> ObjectArrayAssert areNotAtLeast(int times,
Condition<E> condition)
areNotAtLeast in interface ObjectEnumerableAssert<ObjectArrayAssert>times - the number of times the condition should not be verified at least.condition - the given condition.
this object.
public <E> ObjectArrayAssert areAtMost(int times,
Condition<E> condition)
areAtMost in interface ObjectEnumerableAssert<ObjectArrayAssert>times - the number of times the condition should be at most verified.condition - the given condition.
this object.
public <E> ObjectArrayAssert areNotAtMost(int times,
Condition<E> condition)
areNotAtMost in interface ObjectEnumerableAssert<ObjectArrayAssert>times - the number of times the condition should not be verified at most.condition - the given condition.
this object.
public <E> ObjectArrayAssert areExactly(int times,
Condition<E> condition)
areExactly in interface ObjectEnumerableAssert<ObjectArrayAssert>times - the exact number of times the condition should be verified.condition - the given condition.
this object.
public <E> ObjectArrayAssert areNotExactly(int times,
Condition<E> condition)
areNotExactly in interface ObjectEnumerableAssert<ObjectArrayAssert>times - the exact number of times the condition should not be verified.condition - the given condition.
this object.
public <E> ObjectArrayAssert haveAtLeast(int times,
Condition<E> condition)
ObjectEnumerableAssert.areAtLeast(int, Condition).
haveAtLeast in interface ObjectEnumerableAssert<ObjectArrayAssert>
public <E> ObjectArrayAssert doNotHaveAtLeast(int times,
Condition<E> condition)
ObjectEnumerableAssert.areNotAtLeast(int, Condition).
doNotHaveAtLeast in interface ObjectEnumerableAssert<ObjectArrayAssert>
public <E> ObjectArrayAssert haveAtMost(int times,
Condition<E> condition)
ObjectEnumerableAssert.areAtMost(int, Condition).
haveAtMost in interface ObjectEnumerableAssert<ObjectArrayAssert>
public <E> ObjectArrayAssert doNotHaveAtMost(int times,
Condition<E> condition)
ObjectEnumerableAssert.areNotAtMost(int, Condition).
doNotHaveAtMost in interface ObjectEnumerableAssert<ObjectArrayAssert>
public <E> ObjectArrayAssert haveExactly(int times,
Condition<E> condition)
ObjectEnumerableAssert.areExactly(int, Condition).
haveExactly in interface ObjectEnumerableAssert<ObjectArrayAssert>
public <E> ObjectArrayAssert doNotHaveExactly(int times,
Condition<E> condition)
ObjectEnumerableAssert.areNotExactly(int, Condition).
doNotHaveExactly in interface ObjectEnumerableAssert<ObjectArrayAssert>public ObjectArrayAssert isSorted()
All array elements must be primitive or 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 array), examples :
isSorted in interface ArraySortedAssert<ObjectArrayAssert,Object>this assertion object.public ObjectArrayAssert isSortedAccordingTo(Comparator<? extends Object> comparator)
isSortedAccordingTo in interface ArraySortedAssert<ObjectArrayAssert,Object>comparator - the Comparator used to compare array elements
this assertion object.public ObjectArrayAssert 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<ObjectArrayAssert,Object[]>usingComparator in class AbstractAssert<ObjectArrayAssert,Object[]>customComparator - the comparator to use for incoming assertion checks.
this assertion object.public ObjectArrayAssert usingDefaultComparator()
AbstractAssertAssert.usingComparator(Comparator).
usingDefaultComparator in interface Assert<ObjectArrayAssert,Object[]>usingDefaultComparator in class AbstractAssert<ObjectArrayAssert,Object[]>this assertion object.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||