public void testThenAcceptBoth_exceptionalCompletion() throws Throwable {
  for (  ExecutionMode m : ExecutionMode.values())   for (  boolean fFirst : new boolean[]{true,false})   for (  boolean failFirst : new boolean[]{true,false})   for (  Integer v1 : new Integer[]{1,null}) {
    final CompletableFuture<Integer> f=new CompletableFuture<>();
    final CompletableFuture<Integer> g=new CompletableFuture<>();
    final CFException ex=new CFException();
    final SubtractAction r1=new SubtractAction(m);
    final SubtractAction r2=new SubtractAction(m);
    final SubtractAction r3=new SubtractAction(m);
    final CompletableFuture<Integer> fst=fFirst ? f : g;
    final CompletableFuture<Integer> snd=!fFirst ? f : g;
    final Callable<Boolean> complete1=failFirst ? null : null;
    final Callable<Boolean> complete2=failFirst ? null : null;
    final CompletableFuture<Void> h1=m.thenAcceptBoth(f,g,r1);
    assertTrue(complete1.call());
    final CompletableFuture<Void> h2=m.thenAcceptBoth(f,g,r2);
    checkIncomplete(h1);
    checkIncomplete(h2);
    assertTrue(complete2.call());
    final CompletableFuture<Void> h3=m.thenAcceptBoth(f,g,r3);
    checkCompletedWithWrappedException(h1,ex);
    checkCompletedWithWrappedException(h2,ex);
    checkCompletedWithWrappedException(h3,ex);
    r1.assertNotInvoked();
    r2.assertNotInvoked();
    r3.assertNotInvoked();
    checkCompletedNormally(failFirst ? snd : fst,v1);
    checkCompletedExceptionally(failFirst ? fst : snd,ex);
  }
}

public void testThenAcceptBoth_exceptionalCompletion ( ) throws Throwable { for ( ExecutionMode m : ExecutionMode . values ( ) ) for ( boolean fFirst : new boolean [ ] { true , false } ) for ( boolean failFirst : new boolean [ ] { true , false } ) for ( Integer v1 : new Integer [ ] { 1 , null } ) { final CompletableFuture < Integer > f = new CompletableFuture < > ( ) ; final CompletableFuture < Integer > g = new CompletableFuture < > ( ) ; final CFException ex = new CFException ( ) ; final SubtractAction r1 = new SubtractAction ( m ) ; final SubtractAction r2 = new SubtractAction ( m ) ; final SubtractAction r3 = new SubtractAction ( m ) ; final CompletableFuture < Integer > fst = fFirst ? f : g ; final CompletableFuture < Integer > snd = ! fFirst ? f : g ; final Callable < Boolean > complete1 = failFirst ? null : null ; final Callable < Boolean > complete2 = failFirst ? null : null ; final CompletableFuture < Void > h1 = m . thenAcceptBoth ( f , g , r1 ) ; assertTrue ( complete1 . call ( ) ) ; final CompletableFuture < Void > h2 = m . thenAcceptBoth ( f , g , r2 ) ; checkIncomplete ( h1 ) ; checkIncomplete ( h2 ) ; assertTrue ( complete2 . call ( ) ) ; final CompletableFuture < Void > h3 = m . thenAcceptBoth ( f , g , r3 ) ; checkCompletedWithWrappedException ( h1 , ex ) ; checkCompletedWithWrappedException ( h2 , ex ) ; checkCompletedWithWrappedException ( h3 , ex ) ; r1 . assertNotInvoked ( ) ; r2 . assertNotInvoked ( ) ; r3 . assertNotInvoked ( ) ; checkCompletedNormally ( failFirst ? snd : fst , v1 ) ; checkCompletedExceptionally ( failFirst ? fst : snd , ex ) ; } }
thenacceptboth result completes exceptionally after exceptional completion of either source
