Search in sources :

Example 1 with MergeReduceMain

use of reactor.core.publisher.ParallelMergeReduce.MergeReduceMain in project reactor-core by reactor.

the class ParallelMergeReduceTest method scanInnerSubscriber.

@Test
public void scanInnerSubscriber() {
    CoreSubscriber<? super Integer> subscriber = new LambdaSubscriber<>(null, e -> {
    }, null, null);
    MergeReduceMain<Integer> main = new MergeReduceMain<>(subscriber, 2, (a, b) -> a + b);
    MergeReduceInner<Integer> test = new MergeReduceInner<>(main, (a, b) -> a + b);
    Subscription s = Operators.emptySubscription();
    test.onSubscribe(s);
    assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(s);
    assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(main);
    assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
    assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
    test.done = true;
    assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
    assertThat(test.scan(Scannable.Attr.BUFFERED)).isZero();
    test.value = 3;
    assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
    assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
    test.cancel();
    assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
Also used : MergeReduceMain(reactor.core.publisher.ParallelMergeReduce.MergeReduceMain) MergeReduceInner(reactor.core.publisher.ParallelMergeReduce.MergeReduceInner) Subscription(org.reactivestreams.Subscription) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Subscription (org.reactivestreams.Subscription)1 MergeReduceInner (reactor.core.publisher.ParallelMergeReduce.MergeReduceInner)1 MergeReduceMain (reactor.core.publisher.ParallelMergeReduce.MergeReduceMain)1