@@ -64,7 +64,7 @@ public void setUp() {
64
64
public void should_Build_a_really_really_simple_data_loader () {
65
65
AtomicBoolean success = new AtomicBoolean ();
66
66
DataLoader <Integer , Integer > identityLoader = new DataLoader <>(keys ->
67
- CompositeFuture .all (keys .stream ()
67
+ CompositeFuture .join (keys .stream ()
68
68
.map (Future ::succeededFuture )
69
69
.collect (Collectors .toCollection (ArrayList ::new ))));
70
70
@@ -81,7 +81,7 @@ public void should_Build_a_really_really_simple_data_loader() {
81
81
public void should_Support_loading_multiple_keys_in_one_call () {
82
82
AtomicBoolean success = new AtomicBoolean ();
83
83
DataLoader <Integer , Integer > identityLoader = new DataLoader <>(keys ->
84
- CompositeFuture .all (keys .stream ()
84
+ CompositeFuture .join (keys .stream ()
85
85
.map (Future ::succeededFuture )
86
86
.collect (Collectors .toCollection (ArrayList ::new ))));
87
87
@@ -321,20 +321,25 @@ public void should_Resolve_to_error_to_indicate_failure() {
321
321
322
322
@ Test
323
323
public void should_Represent_failures_and_successes_simultaneously () {
324
+ AtomicBoolean success = new AtomicBoolean ();
324
325
ArrayList <Collection > loadCalls = new ArrayList <>();
325
326
DataLoader <Integer , Integer > evenLoader = idLoaderWithErrors (new DataLoaderOptions (), loadCalls );
326
327
327
328
Future <Integer > future1 = evenLoader .load (1 );
328
329
Future <Integer > future2 = evenLoader .load (2 );
329
- evenLoader .dispatch ();
330
+ Future <Integer > future3 = evenLoader .load (3 );
331
+ Future <Integer > future4 = evenLoader .load (4 );
332
+ CompositeFuture result = evenLoader .dispatch ();
333
+ result .setHandler (rh -> success .set (true ));
330
334
331
- await ().until ( future1 :: isComplete );
335
+ await ().untilAtomic ( success , is ( true ) );
332
336
assertThat (future1 .failed (), is (true ));
333
337
assertThat (future1 .cause (), instanceOf (IllegalStateException .class ));
334
-
335
- await ().until (future2 ::isComplete );
336
338
assertThat (future2 .result (), equalTo (2 ));
337
- assertThat (loadCalls , equalTo (Collections .singletonList (Arrays .asList (1 , 2 ))));
339
+ assertThat (future3 .failed (), is (true ));
340
+ assertThat (future4 .result (), equalTo (4 ));
341
+
342
+ assertThat (loadCalls , equalTo (Collections .singletonList (Arrays .asList (1 , 2 , 3 , 4 ))));
338
343
}
339
344
340
345
@ Test
@@ -733,7 +738,7 @@ private static <K, V> DataLoader<K, V> idLoader(DataLoaderOptions options, List<
733
738
return new DataLoader <>(keys -> {
734
739
loadCalls .add (new ArrayList (keys ));
735
740
List <Future > futures = keys .stream ().map (Future ::succeededFuture ).collect (Collectors .toList ());
736
- return CompositeFuture .all (futures );
741
+ return CompositeFuture .join (futures );
737
742
}, options );
738
743
}
739
744
@@ -745,7 +750,7 @@ private static <K, V> DataLoader<K, V> idLoaderAllErrors(
745
750
List <Future > futures = keys .stream ()
746
751
.map (key -> Future .failedFuture (new IllegalStateException ("Error" )))
747
752
.collect (Collectors .toList ());
748
- return CompositeFuture .all (futures );
753
+ return CompositeFuture .join (futures );
749
754
}, options );
750
755
}
751
756
@@ -758,7 +763,7 @@ private static DataLoader<Integer, Integer> idLoaderWithErrors(
758
763
.map (key -> key % 2 == 0 ? Future .succeededFuture (key ) :
759
764
Future .failedFuture (new IllegalStateException ("Error" )))
760
765
.collect (Collectors .toList ());
761
- return CompositeFuture .all (futures );
766
+ return CompositeFuture .join (futures );
762
767
}, options );
763
768
}
764
769
}
0 commit comments