use of org.reactivestreams.Subscription in project cyclops by aol.
the class BaseSequentialTest method subscribeEmpty.
@Test
public void subscribeEmpty() {
List result = new ArrayList<>();
Subscription s = of().forEachSubscribe(i -> result.add(i));
s.request(1l);
assertThat(result.size(), Matchers.equalTo(0));
s.request(1l);
assertThat(result.size(), Matchers.equalTo(0));
s.request(1l);
assertThat(result.size(), Matchers.equalTo(0));
}
use of org.reactivestreams.Subscription in project cyclops by aol.
the class BaseSequentialTest method subscribe.
@Test
public void subscribe() throws InterruptedException {
List<Integer> result = new ArrayList<>();
Subscription s = of(1, 2, 3).forEachSubscribe(i -> result.add(i));
s.request(1l);
assertThat(result.size(), Matchers.equalTo(1));
s.request(1l);
assertThat(result.size(), Matchers.equalTo(2));
s.request(1l);
assertThat(result.size(), Matchers.equalTo(3));
assertThat(result, hasItems(1, 2, 3));
}
use of org.reactivestreams.Subscription in project cyclops by aol.
the class AbstractCollectionXTest method subscribe3ErrorOnComplete.
@Test
public void subscribe3ErrorOnComplete() {
List<Integer> result = new ArrayList<>();
AtomicBoolean onComplete = new AtomicBoolean(false);
Subscription s = of(1, 2, 3).forEachSubscribe(i -> result.add(i), e -> e.printStackTrace(), () -> onComplete.set(true));
assertThat(onComplete.get(), equalTo(false));
s.request(4l);
assertThat(onComplete.get(), equalTo(true));
assertThat(result.size(), equalTo(3));
assertThat(result, hasItems(1, 2, 3));
s.request(1l);
assertThat(onComplete.get(), equalTo(true));
}
use of org.reactivestreams.Subscription in project cyclops by aol.
the class AbstractCollectionXTest method subscribeEmpty.
@Test
public void subscribeEmpty() {
List result = new ArrayList<>();
Subscription s = of().forEachSubscribe(i -> result.add(i));
s.request(1l);
assertThat(result.size(), equalTo(0));
s.request(1l);
assertThat(result.size(), equalTo(0));
s.request(1l);
assertThat(result.size(), equalTo(0));
}
use of org.reactivestreams.Subscription in project cyclops by aol.
the class AbstractCollectionXTest method subscribe3Error.
@Test
public void subscribe3Error() {
List<Integer> result = new ArrayList<>();
Subscription s = of(1, 2, 3).forEachSubscribe(i -> result.add(i), e -> e.printStackTrace());
s.request(3l);
assertThat(result.size(), equalTo(3));
assertThat(result, hasItems(1, 2, 3));
}
Aggregations