|
||||||||||
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>
S
- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation"
for more details.A
- the type of the "actual" value.public abstract class AbstractAssert<S extends AbstractAssert<S,A>,A>
Base class for all assertions.
Field Summary | |
---|---|
protected A |
actual
|
protected S |
myself
|
Constructor Summary | |
---|---|
protected |
AbstractAssert(A actual,
Class<?> selfType)
|
Method Summary | |
---|---|
S |
as(Description description)
Sets the description of this object. |
S |
as(String description)
Sets the description of this object. |
S |
describedAs(Description description)
Alias for since "as" is a keyword in Groovy. |
S |
describedAs(String description)
Alias for since "as" is a keyword in Groovy. |
String |
descriptionText()
The description of this assertion set with describedAs(String) or describedAs(Description) . |
S |
doesNotHave(Condition<A> condition)
Verifies that the actual value does not satisfy the given condition. |
boolean |
equals(Object obj)
Throws if called. |
S |
has(Condition<A> condition)
Verifies that the actual value satisfies the given condition. |
int |
hashCode()
Always returns 1. |
S |
is(Condition<A> condition)
Verifies that the actual value satisfies the given condition. |
S |
isEqualTo(A expected)
Verifies that the actual value is equal to the given one. |
S |
isIn(A... values)
Verifies that the actual value is present in the given array of values. |
S |
isIn(Iterable<? extends A> values)
Verifies that the actual value is present in the given values. |
S |
isNot(Condition<A> condition)
Verifies that the actual value does not satisfy the given condition. |
S |
isNotEqualTo(A other)
Verifies that the actual value is not equal to the given one. |
S |
isNotIn(A... values)
Verifies that the actual value is not present in the given array of values. |
S |
isNotIn(Iterable<? extends A> values)
Verifies that the actual value is not present in the given values. |
S |
isNotNull()
Verifies that the actual value is not null . |
S |
isNotSameAs(A other)
Verifies that the actual value is not the same as the given one. |
void |
isNull()
Verifies that the actual value is null . |
S |
isSameAs(A expected)
Verifies that the actual value is the same as the given one. |
S |
usingComparator(Comparator<?> customComparator)
Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks. |
S |
usingDefaultComparator()
Revert to standard comparison for incoming assertion checks. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final A actual
protected final S extends AbstractAssert<S,A> myself
Constructor Detail |
---|
protected AbstractAssert(A actual, Class<?> selfType)
Method Detail |
---|
public final S as(String description)
as
in interface Descriptable<S extends AbstractAssert<S,A>>
description
- the new description to set.
this
object.Descriptable.describedAs(String)
public final S as(Description description)
EmptyTextDescription
as argument.
This overloaded version of "describedAs" offers more flexibility than the one taking a String
by allowing
users to pass their own implementation of a description. For example, a description that creates its value lazily,
only when an assertion failure occurs.
as
in interface Descriptable<S extends AbstractAssert<S,A>>
description
- the new description to set.
this
object.Descriptable.describedAs(Description)
public final S describedAs(String description)
Descriptable.as(String)
since "as" is a keyword in Groovy.
describedAs
in interface Descriptable<S extends AbstractAssert<S,A>>
description
- the new description to set.
this
object.public final S describedAs(Description description)
Descriptable.as(String)
since "as" is a keyword in Groovy. To remove or clear the description, pass a EmptyTextDescription
as
argument.
This overloaded version of "describedAs" offers more flexibility than the one taking a String
by allowing
users to pass their own implementation of a description. For example, a description that creates its value lazily,
only when an assertion failure occurs.
describedAs
in interface Descriptable<S extends AbstractAssert<S,A>>
description
- the new description to set.
this
object.public S isEqualTo(A expected)
isEqualTo
in interface Assert<S extends AbstractAssert<S,A>,A>
expected
- the given value to compare the actual value to.
this
assertion object.public S isNotEqualTo(A other)
isNotEqualTo
in interface Assert<S extends AbstractAssert<S,A>,A>
other
- the given value to compare the actual value to.
this
assertion object.public final void isNull()
null
.
isNull
in interface Assert<S extends AbstractAssert<S,A>,A>
public final S isNotNull()
null
.
isNotNull
in interface Assert<S extends AbstractAssert<S,A>,A>
this
assertion object.public final S isSameAs(A expected)
isSameAs
in interface Assert<S extends AbstractAssert<S,A>,A>
expected
- the given value to compare the actual value to.
this
assertion object.public final S isNotSameAs(A other)
isNotSameAs
in interface Assert<S extends AbstractAssert<S,A>,A>
other
- the given value to compare the actual value to.
this
assertion object.public final S isIn(A... values)
isIn
in interface Assert<S extends AbstractAssert<S,A>,A>
values
- the given array to search the actual value in.
this
assertion object.public final S isNotIn(A... values)
isNotIn
in interface Assert<S extends AbstractAssert<S,A>,A>
values
- the given array to search the actual value in.
this
assertion object.public final S isIn(Iterable<? extends A> values)
isIn
in interface Assert<S extends AbstractAssert<S,A>,A>
values
- the given iterable to search the actual value in.
this
assertion object.public final S isNotIn(Iterable<? extends A> values)
isNotIn
in interface Assert<S extends AbstractAssert<S,A>,A>
values
- the given iterable to search the actual value in.
this
assertion object.public final S is(Condition<A> condition)
ExtensionPoints.has(Condition)
.
is
in interface ExtensionPoints<S extends AbstractAssert<S,A>,A>
condition
- the given condition.
this ExtensionPoints
object.ExtensionPoints.is(Condition)
public final S isNot(Condition<A> condition)
ExtensionPoints.doesNotHave(Condition)
.
isNot
in interface ExtensionPoints<S extends AbstractAssert<S,A>,A>
condition
- the given condition.
this ExtensionPoints
object.ExtensionPoints.isNot(Condition)
public final S has(Condition<A> condition)
ExtensionPoints.is(Condition)
.
has
in interface ExtensionPoints<S extends AbstractAssert<S,A>,A>
condition
- the given condition.
this ExtensionPoints
object.ExtensionPoints.is(Condition)
public final S doesNotHave(Condition<A> condition)
ExtensionPoints.isNot(Condition)
.
doesNotHave
in interface ExtensionPoints<S extends AbstractAssert<S,A>,A>
condition
- the given condition.
this ExtensionPoints
object.ExtensionPoints.isNot(Condition)
public final String descriptionText()
describedAs(String)
or describedAs(Description)
.
public S usingComparator(Comparator<?> customComparator)
// 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<S extends AbstractAssert<S,A>,A>
customComparator
- the comparator to use for incoming assertion checks.
this
assertion object.public S usingDefaultComparator()
Assert.usingComparator(Comparator)
.
usingDefaultComparator
in interface Assert<S extends AbstractAssert<S,A>,A>
this
assertion object.public final boolean equals(Object obj)
UnsupportedOperationException
if called. It is easy to accidentally call
Assert.equals(Object)
instead of isEqualTo
.
equals
in interface Assert<S extends AbstractAssert<S,A>,A>
equals
in class Object
public final int hashCode()
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |