public static boolean isExpectedException ( final Class < ? extends Exception > expectedClass , final String expectedMessage , final Exception ex ) { if ( ! isExpectedType ( expectedClass , ex ) ) { return false ; } if ( ( expectedClass != null ) && ( expectedMessage != null ) && ( ex != null ) ) { return Objects . equals ( expectedMessage , ex . getMessage ( ) ) ; } return true ; }
Determines if an exception has an expected type and message in a null - safe way .