Search in sources :

Example 1 with ParallelInnerGroup

use of reactor.core.publisher.ParallelGroup.ParallelInnerGroup in project reactor-core by reactor.

the class ParallelGroupTest method scanInnerGroup.

@Test
public void scanInnerGroup() {
    ParallelInnerGroup<Integer> test = new ParallelInnerGroup<>(1023);
    CoreSubscriber<Integer> subscriber = new LambdaSubscriber<>(null, e -> {
    }, null, sub -> sub.request(3));
    Subscription s = Operators.emptySubscription();
    test.onSubscribe(s);
    test.subscribe(subscriber);
    assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(s);
    assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(subscriber);
    // see other test for request
    assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isZero();
    assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
    test.cancel();
    assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
Also used : ParallelInnerGroup(reactor.core.publisher.ParallelGroup.ParallelInnerGroup) Subscription(org.reactivestreams.Subscription) Test(org.junit.Test)

Example 2 with ParallelInnerGroup

use of reactor.core.publisher.ParallelGroup.ParallelInnerGroup in project reactor-core by reactor.

the class ParallelGroupTest method scanInnerGroupRequestNotTrackedWhenParent.

@Test
public void scanInnerGroupRequestNotTrackedWhenParent() {
    ParallelInnerGroup<Integer> test = new ParallelInnerGroup<>(1023);
    CoreSubscriber<Integer> subscriber = new LambdaSubscriber<>(null, e -> {
    }, null, sub -> sub.request(3));
    Subscription s = Operators.emptySubscription();
    test.onSubscribe(s);
    test.subscribe(subscriber);
    assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isZero();
    test.request(2);
    assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isZero();
}
Also used : ParallelInnerGroup(reactor.core.publisher.ParallelGroup.ParallelInnerGroup) Subscription(org.reactivestreams.Subscription) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Subscription (org.reactivestreams.Subscription)2 ParallelInnerGroup (reactor.core.publisher.ParallelGroup.ParallelInnerGroup)2