use of reactor.core.publisher.FluxPeekFuseable.PeekConditionalSubscriber in project reactor-core by reactor.
the class FluxPeekFuseableTest method resumeConditional.
@Test
public void resumeConditional() {
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);
}));
ConditionalAssertSubscriber<Integer> actual = new ConditionalAssertSubscriber<>(context);
SignalPeekThrowNext<Integer> peekParent = new SignalPeekThrowNext<>(nextError);
AssertQueueSubscription<Integer> qs = new AssertQueueSubscription<>();
PeekConditionalSubscriber<Integer> test = new PeekConditionalSubscriber<>(actual, peekParent);
test.onSubscribe(qs);
test.onNext(1);
assertThat(actual.next).as("onNext skips").isEmpty();
assertThat(qs.requested).as("onNext requested more").isEqualTo(1);
boolean tryOnNext = test.tryOnNext(2);
assertThat(tryOnNext).as("tryOnNext skips").isFalse();
test.onComplete();
assertThat(actual.error).isNull();
assertThat(actual.completed).isTrue();
assertThat(resumedErrors).containsExactly(nextError, nextError);
assertThat(resumedValues).containsExactly(1, 2);
}
Aggregations