public static void assertThrowsCompletionException(final Consumer<Void> consumer,final Class<?> exceptionClass){
  try {
    consumer.accept(null);
  }
 catch (  final CompletionException completionEx) {
    final Throwable ex=completionEx.getCause();
    if (ex.getClass() == exceptionClass) {
      return;
    }
    Assert.fail(String.format("unexpected exception of type %s was thrown",ex.getClass()));
  }
  Assert.fail(String.format("expected exception of type %s was not thrown",exceptionClass));
}

public static void assertThrowsCompletionException ( final Consumer < Void > consumer , final Class < ? > exceptionClass ) { try { consumer . accept ( null ) ; } catch ( final CompletionException completionEx ) { final Throwable ex = completionEx . getCause ( ) ; if ( ex . getClass ( ) == exceptionClass ) { return ; } Assert . fail ( String . format ( "unexpected exception of type %s was thrown" , ex . getClass ( ) ) ) ; } Assert . fail ( String . format ( "expected exception of type %s was not thrown" , exceptionClass ) ) ; }
asserts that the execution of consumer throws a completion exception wrapping an exception of the specific class .
