+str #19782 Transpose a sources sequence (#19795)

This commit is contained in:
Rodolphe BELOUIN 2016-04-22 12:04:28 +02:00 committed by Konrad Malawski
parent fd89f36940
commit 936c97051a
13 changed files with 731 additions and 23 deletions

View file

@ -554,7 +554,7 @@ public class SourceTest extends StreamTest {
probe.expectMsgEquals(",");
probe.expectMsgEquals("3");
probe.expectMsgEquals("]");
future.toCompletableFuture().get(200, TimeUnit.MILLISECONDS);
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
}
@Test
@ -574,7 +574,7 @@ public class SourceTest extends StreamTest {
probe.expectMsgEquals("2");
probe.expectMsgEquals(",");
probe.expectMsgEquals("3");
future.toCompletableFuture().get(200, TimeUnit.MILLISECONDS);
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
}
@Test
@ -591,7 +591,7 @@ public class SourceTest extends StreamTest {
probe.expectMsgEquals(2);
probe.expectMsgEquals(3);
future.toCompletableFuture().get(200, TimeUnit.MILLISECONDS);
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
}
@Test
@ -612,7 +612,7 @@ public class SourceTest extends StreamTest {
FiniteDuration duration = Duration.apply(200, TimeUnit.MILLISECONDS);
probe.expectNoMsg(duration);
future.toCompletableFuture().get(200, TimeUnit.MILLISECONDS);
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
}
@Test
@ -637,7 +637,7 @@ public class SourceTest extends StreamTest {
s.sendNext(1);
probe.expectMsgEquals(0);
future.toCompletableFuture().get(200, TimeUnit.MILLISECONDS);
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
}
@Test
@ -654,7 +654,41 @@ public class SourceTest extends StreamTest {
probe.expectMsgAllOf(0, 1, 2, 3);
future.toCompletableFuture().get(200, TimeUnit.MILLISECONDS);
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
}
@Test
public void mustBeAbleToZipN() throws Exception {
final JavaTestKit probe = new JavaTestKit(system);
final Source<Integer, NotUsed> source1 = Source.from(Arrays.asList(0, 1));
final Source<Integer, NotUsed> source2 = Source.from(Arrays.asList(2, 3));
final List<Source<Integer, ?>> sources = Arrays.asList(source1, source2);
final Source<List<Integer>, ?> source = Source.zipN(sources);
final CompletionStage<Done> future = source.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
probe.expectMsgAllOf(Arrays.asList(0, 2), Arrays.asList(1, 3));
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
}
@Test
public void mustBeAbleToZipWithN() throws Exception {
final JavaTestKit probe = new JavaTestKit(system);
final Source<Integer, NotUsed> source1 = Source.from(Arrays.asList(0, 1));
final Source<Integer, NotUsed> source2 = Source.from(Arrays.asList(2, 3));
final List<Source<Integer, ?>> sources = Arrays.asList(source1, source2);
final Source<Boolean, ?> source = Source.zipWithN(list -> new Boolean(list.contains(0)), sources);
final CompletionStage<Done> future = source.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
probe.expectMsgAllOf(Boolean.TRUE, Boolean.FALSE);
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
}
@Test