Search in sources :

Example 1 with ExpandDepthSubscriber

use of reactor.core.publisher.FluxExpand.ExpandDepthSubscriber in project reactor-core by reactor.

the class FluxExpandTest method currentContextForExpandDepthSubscriber.

@Test
public void currentContextForExpandDepthSubscriber() {
    final Context context = Context.of("foo", "bar");
    CoreSubscriber<Integer> parentActual = new BaseSubscriber<Integer>() {

        @Override
        public Context currentContext() {
            return context;
        }
    };
    ExpandDepthSubscription<Integer> expandDepthSubscription = new ExpandDepthSubscription<>(parentActual, i -> i > 5 ? Mono.empty() : Mono.just(i + 1), 123);
    ExpandDepthSubscriber<Integer> test = new ExpandDepthSubscriber<>(expandDepthSubscription);
    assertThat(test.currentContext()).isSameAs(context);
}
Also used : Context(reactor.util.context.Context) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ExpandDepthSubscriber(reactor.core.publisher.FluxExpand.ExpandDepthSubscriber) ExpandDepthSubscription(reactor.core.publisher.FluxExpand.ExpandDepthSubscription) Test(org.junit.Test)

Example 2 with ExpandDepthSubscriber

use of reactor.core.publisher.FluxExpand.ExpandDepthSubscriber in project reactor-core by reactor.

the class FluxExpandTest method scanExpandDepthSubscriber.

@Test
public void scanExpandDepthSubscriber() {
    CoreSubscriber<Integer> parentActual = new LambdaSubscriber<>(null, Throwable::printStackTrace, null, null);
    ExpandDepthSubscription<Integer> eds = new ExpandDepthSubscription<>(parentActual, i -> i > 5 ? Mono.empty() : Mono.just(i + 1), 123);
    ExpandDepthSubscriber<Integer> test = new ExpandDepthSubscriber<>(eds);
    Subscription s = Operators.emptySubscription();
    test.onSubscribe(s);
    assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(s);
    assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(parentActual);
    assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
    test.onComplete();
    assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ExpandDepthSubscriber(reactor.core.publisher.FluxExpand.ExpandDepthSubscriber) ExpandDepthSubscription(reactor.core.publisher.FluxExpand.ExpandDepthSubscription) ExpandDepthSubscription(reactor.core.publisher.FluxExpand.ExpandDepthSubscription) Subscription(org.reactivestreams.Subscription) Test(org.junit.Test)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Test (org.junit.Test)2 ExpandDepthSubscriber (reactor.core.publisher.FluxExpand.ExpandDepthSubscriber)2 ExpandDepthSubscription (reactor.core.publisher.FluxExpand.ExpandDepthSubscription)2 Subscription (org.reactivestreams.Subscription)1 Context (reactor.util.context.Context)1