Package com.google.common.truth
Class Correspondence.ExceptionStore
- java.lang.Object
-
- com.google.common.truth.Correspondence.ExceptionStore
-
- Enclosing class:
- Correspondence<A,E>
static final class Correspondence.ExceptionStore extends java.lang.ObjectHelper object to store exceptions encountered while executing aCorrespondencemethod.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringargumentLabelprivate Correspondence.StoredExceptionfirstCompareExceptionprivate Correspondence.StoredExceptionfirstFormatDiffExceptionprivate Correspondence.StoredExceptionfirstPairingException
-
Constructor Summary
Constructors Modifier Constructor Description privateExceptionStore(java.lang.String argumentLabel)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddActualKeyFunctionException(java.lang.Class<?> callingClass, java.lang.Exception exception, java.lang.Object actual)Adds an exception that was thrown during anapplycall on the function used to key actual elements.(package private) voidaddCompareException(java.lang.Class<?> callingClass, java.lang.Exception exception, java.lang.Object actual, java.lang.Object expected)Adds an exception that was thrown during acomparecall.(package private) voidaddExpectedKeyFunctionException(java.lang.Class<?> callingClass, java.lang.Exception exception, java.lang.Object expected)Adds an exception that was thrown during anapplycall on the function used to key expected elements.(package private) voidaddFormatDiffException(java.lang.Class<?> callingClass, java.lang.Exception exception, java.lang.Object actual, java.lang.Object expected)Adds an exception that was thrown during aformatDiffcall.(package private) FactsdescribeAsAdditionalInfo()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) FactsdescribeAsMainCause()Returns facts to use in a failure message when the exceptions fromcomparecalls are the main cause of the failure.(package private) static Correspondence.ExceptionStoreforIterable()(package private) static Correspondence.ExceptionStoreforMapValues()(package private) booleanhasCompareException()Returns whether any exceptions thrown duringcomparecalls were stored.private static voidtruncateStackTrace(java.lang.Exception exception, java.lang.Class<?> callingClass)
-
-
-
Field Detail
-
argumentLabel
private final java.lang.String argumentLabel
-
firstCompareException
private Correspondence.StoredException firstCompareException
-
firstPairingException
private Correspondence.StoredException firstPairingException
-
firstFormatDiffException
private Correspondence.StoredException firstFormatDiffException
-
-
Method Detail
-
forIterable
static Correspondence.ExceptionStore forIterable()
-
forMapValues
static Correspondence.ExceptionStore forMapValues()
-
addCompareException
void addCompareException(java.lang.Class<?> callingClass, java.lang.Exception exception, java.lang.Object actual, java.lang.Object expected)Adds an exception that was thrown during acomparecall.- Parameters:
callingClass- The class from which thecomparemethod was called. When reporting failures, stack traces will be truncated above elements in this class.exception- The exception encounteredactual- Theactualargument to thecomparecall during which the exception was encounteredexpected- Theexpectedargument to thecomparecall during which the exception was encountered
-
addActualKeyFunctionException
void addActualKeyFunctionException(java.lang.Class<?> callingClass, java.lang.Exception exception, java.lang.Object actual)Adds an exception that was thrown during anapplycall on the function used to key actual elements.- Parameters:
callingClass- The class from which theapplymethod was called. When reporting failures, stack traces will be truncated above elements in this class.exception- The exception encounteredactual- Theactualargument to theapplycall during which the exception was encountered
-
addExpectedKeyFunctionException
void addExpectedKeyFunctionException(java.lang.Class<?> callingClass, java.lang.Exception exception, java.lang.Object expected)Adds an exception that was thrown during anapplycall on the function used to key expected elements.- Parameters:
callingClass- The class from which theapplymethod was called. When reporting failures, stack traces will be truncated above elements in this class.exception- The exception encounteredexpected- Theexpectedargument to theapplycall during which the exception was encountered
-
addFormatDiffException
void addFormatDiffException(java.lang.Class<?> callingClass, java.lang.Exception exception, java.lang.Object actual, java.lang.Object expected)Adds an exception that was thrown during aformatDiffcall.- Parameters:
callingClass- The class from which theformatDiffmethod was called. When reporting failures, stack traces will be truncated above elements in this class.exception- The exception encounteredactual- Theactualargument to theformatDiffcall during which the exception was encounteredexpected- Theexpectedargument to theformatDiffcall during which the exception was encountered
-
hasCompareException
boolean hasCompareException()
Returns whether any exceptions thrown duringcomparecalls were stored.
-
describeAsMainCause
Facts describeAsMainCause()
Returns facts to use in a failure message when the exceptions fromcomparecalls are the main cause of the failure. At least one exception thrown during acomparecall must have been stored, and no exceptions from aformatDiffcall. 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
private static void truncateStackTrace(java.lang.Exception exception, java.lang.Class<?> callingClass)
-
-