Search in sources :

Example 1 with ResourceSubscriber

use of reactor.core.publisher.FluxUsingWhen.ResourceSubscriber in project reactor-core by reactor.

the class FluxUsingWhenTest method scanResourceSubscriber.

@Test
public void scanResourceSubscriber() {
    CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {
    }, null, null);
    ResourceSubscriber<String, Integer> op = new ResourceSubscriber<>(actual, s -> Flux.just(s.length()), Mono::just, (s, err) -> Mono.just(s), Mono::just, true);
    final Subscription parent = Operators.emptySubscription();
    op.onSubscribe(parent);
    assertThat(op.scan(Attr.PARENT)).as("PARENT").isSameAs(parent);
    assertThat(op.scan(Attr.ACTUAL)).as("ACTUAL").isSameAs(actual);
    assertThat(op.scan(Attr.PREFETCH)).as("PREFETCH").isEqualTo(Integer.MAX_VALUE);
    assertThat(op.scan(Attr.RUN_STYLE)).isSameAs(Attr.RunStyle.SYNC);
    assertThat(op.scan(Attr.TERMINATED)).as("TERMINATED").isFalse();
    op.resourceProvided = true;
    assertThat(op.scan(Attr.TERMINATED)).as("TERMINATED resourceProvided").isTrue();
    assertThat(op.scanUnsafe(Attr.CANCELLED)).as("CANCELLED not supported").isNull();
}
Also used : Subscription(org.reactivestreams.Subscription) ResourceSubscriber(reactor.core.publisher.FluxUsingWhen.ResourceSubscriber) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 Subscription (org.reactivestreams.Subscription)1 ResourceSubscriber (reactor.core.publisher.FluxUsingWhen.ResourceSubscriber)1