Package org.assertj.core.internal
Class Throwables
java.lang.Object
org.assertj.core.internal.Throwables
Reusable assertions for
Throwable
s.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
assertHasCause
(AssertionInfo info, Throwable actual, Throwable expectedCause) void
assertHasCauseExactlyInstanceOf
(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the cause of actualThrowable
is exactly an instance of the given type.void
assertHasCauseInstanceOf
(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the cause of actualThrowable
is an instance of the given type.void
assertHasMessage
(AssertionInfo info, Throwable actual, String message) Asserts that the given actualThrowable
message is equal to the given one.void
assertHasMessageContaining
(AssertionInfo info, Throwable actual, String description) Asserts that the message of the actualThrowable
contains with the given description.void
assertHasMessageEndingWith
(AssertionInfo info, Throwable actual, String description) Asserts that the message of the actualThrowable
ends with the given description.void
assertHasMessageMatching
(AssertionInfo info, Throwable actual, String regex) Asserts that the message of the actualThrowable
matches with the given regular expression.void
assertHasMessageStartingWith
(AssertionInfo info, Throwable actual, String description) Asserts that the message of the actualThrowable
starts with the given description.void
assertHasNoCause
(AssertionInfo info, Throwable actual) Asserts that the actualThrowable
does not have a cause.void
assertHasNoSuppressedExceptions
(AssertionInfo info, Throwable actual) void
assertHasRootCauseExactlyInstanceOf
(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the root cause of actualThrowable
is exactly an instance of the given type.void
assertHasRootCauseInstanceOf
(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the root cause of actualThrowable
is an instance of the given type.void
assertHasStackTraceContaining
(AssertionInfo info, Throwable actual, String description) Asserts that the stack trace of the actualThrowable
contains with the given description.void
assertHasSuppressedException
(AssertionInfo info, Throwable actual, Throwable expectedSuppressedException) private static void
assertNotNull
(AssertionInfo info, Throwable actual) private static boolean
compareThrowable
(Throwable actual, Throwable expected) static Throwables
instance()
Returns the singleton instance of this class.
-
Field Details
-
INSTANCE
-
failures
Failures failures
-
-
Constructor Details
-
Throwables
Throwables()
-
-
Method Details
-
instance
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
assertHasMessage
Asserts that the given actualThrowable
message is equal to the given one.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.message
- the expected message.- Throws:
AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the message of the actualThrowable
is not equal to the given one.
-
assertHasCause
-
assertHasNoCause
Asserts that the actualThrowable
does not have a cause.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.- Throws:
AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the actualThrowable
has a cause.
-
assertHasMessageStartingWith
Asserts that the message of the actualThrowable
starts with the given description.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.description
- the description expected to start the actualThrowable
's message.- Throws:
AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the message of the actualThrowable
does not start with the given description.
-
assertHasMessageContaining
Asserts that the message of the actualThrowable
contains with the given description.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.description
- the description expected to be contained in the actualThrowable
's message.- Throws:
AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the message of the actualThrowable
does not contain the given description.
-
assertHasStackTraceContaining
Asserts that the stack trace of the actualThrowable
contains with the given description.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.description
- the description expected to be contained in the actualThrowable
's stack trace.- Throws:
AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the stack trace of the actualThrowable
does not contain the given description.
-
assertHasMessageMatching
Asserts that the message of the actualThrowable
matches with the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.regex
- the regular expression of value expected to be matched the actualThrowable
's message.- Throws:
AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the message of the actualThrowable
does not match the given regular expression.NullPointerException
- if the regex is null
-
assertHasMessageEndingWith
Asserts that the message of the actualThrowable
ends with the given description.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.description
- the description expected to end the actualThrowable
's message.- Throws:
AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the message of the actualThrowable
does not end with the given description.
-
assertHasCauseInstanceOf
public void assertHasCauseInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the cause of actualThrowable
is an instance of the given type.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.type
- the expected cause type.- Throws:
NullPointerException
- if given type isnull
.AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the actualThrowable
has no cause.AssertionError
- if the cause of the actualThrowable
is not an instance of the given type.
-
assertHasCauseExactlyInstanceOf
public void assertHasCauseExactlyInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the cause of actualThrowable
is exactly an instance of the given type.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.type
- the expected cause type.- Throws:
NullPointerException
- if given type isnull
.AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the actualThrowable
has no cause.AssertionError
- if the cause of the actualThrowable
is not exactly an instance of the given type.
-
assertHasRootCauseInstanceOf
public void assertHasRootCauseInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the root cause of actualThrowable
is an instance of the given type.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.type
- the expected cause type.- Throws:
NullPointerException
- if given type isnull
.AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the actualThrowable
has no cause.AssertionError
- if the cause of the actualThrowable
is not an instance of the given type.
-
assertHasRootCauseExactlyInstanceOf
public void assertHasRootCauseExactlyInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the root cause of actualThrowable
is exactly an instance of the given type.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.type
- the expected cause type.- Throws:
NullPointerException
- if given type isnull
.AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the actualThrowable
has no cause.AssertionError
- if the root cause of the actualThrowable
is not exactly an instance of the given type.
-
assertHasNoSuppressedExceptions
-
assertHasSuppressedException
public void assertHasSuppressedException(AssertionInfo info, Throwable actual, Throwable expectedSuppressedException) -
assertNotNull
-
compareThrowable
-