Docs: Source.repeat (and friends) (#28615)

This commit is contained in:
Enno 2020-02-19 09:03:59 +01:00 committed by GitHub
parent d946abd8d7
commit cff15cf40d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 16 deletions

View file

@ -626,6 +626,20 @@ public class SourceTest extends StreamTest {
for (Integer i : result) assertEquals(i, (Integer) 42);
}
@Test
public void mustRepeatForDocs() throws Exception {
// #repeat
Source<Integer, NotUsed> source = Source.repeat(42);
CompletionStage<Done> f = source.take(4).runWith(Sink.foreach(System.out::println), system);
// 42
// 42
// 42
// 42
// #repeat
final Done result = f.toCompletableFuture().get(3, TimeUnit.SECONDS);
assertEquals(Done.done(), result);
}
@Test
public void mustBeAbleToUseQueue() throws Exception {
final Pair<SourceQueueWithComplete<String>, CompletionStage<List<String>>> x =