use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxWindowTest method scanOverlapSubscriber.
@Test
public void scanOverlapSubscriber() {
CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxWindow.WindowOverlapSubscriber<Integer> test = new FluxWindow.WindowOverlapSubscriber<Integer>(actual, 123, 3, Queues.unbounded(), Queues.<UnicastProcessor<Integer>>unbounded().get());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.CAPACITY)).isEqualTo(123);
test.requested = 35;
Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
test.onNext(2);
Assertions.assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
test.onError(new IllegalStateException("boom"));
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxWindowTest method scanExactSubscriber.
@Test
public void scanExactSubscriber() {
CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxWindow.WindowExactSubscriber<Integer> test = new FluxWindow.WindowExactSubscriber<Integer>(actual, 123, Queues.unbounded());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.CAPACITY)).isEqualTo(123);
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onComplete();
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxZipIterableTest method scanSingleSubscriber.
@Test
public void scanSingleSubscriber() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxZipIterable.ZipSubscriber<Integer, Integer, Integer> test = new FluxZipIterable.ZipSubscriber<>(actual, new ArrayList<Integer>().iterator(), (i, j) -> i + j);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onComplete();
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxZipTest method scanSingleSubscriber.
@Test
public void scanSingleSubscriber() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxZip.ZipSingleCoordinator<Integer, Integer> main = new FluxZip.ZipSingleCoordinator<Integer, Integer>(actual, new Object[1], 1, i -> 5);
FluxZip.ZipSingleSubscriber<Integer> test = new FluxZip.ZipSingleSubscriber<>(main, 0);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(main);
test.onNext(7);
Assertions.assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class MonoProcessorTest method scanProcessorSubscription.
@Test
public void scanProcessorSubscription() {
MonoProcessor<String> test = MonoProcessor.create();
Subscription subscription = Operators.emptySubscription();
test.onSubscribe(subscription);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isNull();
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(subscription);
test.getOrStart();
assertThat(test.scan(Scannable.Attr.ACTUAL)).isNotNull();
}
Aggregations