Class ThrowableCauseMatcher<T extends java.lang.Throwable>

  • Type Parameters:
    T - the type of the throwable being matched
    All Implemented Interfaces:
    org.hamcrest.Matcher<T>, org.hamcrest.SelfDescribing

    public class ThrowableCauseMatcher<T extends java.lang.Throwable>
    extends org.hamcrest.TypeSafeMatcher<T>
    A matcher that applies a delegate matcher to the cause of the current Throwable, returning the result of that match.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.hamcrest.Matcher<? extends java.lang.Throwable> causeMatcher  
    • Constructor Summary

      Constructors 
      Constructor Description
      ThrowableCauseMatcher​(org.hamcrest.Matcher<? extends java.lang.Throwable> causeMatcher)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void describeMismatchSafely​(T item, org.hamcrest.Description description)  
      void describeTo​(org.hamcrest.Description description)  
      static <T extends java.lang.Throwable>
      org.hamcrest.Matcher<T>
      hasCause​(org.hamcrest.Matcher<? extends java.lang.Throwable> matcher)
      Returns a matcher that verifies that the outer exception has a cause for which the supplied matcher evaluates to true.
      protected boolean matchesSafely​(T item)  
      • Methods inherited from class org.hamcrest.TypeSafeMatcher

        describeMismatch, matches
      • Methods inherited from class org.hamcrest.BaseMatcher

        _dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • causeMatcher

        private final org.hamcrest.Matcher<? extends java.lang.Throwable> causeMatcher
    • Constructor Detail

      • ThrowableCauseMatcher

        public ThrowableCauseMatcher​(org.hamcrest.Matcher<? extends java.lang.Throwable> causeMatcher)
    • Method Detail

      • describeTo

        public void describeTo​(org.hamcrest.Description description)
      • matchesSafely

        protected boolean matchesSafely​(T item)
        Specified by:
        matchesSafely in class org.hamcrest.TypeSafeMatcher<T extends java.lang.Throwable>
      • describeMismatchSafely

        protected void describeMismatchSafely​(T item,
                                              org.hamcrest.Description description)
        Overrides:
        describeMismatchSafely in class org.hamcrest.TypeSafeMatcher<T extends java.lang.Throwable>
      • hasCause

        public static <T extends java.lang.Throwable> org.hamcrest.Matcher<T> hasCause​(org.hamcrest.Matcher<? extends java.lang.Throwable> matcher)
        Returns a matcher that verifies that the outer exception has a cause for which the supplied matcher evaluates to true.
        Type Parameters:
        T - type of the outer exception
        Parameters:
        matcher - to apply to the cause of the outer exception