use of io.smallrye.mutiny.tuples.Tuple2 in project smallrye-mutiny by smallrye.
the class CombiningItemsTest method testWithMulti.
@Test
public void testWithMulti() throws InterruptedException {
Multi<A> multiA = getMultiA();
Multi<B> multiB = getMultiB();
// tag::combine-multi[]
Multi<Tuple2<A, B>> combined = Multi.createBy().combining().streams(multiA, multiB).asTuple();
// end::combine-multi[]
CountDownLatch latch = new CountDownLatch(1);
AtomicInteger i = new AtomicInteger();
combined.subscribe().with(tuple -> {
int v = i.incrementAndGet();
assertThat(tuple.getItem1()).isEqualTo("a" + v);
assertThat(tuple.getItem2()).isEqualTo("b" + v);
}, () -> latch.countDown());
assertThat(latch.await(10, TimeUnit.MILLISECONDS)).isTrue();
// tag::combine-multi-with[]
Multi.createBy().combining().streams(multiA, multiB).using(list -> combineItems(list)).subscribe().with(x -> {
// do something with the combined items
});
// end::combine-multi-with[]
}
Aggregations