Пример #1
0
 @Test
 public void mustRepeat() throws Exception {
   final CompletionStage<List<Integer>> f =
       Source.repeat(42).grouped(10000).runWith(Sink.<List<Integer>>head(), materializer);
   final List<Integer> result = f.toCompletableFuture().get(3, TimeUnit.SECONDS);
   assertEquals(result.size(), 10000);
   for (Integer i : result) assertEquals(i, (Integer) 42);
 }
Пример #2
0
 @Test
 public void mustWorkFromRange() throws Exception {
   CompletionStage<List<Integer>> f =
       Source.range(0, 10).grouped(20).runWith(Sink.<List<Integer>>head(), materializer);
   final List<Integer> result = f.toCompletableFuture().get(3, TimeUnit.SECONDS);
   assertEquals(11, result.size());
   Integer counter = 0;
   for (Integer i : result) assertEquals(i, counter++);
 }