Package com.google.common.truth
Class Correspondence.ExceptionStore
java.lang.Object
com.google.common.truth.Correspondence.ExceptionStore
- Enclosing class:
Correspondence<A,
E>
Helper object to store exceptions encountered while executing a
Correspondence
method.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
private Correspondence.StoredException
private Correspondence.StoredException
private Correspondence.StoredException
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
addActualKeyFunctionException
(Class<?> callingClass, Exception exception, Object actual) Adds an exception that was thrown during anapply
call on the function used to key actual elements.(package private) void
addCompareException
(Class<?> callingClass, Exception exception, Object actual, Object expected) Adds an exception that was thrown during acompare
call.(package private) void
addExpectedKeyFunctionException
(Class<?> callingClass, Exception exception, Object expected) Adds an exception that was thrown during anapply
call on the function used to key expected elements.(package private) void
addFormatDiffException
(Class<?> callingClass, Exception exception, Object actual, Object expected) Adds an exception that was thrown during aformatDiff
call.(package private) Facts
If any exceptions are stored, returns facts to use in a failure message when the exceptions should be noted as additional info; if empty, returns an empty list.(package private) Facts
Returns facts to use in a failure message when the exceptions fromcompare
calls are the main cause of the failure.(package private) static Correspondence.ExceptionStore
(package private) static Correspondence.ExceptionStore
(package private) boolean
Returns whether any exceptions thrown duringcompare
calls were stored.private static void
truncateStackTrace
(Exception exception, Class<?> callingClass)
-
Field Details
-
argumentLabel
-
firstCompareException
-
firstPairingException
-
firstFormatDiffException
-
-
Constructor Details
-
ExceptionStore
-
-
Method Details
-
forIterable
-
forMapValues
-
addCompareException
void addCompareException(Class<?> callingClass, Exception exception, Object actual, Object expected) Adds an exception that was thrown during acompare
call.- Parameters:
callingClass
- The class from which thecompare
method was called. When reporting failures, stack traces will be truncated above elements in this class.exception
- The exception encounteredactual
- Theactual
argument to thecompare
call during which the exception was encounteredexpected
- Theexpected
argument to thecompare
call during which the exception was encountered
-
addActualKeyFunctionException
Adds an exception that was thrown during anapply
call on the function used to key actual elements.- Parameters:
callingClass
- The class from which theapply
method was called. When reporting failures, stack traces will be truncated above elements in this class.exception
- The exception encounteredactual
- Theactual
argument to theapply
call during which the exception was encountered
-
addExpectedKeyFunctionException
Adds an exception that was thrown during anapply
call on the function used to key expected elements.- Parameters:
callingClass
- The class from which theapply
method was called. When reporting failures, stack traces will be truncated above elements in this class.exception
- The exception encounteredexpected
- Theexpected
argument to theapply
call during which the exception was encountered
-
addFormatDiffException
void addFormatDiffException(Class<?> callingClass, Exception exception, Object actual, Object expected) Adds an exception that was thrown during aformatDiff
call.- Parameters:
callingClass
- The class from which theformatDiff
method was called. When reporting failures, stack traces will be truncated above elements in this class.exception
- The exception encounteredactual
- Theactual
argument to theformatDiff
call during which the exception was encounteredexpected
- Theexpected
argument to theformatDiff
call during which the exception was encountered
-
hasCompareException
boolean hasCompareException()Returns whether any exceptions thrown duringcompare
calls were stored. -
describeAsMainCause
Facts describeAsMainCause()Returns facts to use in a failure message when the exceptions fromcompare
calls are the main cause of the failure. At least one exception thrown during acompare
call must have been stored, and no exceptions from aformatDiff
call. Assertions should use this when exceptions were thrown while comparing elements and no more meaningful failure was discovered by assuming a false return and continuing (see the javadoc forCorrespondence.compare(A, E)
). C.f.describeAsAdditionalInfo()
. -
describeAsAdditionalInfo
Facts describeAsAdditionalInfo()If any exceptions are stored, returns facts to use in a failure message when the exceptions should be noted as additional info; if empty, returns an empty list. Assertions should use this when exceptions were thrown while comparing elements but more meaningful failures were discovered by assuming a false return and continuing (see the javadoc forCorrespondence.compare(A, E)
), or when exceptions were thrown by other methods while generating the failure message. C.f.describeAsMainCause()
. -
truncateStackTrace
-