public static <T extends Throwable> T assertThrowsOrNot(final T expected, final Executable executable,
                                                            final Supplier<String> messageSupplier) {
        if (expected == null) {
            assertDoesNotThrow(executable, messageSupplier);
            return null;
        }
        return (T) assertThrows(expected.getClass(), executable, messageSupplier);
    }
Null safe assertThrows and assertDoesNotThrow..

@param expected        Expected exception type. +null+ if no exception should be thrown.
@param executable      Procedure to assert thrown exception.
@param messageSupplier Message supplier for test case.
@param <T>             Type of exception to be expected.
@return Exception thrown in assertion process.
core/cas-server-core-util-api/src/test/java/org/apereo/cas/util/junit/Assertions.java