use of io.smallrye.mutiny.GroupedMulti in project smallrye-mutiny by smallrye.
the class MultiGroupTest method testGroupByOnFailingMulti.
@Test
public void testGroupByOnFailingMulti() {
AssertSubscriber<GroupedMulti<Integer, Integer>> subscriber = Multi.createFrom().<Integer>failure(new IOException("boom")).group().by(i -> i % 2).subscribe().withSubscriber(AssertSubscriber.create(100));
subscriber.assertFailedWith(IOException.class, "boom");
assertThat(subscriber.getItems()).hasSize(0);
}
use of io.smallrye.mutiny.GroupedMulti in project smallrye-mutiny by smallrye.
the class MultiGroupTest method testGroupByWithUpstreamFailure.
@RepeatedTest(10)
public void testGroupByWithUpstreamFailure() {
AtomicReference<MultiEmitter<? super Long>> emitter = new AtomicReference<>();
Multi<Long> multi = Multi.createBy().merging().streams(Multi.createFrom().ticks().every(Duration.ofMillis(2)), Multi.createFrom().emitter((Consumer<MultiEmitter<? super Long>>) emitter::set));
AssertSubscriber<GroupedMulti<Long, Long>> subscriber = multi.group().by(l -> l % 2).subscribe().withSubscriber(AssertSubscriber.create(Long.MAX_VALUE));
subscriber.assertSubscribed();
await().until(() -> subscriber.getItems().size() == 2);
AssertSubscriber<Long> s1 = subscriber.getItems().get(0).subscribe().withSubscriber(AssertSubscriber.create(Long.MAX_VALUE));
s1.assertSubscribed();
AssertSubscriber<Long> s2 = subscriber.getItems().get(1).subscribe().withSubscriber(AssertSubscriber.create(Long.MAX_VALUE));
s2.assertSubscribed();
await().until(() -> s1.getItems().size() >= 3);
await().until(() -> s2.getItems().size() >= 3);
emitter.get().fail(new TestException("boom"));
s1.awaitFailure().assertFailedWith(TestException.class, "boom");
s2.awaitFailure().assertFailedWith(TestException.class, "boom");
subscriber.assertFailedWith(TestException.class, "boom");
}
Aggregations