Package org.assertj.core.internal
Class Throwables
java.lang.Object
org.assertj.core.internal.Throwables
Reusable assertions for
Throwables.- Author:
- Joel Costigliola, Libor Ondrusek, Jack Gough, Mike Gilchrist
-
Method Summary
Modifier and TypeMethodDescriptionvoidassertHasCause(AssertionInfo info, Throwable actual) Asserts that the actualThrowablehas a cause.voidassertHasCause(AssertionInfo info, Throwable actual, Throwable expectedCause) voidassertHasCauseExactlyInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the cause of actualThrowableis exactly an instance of the given type.voidassertHasCauseInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the cause of actualThrowableis an instance of the given type.voidassertHasCauseReference(AssertionInfo info, Throwable actual, Throwable expectedCause) Asserts that the actualThrowablehas a cause that refers to the expected one.voidassertHasMessage(AssertionInfo info, Throwable actual, String expectedMessage) Asserts that the given actualThrowablemessage is equal to the given one.voidassertHasMessageContaining(AssertionInfo info, Throwable actual, String description) Asserts that the message of the actualThrowablecontains with the given description.voidassertHasMessageContainingAll(AssertionInfo info, Throwable actual, CharSequence... values) Asserts that the message of the actualThrowablecontains with the given values.voidassertHasMessageEndingWith(AssertionInfo info, Throwable actual, String description) Asserts that the message of the actualThrowableends with the given description.voidassertHasMessageFindingMatch(AssertionInfo info, Throwable actual, String regex) Asserts that a sequence of the message of the actualThrowablematches with the given regular expression (seeMatcher.find()).voidassertHasMessageMatching(AssertionInfo info, Throwable actual, String regex) voidassertHasMessageMatching(AssertionInfo info, Throwable actual, Pattern regex) Asserts that the message of the actualThrowablematches with the given regular expression.voidassertHasMessageNotContaining(AssertionInfo info, Throwable actual, String content) Asserts that the message of the actualThrowabledoes not contain the given content or isnull.voidassertHasMessageNotContainingAny(AssertionInfo info, Throwable actual, CharSequence... values) Asserts that the message of the actualThrowabledoes not contain any of the given values or isnull.voidassertHasMessageStartingWith(AssertionInfo info, Throwable actual, String description) Asserts that the message of the actualThrowablestarts with the given description.voidassertHasNoCause(AssertionInfo info, Throwable actual) Asserts that the actualThrowabledoes not have a cause.voidassertHasNoSuppressedExceptions(AssertionInfo info, Throwable actual) voidassertHasRootCause(AssertionInfo info, Throwable actual) Asserts that the actualThrowablehas a root cause.voidassertHasRootCause(AssertionInfo info, Throwable actual, Throwable expectedRootCause) Asserts that the actualThrowablehas a root cause similar to the given one.voidassertHasRootCauseExactlyInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the root cause of actualThrowableis exactly an instance of the given type.voidassertHasRootCauseInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the root cause of actualThrowableis an instance of the given type.voidassertHasRootCauseMessage(AssertionInfo info, Throwable actual, String expectedMessage) Asserts that the message of the root cause of the actualThrowableis equal to the given one.voidassertHasStackTraceContaining(AssertionInfo info, Throwable actual, String description) Asserts that the stack trace of the actualThrowablecontains with the given description.voidassertHasSuppressedException(AssertionInfo info, Throwable actual, Throwable expectedSuppressedException) static Throwablesinstance()Returns the singleton instance of this class.
-
Method Details
-
instance
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
assertHasMessage
Asserts that the given actualThrowablemessage is equal to the given one.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.expectedMessage- the expected message.- Throws:
AssertionError- if the actualThrowableisnull.AssertionError- if the message of the actualThrowableis not equal to the given one.
-
assertHasCause
-
assertHasCauseReference
Asserts that the actualThrowablehas a cause that refers to the expected one.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.expectedCause- the expected cause.
-
assertHasRootCause
Asserts that the actualThrowablehas a root cause similar to the given one.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.expectedRootCause- the expected root cause.
-
assertHasRootCauseMessage
Asserts that the message of the root cause of the actualThrowableis equal to the given one.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.expectedMessage- the expected message of the root cause.
-
assertHasNoCause
Asserts that the actualThrowabledoes not have a cause.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.- Throws:
AssertionError- if the actualThrowableisnull.AssertionError- if the actualThrowablehas a cause.
-
assertHasCause
Asserts that the actualThrowablehas a cause.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.- Throws:
AssertionError- if the actualThrowableisnull.AssertionError- if the actualThrowabledoes not have a cause.
-
assertHasRootCause
Asserts that the actualThrowablehas a root cause.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.- Throws:
AssertionError- if the actualThrowableisnull.AssertionError- if the actualThrowabledoes not have a root cause.
-
assertHasMessageStartingWith
Asserts that the message of the actualThrowablestarts 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 actualThrowableisnull.AssertionError- if the message of the actualThrowabledoes not start with the given description.
-
assertHasMessageContaining
Asserts that the message of the actualThrowablecontains 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 actualThrowableisnull.AssertionError- if the message of the actualThrowabledoes not contain the given description.
-
assertHasMessageContainingAll
public void assertHasMessageContainingAll(AssertionInfo info, Throwable actual, CharSequence... values) Asserts that the message of the actualThrowablecontains with the given values.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.values- the Strings expected to be contained in the actualThrowable's message.- Throws:
AssertionError- if the actualThrowableisnull.AssertionError- if the message of the actualThrowabledoes not contain the given description.
-
assertHasMessageNotContaining
Asserts that the message of the actualThrowabledoes not contain the given content or isnull.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.content- the content expected not to be contained in the actualThrowable's message.- Throws:
AssertionError- if the actualThrowableisnull.AssertionError- if the message of the actualThrowablecontains the given content.- Since:
- 3.12.0
-
assertHasMessageNotContainingAny
public void assertHasMessageNotContainingAny(AssertionInfo info, Throwable actual, CharSequence... values) Asserts that the message of the actualThrowabledoes not contain any of the given values or isnull.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.values- the contents expected to not be contained in the actualThrowable's message.- Throws:
AssertionError- if the actualThrowableisnull.AssertionError- if the message of the actualThrowabledoes not contain the given description.
-
assertHasStackTraceContaining
Asserts that the stack trace of the actualThrowablecontains 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 actualThrowableisnull.AssertionError- if the stack trace of the actualThrowabledoes not contain the given description.
-
assertHasMessageMatching
Asserts that the message of the actualThrowablematches 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 actualThrowableisnull.AssertionError- if the message of the actualThrowabledoes not match the given regular expression.NullPointerException- if the regex is null
-
assertHasMessageMatching
- See Also:
-
assertHasMessageFindingMatch
Asserts that a sequence of the message of the actualThrowablematches with the given regular expression (seeMatcher.find()). The Pattern used under the hood enables thePattern.DOTALLmode.- Parameters:
info- contains information about the assertion.actual- the givenThrowable.regex- the regular expression expected to be found in the actualThrowable's message.- Throws:
AssertionError- if the actualThrowableisnull.AssertionError- if the message of the actualThrowabledoesn't contain any sequence matching with the given regular expressionNullPointerException- if the regex is null
-
assertHasMessageEndingWith
Asserts that the message of the actualThrowableends 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 actualThrowableisnull.AssertionError- if the message of the actualThrowabledoes not end with the given description.
-
assertHasCauseInstanceOf
public void assertHasCauseInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the cause of actualThrowableis 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 actualThrowableisnull.AssertionError- if the actualThrowablehas no cause.AssertionError- if the cause of the actualThrowableis not an instance of the given type.
-
assertHasCauseExactlyInstanceOf
public void assertHasCauseExactlyInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) Assert that the cause of actualThrowableis 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 actualThrowableisnull.AssertionError- if the actualThrowablehas no cause.AssertionError- if the cause of the actualThrowableis 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 actualThrowableis 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 actualThrowableisnull.AssertionError- if the actualThrowablehas no cause.AssertionError- if the cause of the actualThrowableis 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 actualThrowableis 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 actualThrowableisnull.AssertionError- if the actualThrowablehas no cause.AssertionError- if the root cause of the actualThrowableis not exactly an instance of the given type.
-
assertHasNoSuppressedExceptions
-
assertHasSuppressedException
public void assertHasSuppressedException(AssertionInfo info, Throwable actual, Throwable expectedSuppressedException)
-