Package org.assertj.core.internal
Class Throwables
- java.lang.Object
-
- org.assertj.core.internal.Throwables
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Failures
failures
private static Throwables
INSTANCE
-
Constructor Summary
Constructors Constructor Description Throwables()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
assertHasCauseReference(AssertionInfo info, Throwable actual, Throwable expectedCause)
Asserts that the actualThrowable
has a cause that refers to the expected one.void
assertHasMessage(AssertionInfo info, Throwable actual, String expectedMessage)
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
assertHasMessageContainingAll(AssertionInfo info, Throwable actual, CharSequence... values)
Asserts that the message of the actualThrowable
contains with the given values.void
assertHasMessageEndingWith(AssertionInfo info, Throwable actual, String description)
Asserts that the message of the actualThrowable
ends with the given description.void
assertHasMessageFindingMatch(AssertionInfo info, Throwable actual, String regex)
Asserts that a sequence of the message of the actualThrowable
matches with the given regular expression (seeMatcher.find()
).void
assertHasMessageMatching(AssertionInfo info, Throwable actual, String regex)
Asserts that the message of the actualThrowable
matches with the given regular expression.void
assertHasMessageNotContaining(AssertionInfo info, Throwable actual, String content)
Asserts that the message of the actualThrowable
does not contain the given content or isnull
.void
assertHasMessageNotContainingAny(AssertionInfo info, Throwable actual, CharSequence... values)
Asserts that the message of the actualThrowable
does not contain any of the given values or isnull
.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
assertHasRootCause(AssertionInfo info, Throwable actual, Throwable expectedRootCause)
Asserts that the actualThrowable
has a root cause similar to the given one.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 void
checkCharSequenceArrayDoesNotHaveNullElements(CharSequence[] values)
private static void
checkCharSequenceIsNotNull(CharSequence sequence)
private static void
checkIsNotEmpty(CharSequence... values)
private static void
checkIsNotNull(CharSequence... values)
private static boolean
compareThrowable(Throwable actual, Throwable expected)
private static void
doCommonCheckForMessages(AssertionInfo info, Throwable actual, CharSequence[] values)
static Throwables
instance()
Returns the singleton instance of this class.
-
-
-
Field Detail
-
INSTANCE
private static final Throwables INSTANCE
-
failures
Failures failures
-
-
Method Detail
-
instance
public static Throwables instance()
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
assertHasMessage
public void assertHasMessage(AssertionInfo info, Throwable actual, String expectedMessage)
Asserts that the given actualThrowable
message is equal to the given one.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.expectedMessage
- the expected message.- Throws:
AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the message of the actualThrowable
is not equal to the given one.
-
assertHasCause
public void assertHasCause(AssertionInfo info, Throwable actual, Throwable expectedCause)
-
assertHasCauseReference
public void assertHasCauseReference(AssertionInfo info, Throwable actual, Throwable expectedCause)
Asserts that the actualThrowable
has a cause that refers to the expected one.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.expectedCause
- the expected cause.
-
assertHasRootCause
public void assertHasRootCause(AssertionInfo info, Throwable actual, Throwable expectedRootCause)
Asserts that the actualThrowable
has a root cause similar to the given one.- Parameters:
info
- contains information about the assertion.actual
- the givenThrowable
.expectedRootCause
- the expected root cause.
-
assertHasNoCause
public void assertHasNoCause(AssertionInfo info, Throwable actual)
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
public void assertHasMessageStartingWith(AssertionInfo info, Throwable actual, String description)
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
public void assertHasMessageContaining(AssertionInfo info, Throwable actual, String description)
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.
-
assertHasMessageContainingAll
public void assertHasMessageContainingAll(AssertionInfo info, Throwable actual, CharSequence... values)
Asserts that the message of the actualThrowable
contains 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 actualThrowable
isnull
.AssertionError
- if the message of the actualThrowable
does not contain the given description.
-
assertHasMessageNotContaining
public void assertHasMessageNotContaining(AssertionInfo info, Throwable actual, String content)
Asserts that the message of the actualThrowable
does 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 actualThrowable
isnull
.AssertionError
- if the message of the actualThrowable
contains the given content.- Since:
- 3.12.0
-
assertHasMessageNotContainingAny
public void assertHasMessageNotContainingAny(AssertionInfo info, Throwable actual, CharSequence... values)
Asserts that the message of the actualThrowable
does 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 actualThrowables
's message.- Throws:
AssertionError
- if the actualThrowable
isnull
.AssertionError
- if the message of the actualThrowable
does not contain the given description.
-
assertHasStackTraceContaining
public void assertHasStackTraceContaining(AssertionInfo info, Throwable actual, String description)
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
public void assertHasMessageMatching(AssertionInfo info, Throwable actual, String regex)
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
-
assertHasMessageFindingMatch
public void assertHasMessageFindingMatch(AssertionInfo info, Throwable actual, String regex)
Asserts that a sequence of the message of the actualThrowable
matches with the given regular expression (seeMatcher.find()
). The Pattern used under the hood enables thePattern.DOTALL
mode.- 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 actualThrowable
isnull
.AssertionError
- if the message of the actualThrowable
doesn't contain any sequence matching with the given regular expressionNullPointerException
- if the regex is null
-
assertHasMessageEndingWith
public void assertHasMessageEndingWith(AssertionInfo info, Throwable actual, String description)
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
public void assertHasNoSuppressedExceptions(AssertionInfo info, Throwable actual)
-
assertHasSuppressedException
public void assertHasSuppressedException(AssertionInfo info, Throwable actual, Throwable expectedSuppressedException)
-
doCommonCheckForMessages
private static void doCommonCheckForMessages(AssertionInfo info, Throwable actual, CharSequence[] values)
-
assertNotNull
private static void assertNotNull(AssertionInfo info, Throwable actual)
-
checkIsNotNull
private static void checkIsNotNull(CharSequence... values)
-
checkIsNotEmpty
private static void checkIsNotEmpty(CharSequence... values)
-
checkCharSequenceArrayDoesNotHaveNullElements
private static void checkCharSequenceArrayDoesNotHaveNullElements(CharSequence[] values)
-
checkCharSequenceIsNotNull
private static void checkCharSequenceIsNotNull(CharSequence sequence)
-
-