public static <E extends Exception> void assertException(Class<E> exceptionClass, ThrowingRunnable body,
      ThrowingConsumer<E> errorAction) throws Exception {
    try {
      body.run();
      Assert.fail("Should have thrown exception");
    } catch (Exception e) {
      if (exceptionClass.isInstance(e)) {
        if (errorAction != null) {
          errorAction.accept(exceptionClass.cast(e));
        }
      } else {
        throw e;
      }
    }
  }
Succeed if the {@code body} throws an exception of type {@code exceptionClass}, otherwise fail.
@param exceptionClass the type of exception that should occur.
@param body the body to execute. This should throw an exception of type {@code exceptionClass}
@param errorAction if non-null and the exception class matches, execute this action.
@throws Exception when an unexpected exception occurs.
ambry-test-utils/src/main/java/com/github/ambry/utils/TestUtils.java