Search in sources :

Example 1 with ParallelCollectSubscriber

use of reactor.core.publisher.ParallelCollect.ParallelCollectSubscriber in project reactor-core by reactor.

the class ParallelCollectTest method scanSubscriber.

@Test
public void scanSubscriber() {
    CoreSubscriber<List<Integer>> subscriber = new LambdaSubscriber<>(null, e -> {
    }, null, null);
    ParallelCollectSubscriber<Integer, List<Integer>> test = new ParallelCollectSubscriber<>(subscriber, new ArrayList<>(), List::add);
    Subscription s = Operators.emptySubscription();
    test.onSubscribe(s);
    assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(subscriber);
    assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
    assertThat(test.scan(Scannable.Attr.RUN_STYLE)).isSameAs(Scannable.Attr.RunStyle.SYNC);
    assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
    test.complete(Collections.emptyList());
    assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
    assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
    test.cancel();
    assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
Also used : ParallelCollectSubscriber(reactor.core.publisher.ParallelCollect.ParallelCollectSubscriber) ArrayList(java.util.ArrayList) List(java.util.List) Subscription(org.reactivestreams.Subscription) Test(org.junit.jupiter.api.Test)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.jupiter.api.Test)1 Subscription (org.reactivestreams.Subscription)1 ParallelCollectSubscriber (reactor.core.publisher.ParallelCollect.ParallelCollectSubscriber)1