public class AssertionFailedError
extends java.lang.AssertionError
AssertionFailedError
is a common base class for test-related
AssertionErrors
.
In addition to a message and a cause, this class stores the expected
and actual values of an assertion using the ValueWrapper
type.
Modifier and Type | Field and Description |
---|---|
private ValueWrapper |
actual |
private ValueWrapper |
expected |
private static long |
serialVersionUID |
Modifier | Constructor and Description |
---|---|
|
AssertionFailedError()
Constructs an
AssertionFailedError with an empty message, no
cause, and no expected/actual values. |
|
AssertionFailedError(java.lang.String message)
Constructs an
AssertionFailedError with a message, no cause,
and no expected/actual values. |
|
AssertionFailedError(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual)
Constructs an
AssertionFailedError with a message and
expected/actual values but without a cause. |
|
AssertionFailedError(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual,
java.lang.Throwable cause)
Constructs an
AssertionFailedError with a message,
expected/actual values, and a cause. |
|
AssertionFailedError(java.lang.String message,
java.lang.Throwable cause)
Constructs an
AssertionFailedError with a message and a cause
but without expected/actual values. |
private |
AssertionFailedError(java.lang.String message,
ValueWrapper expected,
ValueWrapper actual,
java.lang.Throwable cause) |
Modifier and Type | Method and Description |
---|---|
ValueWrapper |
getActual()
Returns the wrapped actual value if it is defined; otherwise
null . |
ValueWrapper |
getExpected()
Returns the wrapped expected value if it is defined; otherwise
null . |
boolean |
isActualDefined()
Returns
true if an actual value was supplied via an
appropriate constructor. |
boolean |
isExpectedDefined()
Returns
true if an expected value was supplied via an
appropriate constructor. |
java.lang.String |
toString()
Returns a short description of this assertion error using the same format
as
Throwable.toString() . |
private static final long serialVersionUID
private final ValueWrapper expected
private final ValueWrapper actual
public AssertionFailedError()
AssertionFailedError
with an empty message, no
cause, and no expected/actual values.public AssertionFailedError(java.lang.String message)
AssertionFailedError
with a message, no cause,
and no expected/actual values.message
- the detail message; null
or blank will be
converted to the empty String
public AssertionFailedError(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
AssertionFailedError
with a message and
expected/actual values but without a cause.message
- the detail message; null
or blank will be
converted to the empty String
expected
- the expected value; may be null
actual
- the actual value; may be null
public AssertionFailedError(java.lang.String message, java.lang.Throwable cause)
AssertionFailedError
with a message and a cause
but without expected/actual values.message
- the detail message; null
or blank will be
converted to the empty String
cause
- the cause of the failurepublic AssertionFailedError(java.lang.String message, java.lang.Object expected, java.lang.Object actual, java.lang.Throwable cause)
AssertionFailedError
with a message,
expected/actual values, and a cause.message
- the detail message; null
or blank will be
converted to the empty String
expected
- the expected value; may be null
actual
- the actual value; may be null
cause
- the cause of the failureprivate AssertionFailedError(java.lang.String message, ValueWrapper expected, ValueWrapper actual, java.lang.Throwable cause)
public boolean isExpectedDefined()
true
if an expected value was supplied via an
appropriate constructor.getExpected()
public boolean isActualDefined()
true
if an actual value was supplied via an
appropriate constructor.getActual()
public ValueWrapper getExpected()
null
.isExpectedDefined()
public ValueWrapper getActual()
null
.isActualDefined()
public java.lang.String toString()
Throwable.toString()
.
Since the constructors of this class convert supplied null
or
blank messages to the empty String
, this method only includes
non-empty messages in its return value.
toString
in class java.lang.Throwable
AssertionFailedError