use of reactor.core.publisher.FluxPeekFuseable.PeekFuseableConditionalSubscriber in project reactor-core by reactor.
the class FluxPeekFuseableTest method scanFuseableConditionalSubscriber.
@Test
public void scanFuseableConditionalSubscriber() {
@SuppressWarnings("unchecked") Fuseable.ConditionalSubscriber<Integer> actual = Mockito.mock(MockUtils.TestScannableConditionalSubscriber.class);
FluxPeek<Integer> peek = new FluxPeek<>(Flux.just(1), s -> {
}, s -> {
}, e -> {
}, () -> {
}, () -> {
}, r -> {
}, () -> {
});
PeekFuseableConditionalSubscriber<Integer> test = new PeekFuseableConditionalSubscriber<>(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();
}
use of reactor.core.publisher.FluxPeekFuseable.PeekFuseableConditionalSubscriber in project reactor-core by reactor.
the class FluxPeekFuseableTest method resumeFuseableConditional.
@Test
public void resumeFuseableConditional() {
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<>();
PeekFuseableConditionalSubscriber<Integer> test = new PeekFuseableConditionalSubscriber<>(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();
qs.offer(3);
Integer polled = test.poll();
assertThat(polled).as("poll skips").isNull();
test.onComplete();
assertThat(actual.error).isNull();
assertThat(actual.completed).isTrue();
assertThat(resumedErrors).containsExactly(nextError, nextError, nextError);
assertThat(resumedValues).containsExactly(1, 2, 3);
}
Aggregations