|
||||||||||
| 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>
T - the type of object implementations of this template can verify.public abstract class GenericAssert<T>
Understands a template for assertion methods.
| Field Summary | |
|---|---|
protected T |
actual
|
| Constructor Summary | |
|---|---|
protected |
GenericAssert(T actual)
Creates a new . |
| Method Summary | |
|---|---|
protected abstract GenericAssert<T> |
as(Description description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
protected abstract GenericAssert<T> |
as(String description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
protected void |
assertDoesNotSatisfy(Condition<T> condition)
Verifies that the actual value does not satisfy the given condition. |
protected void |
assertEqualTo(T expected)
Verifies that the actual value is equal to the given one. |
protected void |
assertIs(Condition<T> condition)
Verifies that the actual value satisfies the given condition. |
protected void |
assertIsNot(Condition<T> condition)
Verifies that the actual value does not satisfy the given condition. |
protected void |
assertNotEqualTo(T other)
Verifies that the actual value is not equal to the given one. |
protected void |
assertNotNull()
Verifies that the actual value is not null. |
protected void |
assertNotSameAs(T expected)
Verifies that the actual value is not the same as the given one. |
protected void |
assertSameAs(T expected)
Verifies that the actual value is the same as the given one. |
protected void |
assertSatisfies(Condition<T> condition)
Verifies that the actual value satisfies the given condition. |
protected abstract GenericAssert<T> |
describedAs(Description description)
Alias for , since "as" is a keyword in
Groovy. |
protected abstract GenericAssert<T> |
describedAs(String description)
Alias for , since "as" is a keyword in
Groovy. |
protected abstract GenericAssert<T> |
doesNotSatisfy(Condition<T> condition)
Verifies that the actual value does not satisfy the given condition. |
protected abstract GenericAssert<T> |
is(Condition<T> condition)
Alias for . |
protected abstract GenericAssert<T> |
isEqualTo(T expected)
Verifies that the actual value is equal to the given one. |
protected abstract GenericAssert<T> |
isNot(Condition<T> condition)
Alias for . |
protected abstract GenericAssert<T> |
isNotEqualTo(T other)
Verifies that the actual value is not equal to the given one. |
protected abstract GenericAssert<T> |
isNotNull()
Verifies that the actual value is not null. |
protected abstract GenericAssert<T> |
isNotSameAs(T other)
Verifies that the actual value is not the same as the given one. |
void |
isNull()
Asserts that the actual value (specified in the constructor of this class) is null. |
protected abstract GenericAssert<T> |
isSameAs(T expected)
Verifies that the actual value is the same as the given one. |
protected abstract GenericAssert<T> |
overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one. |
protected abstract GenericAssert<T> |
satisfies(Condition<T> condition)
Verifies that the actual value satisfies the given condition. |
| 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 |
| Field Detail |
|---|
protected final T actual
| Constructor Detail |
|---|
protected GenericAssert(T actual)
GenericAssert.
actual - the actual target to verify.| Method Detail |
|---|
public final void isNull()
null.
AssertionError - if the actual value is not null.protected abstract GenericAssert<T> satisfies(Condition<T> condition)
condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual value does not satisfy the given condition.is(Condition)protected abstract GenericAssert<T> doesNotSatisfy(Condition<T> condition)
condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual value does satisfies the given condition.isNot(Condition)protected abstract GenericAssert<T> is(Condition<T> condition)
satisfies(Condition).
condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual value does not satisfy the given condition.protected abstract GenericAssert<T> isNot(Condition<T> condition)
doesNotSatisfy(Condition).
condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual value does satisfies the given condition.protected abstract GenericAssert<T> 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");
description - the description of the actual value.
protected abstract GenericAssert<T> describedAs(String description)
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");
description - the description of the actual value.
protected abstract GenericAssert<T> 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");
description - the description of the actual value.
protected abstract GenericAssert<T> describedAs(Description description)
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");
description - the description of the actual value.
protected abstract GenericAssert<T> isEqualTo(T expected)
expected - the given value to compare the actual value to.
AssertionError - if the actual value is not equal to the given one.protected abstract GenericAssert<T> isNotEqualTo(T other)
other - the given value to compare the actual value to.
AssertionError - if the actual value is equal to the given one.protected abstract GenericAssert<T> isNotNull()
null.
AssertionError - if the actual value is null.protected abstract GenericAssert<T> isSameAs(T expected)
expected - the given value to compare the actual value to.
AssertionError - if the actual value is not the same as the given one.protected abstract GenericAssert<T> isNotSameAs(T other)
other - the given value to compare the actual value to.
AssertionError - if the actual value is the same as the given one.protected final void assertSatisfies(Condition<T> condition)
condition - the condition to check.
NullPointerException - if the given condition is null.
AssertionError - if the actual value does not satisfy the given condition.protected final void assertIs(Condition<T> condition)
condition - the condition to check.
NullPointerException - if the given condition is null.
AssertionError - if the actual value does not satisfy the given condition.protected final void assertDoesNotSatisfy(Condition<T> condition)
condition - the condition to check.
NullPointerException - if the given condition is null.
AssertionError - if the actual value satisfies the given condition.protected final void assertIsNot(Condition<T> condition)
condition - the condition to check.
NullPointerException - if the given condition is null.
AssertionError - if the actual value satisfies the given condition.protected final void assertEqualTo(T expected)
expected - the value to compare the actual value to.
AssertionError - if the actual value is not equal to the given one.protected final void assertNotEqualTo(T other)
other - the value to compare the actual value to.
AssertionError - if the actual value is equal to the given one.protected final void assertNotNull()
null.
AssertionError - if the actual value is null.protected final void assertSameAs(T expected)
expected - the value to compare the actual value to.
AssertionError - if the actual value is not the same as the given one.protected final void assertNotSameAs(T expected)
expected - the value to compare the actual value to.
AssertionError - if the actual value is the same as the given one.protected abstract GenericAssert<T> 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'".
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 | |||||||||