Class Correspondence.ExceptionStore

java.lang.Object
com.google.common.truth.Correspondence.ExceptionStore
Enclosing class:
Correspondence<A,E>

static final class Correspondence.ExceptionStore extends Object
Helper object to store exceptions encountered while executing a Correspondence method.
  • Field Details

  • Constructor Details

    • ExceptionStore

      private ExceptionStore(String argumentLabel)
  • Method Details

    • forIterable

      static Correspondence.ExceptionStore forIterable()
    • forMapValues

      static Correspondence.ExceptionStore forMapValues()
    • addCompareException

      void addCompareException(Class<?> callingClass, Exception exception, Object actual, Object expected)
      Adds an exception that was thrown during a compare call.
      Parameters:
      callingClass - The class from which the compare method was called. When reporting failures, stack traces will be truncated above elements in this class.
      exception - The exception encountered
      actual - The actual argument to the compare call during which the exception was encountered
      expected - The expected argument to the compare call during which the exception was encountered
    • addActualKeyFunctionException

      void addActualKeyFunctionException(Class<?> callingClass, Exception exception, Object actual)
      Adds an exception that was thrown during an apply call on the function used to key actual elements.
      Parameters:
      callingClass - The class from which the apply method was called. When reporting failures, stack traces will be truncated above elements in this class.
      exception - The exception encountered
      actual - The actual argument to the apply call during which the exception was encountered
    • addExpectedKeyFunctionException

      void addExpectedKeyFunctionException(Class<?> callingClass, Exception exception, Object expected)
      Adds an exception that was thrown during an apply call on the function used to key expected elements.
      Parameters:
      callingClass - The class from which the apply method was called. When reporting failures, stack traces will be truncated above elements in this class.
      exception - The exception encountered
      expected - The expected argument to the apply 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 a formatDiff call.
      Parameters:
      callingClass - The class from which the formatDiff method was called. When reporting failures, stack traces will be truncated above elements in this class.
      exception - The exception encountered
      actual - The actual argument to the formatDiff call during which the exception was encountered
      expected - The expected argument to the formatDiff call during which the exception was encountered
    • hasCompareException

      boolean hasCompareException()
      Returns whether any exceptions thrown during compare calls were stored.
    • describeAsMainCause

      Facts describeAsMainCause()
      Returns facts to use in a failure message when the exceptions from compare calls are the main cause of the failure. At least one exception thrown during a compare call must have been stored, and no exceptions from a formatDiff 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 for Correspondence.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 for Correspondence.compare(A, E)), or when exceptions were thrown by other methods while generating the failure message. C.f. describeAsMainCause().
    • truncateStackTrace

      private static void truncateStackTrace(Exception exception, Class<?> callingClass)