use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxDistinctUntilChangedTest method scanConditionalSubscriber.
@Test
public void scanConditionalSubscriber() {
@SuppressWarnings("unchecked") Fuseable.ConditionalSubscriber<String> actual = Mockito.mock(MockUtils.TestScannableConditionalSubscriber.class);
FluxDistinctUntilChanged.DistinctUntilChangedConditionalSubscriber<String, Integer> test = new FluxDistinctUntilChanged.DistinctUntilChangedConditionalSubscriber<>(actual, String::hashCode, Objects::equals);
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 org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxDistinctUntilChangedTest method scanSubscriber.
@Test
public void scanSubscriber() {
CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxDistinctUntilChanged.DistinctUntilChangedSubscriber<String, Integer> test = new FluxDistinctUntilChanged.DistinctUntilChangedSubscriber<>(actual, String::hashCode, Objects::equals);
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 org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxConcatArrayTest method scanDelayErrorSubscriber.
@Test
public void scanDelayErrorSubscriber() {
CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
@SuppressWarnings("unchecked") Publisher<String>[] emptyPub = (Publisher<String>[]) new Publisher[0];
FluxConcatArray.ConcatArrayDelayErrorSubscriber<String> test = new FluxConcatArray.ConcatArrayDelayErrorSubscriber<>(actual, emptyPub);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isTrue();
test.missedRequested = 2;
test.requested = 3;
test.error = new IllegalStateException("boom");
assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(5L);
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxConcatMapTest method scanConcatMapDelayed.
@Test
public void scanConcatMapDelayed() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxConcatMap.ConcatMapDelayed<String, Integer> test = new FluxConcatMap.ConcatMapDelayed<>(actual, s -> Mono.just(s.length()), Queues.one(), 123, true);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
test.error = new IllegalStateException("boom");
test.queue.offer("foo");
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isTrue();
assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
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();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancelled = true;
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxConcatMapTest method scanConcatMapImmediate.
@Test
public void scanConcatMapImmediate() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxConcatMap.ConcatMapImmediate<String, Integer> test = new FluxConcatMap.ConcatMapImmediate<>(actual, s -> Mono.just(s.length()), Queues.one(), 123);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
test.queue.offer("foo");
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isFalse();
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onComplete();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancelled = true;
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
Aggregations