public virtual void test_combineFuturesAsMap_exception() { CompletableFuture <string> future1 = new CompletableFuture <string>(); future1.complete("A"); System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1); CompletableFuture <string> future2 = CompletableFuture.supplyAsync(() => { try { latch.await(); } catch (InterruptedException) { } throw new System.InvalidOperationException("Oops"); }); IDictionary <string, CompletableFuture <string> > input = ImmutableMap.of("a", future1, "b", future2); CompletableFuture <IDictionary <string, string> > test = Guavate.combineFuturesAsMap(input); assertEquals(test.Done, false); latch.Signal(); assertThrows(typeof(CompletionException), () => test.join()); assertEquals(test.Done, true); assertEquals(test.CompletedExceptionally, true); }
//------------------------------------------------------------------------- public virtual void test_combineFuturesAsMap() { CompletableFuture <string> future1 = new CompletableFuture <string>(); future1.complete("A"); System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1); CompletableFuture <string> future2 = CompletableFuture.supplyAsync(() => { try { latch.await(); } catch (InterruptedException) { } return("B"); }); IDictionary <string, CompletableFuture <string> > input = ImmutableMap.of("a", future1, "b", future2); CompletableFuture <IDictionary <string, string> > test = Guavate.combineFuturesAsMap(input); assertEquals(test.Done, false); latch.Signal(); IDictionary <string, string> combined = test.join(); assertEquals(test.Done, true); assertEquals(combined.Count, 2); assertEquals(combined["a"], "A"); assertEquals(combined["b"], "B"); }