|
||||||||||
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<Object>
org.fest.assertions.ObjectAssert
public class ObjectAssert
Understands assertion methods for objects. To create a new instance of this class use the
method
.
Assertions.assertThat(Object)
Field Summary |
---|
Fields inherited from class org.fest.assertions.GenericAssert |
---|
actual |
Constructor Summary | |
---|---|
protected |
ObjectAssert(Object actual)
Creates a new ObjectAssert . |
Method Summary | |
---|---|
ObjectAssert |
as(Description description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
ObjectAssert |
as(String description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
ObjectAssert |
describedAs(Description description)
Alias for , since "as" is a keyword in
Groovy. |
ObjectAssert |
describedAs(String description)
Alias for , since "as" is a keyword in
Groovy. |
ObjectAssert |
doesNotSatisfy(Condition<Object> condition)
Verifies that the actual Object does not satisfy the given condition. |
ObjectAssert |
is(Condition<Object> condition)
Alias for . |
ObjectAssert |
isEqualTo(Object expected)
Verifies that the actual Object is equal to the given one. |
ObjectAssert |
isInstanceOf(Class<?> type)
Verifies that the actual Object is an instance of the given type. |
ObjectAssert |
isInstanceOfAny(Class<?>... types)
Verifies that the actual Object is an instance of any of the given types. |
ObjectAssert |
isNot(Condition<Object> condition)
Alias for . |
ObjectAssert |
isNotEqualTo(Object other)
Verifies that the actual Object is not equal to the given one. |
ObjectAssert |
isNotNull()
Verifies that the actual Object is not null . |
ObjectAssert |
isNotSameAs(Object other)
Verifies that the actual Object is not the same as the given one. |
ObjectAssert |
isSameAs(Object expected)
Verifies that the actual Object is the same as the given one. |
ObjectAssert |
overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one. |
ObjectAssert |
satisfies(Condition<Object> condition)
Verifies that the actual Object satisfies the given condition. |
Methods inherited from class org.fest.assertions.GenericAssert |
---|
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, isNull |
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 |
Constructor Detail |
---|
protected ObjectAssert(Object actual)
ObjectAssert
.
actual
- the target to verify.Method Detail |
---|
public ObjectAssert isInstanceOf(Class<?> type)
Object
is an instance of the given type.
type
- the type to check the actual Object
against.
AssertionError
- if the actual Object
is null
.
AssertionError
- if the actual Object
is not an instance of the given type.
NullPointerException
- if the given type is null
.public ObjectAssert isInstanceOfAny(Class<?>... types)
Object
is an instance of any of the given types.
types
- the types to check the actual Object
against.
AssertionError
- if the actual Object
is null
.
AssertionError
- if the actual Object
is not an instance of any of the given types.
NullPointerException
- if the given array of types is null
.
NullPointerException
- if the given array of types contains null
s.public ObjectAssert 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");
as
in class GenericAssert<Object>
description
- the description of the actual value.
public ObjectAssert describedAs(String description)
GenericAssert.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");
describedAs
in class GenericAssert<Object>
description
- the description of the actual value.
public ObjectAssert 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");
as
in class GenericAssert<Object>
description
- the description of the actual value.
public ObjectAssert describedAs(Description description)
GenericAssert.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");
describedAs
in class GenericAssert<Object>
description
- the description of the actual value.
public ObjectAssert satisfies(Condition<Object> condition)
Object
satisfies the given condition.
satisfies
in class GenericAssert<Object>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual Object
does not satisfy the given condition.is(Condition)
public ObjectAssert doesNotSatisfy(Condition<Object> condition)
Object
does not satisfy the given condition.
doesNotSatisfy
in class GenericAssert<Object>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual Object
satisfies the given condition.isNot(Condition)
public ObjectAssert is(Condition<Object> condition)
satisfies(Condition)
.
is
in class GenericAssert<Object>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual Object
does not satisfy the given condition.public ObjectAssert isNot(Condition<Object> condition)
doesNotSatisfy(Condition)
.
isNot
in class GenericAssert<Object>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual Object
satisfies the given condition.public ObjectAssert isNotNull()
Object
is not null
.
isNotNull
in class GenericAssert<Object>
AssertionError
- if the actual Object
is null
.public ObjectAssert isSameAs(Object expected)
Object
is the same as the given one.
isSameAs
in class GenericAssert<Object>
expected
- the given Object
to compare the actual Object
to.
AssertionError
- if the actual Object
is not the same as the given one.public ObjectAssert isNotSameAs(Object other)
Object
is not the same as the given one.
isNotSameAs
in class GenericAssert<Object>
other
- the given Object
to compare the actual Object
to.
AssertionError
- if the actual Object
is the same as the given one.public ObjectAssert isEqualTo(Object expected)
Object
is equal to the given one.
isEqualTo
in class GenericAssert<Object>
expected
- the given Object
to compare the actual Object
to.
AssertionError
- if the actual Object
is not equal to the given one.public ObjectAssert isNotEqualTo(Object other)
Object
is not equal to the given one.
isNotEqualTo
in class GenericAssert<Object>
other
- the given Object
to compare the actual Object
to.
AssertionError
- if the actual Object
is equal to the given one.public ObjectAssert 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'".
overridingErrorMessage
in class GenericAssert<Object>
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 |