use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxBufferWhenTest method scanStartEndMainCompleted.
@Test
public void scanStartEndMainCompleted() {
CoreSubscriber<List<String>> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxBufferWhen.BufferWhenMainSubscriber<String, Integer, Long, List<String>> test = new FluxBufferWhen.BufferWhenMainSubscriber<String, Integer, Long, List<String>>(actual, ArrayList::new, Queues.small(), Mono.just(1), u -> Mono.just(1L));
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onComplete();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxCancelOnTest method scanSubscriber.
@Test
public void scanSubscriber() {
CoreSubscriber<String> actual = new LambdaSubscriber<>(null, null, null, null);
FluxCancelOn.CancelSubscriber<String> test = new FluxCancelOn.CancelSubscriber<>(actual, Schedulers.single());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.single());
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxDelayUntilTest method immediateCancel.
@Test
public void immediateCancel() {
AtomicReference<String> value = new AtomicReference<>();
AtomicReference<Throwable> error = new AtomicReference<>();
Disposable s = Flux.just("foo", "bar").delayUntil(v -> Mono.just(1)).subscribe(value::set, error::set, () -> {
}, Subscription::cancel);
assertThat(value.get()).isNull();
// would be a NPE if trigger array wasn't pre-initialized
assertThat(error.get()).isNull();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxDematerializeTest method scanSubscriber.
@Test
public void scanSubscriber() {
CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {
}, null, sub -> sub.request(100));
FluxDematerialize.DematerializeSubscriber<String> test = new FluxDematerialize.DematerializeSubscriber<>(actual);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(100L);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(0);
test.value = "foo";
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxDistinctTest method scanSubscriber.
@Test
public void scanSubscriber() {
CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxDistinct.DistinctSubscriber<String, Integer, Set<Integer>> test = new FluxDistinct.DistinctSubscriber<>(actual, new HashSet<>(), String::hashCode, Set::add, Set::clear);
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