Change tests to use new Source.queue api, #29801 (#30070)

This commit is contained in:
Alex 2021-05-27 10:53:18 +04:00 committed by GitHub
parent 48e4f11dfd
commit 3ae85e8cd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 27 deletions

View file

@ -636,9 +636,9 @@ public class SourceTest extends StreamTest {
@Test
public void mustBeAbleToUseQueue() throws Exception {
final Pair<SourceQueueWithComplete<String>, CompletionStage<List<String>>> x =
Flow.of(String.class).runWith(Source.queue(2, OverflowStrategy.fail()), Sink.seq(), system);
final SourceQueueWithComplete<String> source = x.first();
final Pair<BoundedSourceQueue<String>, CompletionStage<List<String>>> x =
Flow.of(String.class).runWith(Source.queue(2), Sink.seq(), system);
final BoundedSourceQueue<String> source = x.first();
final CompletionStage<List<String>> result = x.second();
source.offer("hello");
source.offer("world");
@ -833,20 +833,19 @@ public class SourceTest extends StreamTest {
@Test
public void mustBeAbleToCombineMat() throws Exception {
final TestKit probe = new TestKit(system);
final Source<Integer, SourceQueueWithComplete<Integer>> source1 =
Source.queue(1, OverflowStrategy.dropNew());
final Source<Integer, BoundedSourceQueue<Integer>> source1 = Source.queue(2);
final Source<Integer, NotUsed> source2 = Source.from(Arrays.asList(2, 3));
// compiler to check the correct materialized value of type = SourceQueueWithComplete<Integer>
// compiler to check the correct materialized value of type = BoundedSourceQueue<Integer>
// available
final Source<Integer, SourceQueueWithComplete<Integer>> combined =
final Source<Integer, BoundedSourceQueue<Integer>> combined =
Source.combineMat(
source1,
source2,
width -> Concat.create(width),
Keep.left()); // Keep.left() (i.e. preserve queueSource's materialized value)
SourceQueueWithComplete<Integer> queue =
BoundedSourceQueue<Integer> queue =
combined
.toMat(
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), Keep.left())