use of reactor.core.publisher.FluxPeekFuseable.PeekFuseableSubscriber in project reactor-core by reactor.
the class FluxPeekFuseableTest method resumeFuseable.
@Test
public void resumeFuseable() {
RuntimeException nextError = new IllegalStateException("next");
List<Throwable> resumedErrors = new ArrayList<>();
List<Object> resumedValues = new ArrayList<>();
Context context = Context.of(OnNextFailureStrategy.KEY_ON_NEXT_ERROR_STRATEGY, OnNextFailureStrategy.resume((t, s) -> {
resumedErrors.add(t);
resumedValues.add(s);
}));
AssertSubscriber<Integer> actual = new AssertSubscriber<>(context, 0);
SignalPeekThrowNext<Integer> peekParent = new SignalPeekThrowNext<>(nextError);
AssertQueueSubscription<Integer> qs = new AssertQueueSubscription<>();
PeekFuseableSubscriber<Integer> test = new PeekFuseableSubscriber<>(actual, peekParent);
test.onSubscribe(qs);
test.onNext(1);
actual.assertNoValues();
assertThat(qs.requested).as("onNext requested more").isEqualTo(1);
qs.offer(3);
Integer polled = test.poll();
assertThat(polled).as("poll skips").isNull();
test.onComplete();
actual.assertNoValues();
actual.assertNoError();
actual.assertComplete();
assertThat(resumedErrors).containsExactly(nextError, nextError);
assertThat(resumedValues).containsExactly(1, 3);
}
use of reactor.core.publisher.FluxPeekFuseable.PeekFuseableSubscriber in project reactor-core by reactor.
the class FluxPeekFuseableTest method scanFuseableSubscriber.
@Test
public void scanFuseableSubscriber() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxPeek<Integer> peek = new FluxPeek<>(Flux.just(1), s -> {
}, s -> {
}, e -> {
}, () -> {
}, () -> {
}, r -> {
}, () -> {
});
PeekFuseableSubscriber<Integer> test = new PeekFuseableSubscriber<>(actual, peek);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
}
Aggregations