use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class CompletableFromSupplierTest method fromSupplierInvokesLazy.
@Test
public void fromSupplierInvokesLazy() {
final AtomicInteger atomicInteger = new AtomicInteger();
Completable completable = Completable.fromSupplier(new Supplier<Object>() {
@Override
public Object get() throws Exception {
atomicInteger.incrementAndGet();
return null;
}
});
assertEquals(0, atomicInteger.get());
completable.test().assertResult();
assertEquals(1, atomicInteger.get());
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class CompletableDoOnLifecycleTest method onSubscribeCrash.
@Test
public void onSubscribeCrash() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<? super Disposable> onSubscribe = mock(Consumer.class);
Action onDispose = mock(Action.class);
doThrow(new TestException("First")).when(onSubscribe).accept(any());
Disposable bs = Disposable.empty();
new Completable() {
@Override
protected void subscribeActual(CompletableObserver observer) {
observer.onSubscribe(bs);
observer.onError(new TestException("Second"));
observer.onComplete();
}
}.doOnLifecycle(onSubscribe, onDispose).to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
assertTrue(bs.isDisposed());
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
verify(onSubscribe).accept(any());
verify(onDispose, never()).run();
});
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class CompletableFromActionTest method fromActionInvokesLazy.
@Test
public void fromActionInvokesLazy() {
final AtomicInteger atomicInteger = new AtomicInteger();
Completable completable = Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
atomicInteger.incrementAndGet();
}
});
assertEquals(0, atomicInteger.get());
completable.test().assertResult();
assertEquals(1, atomicInteger.get());
}
use of io.reactivex.rxjava3.core.Completable in project wildfly by wildfly.
the class HotRodStore method batch.
@Override
public CompletionStage<Void> batch(int publisherCount, Publisher<SegmentedPublisher<Object>> removePublisher, Publisher<SegmentedPublisher<MarshallableEntry<K, V>>> writePublisher) {
Completable removeCompletable = Flowable.fromPublisher(removePublisher).flatMap(sp -> Flowable.fromPublisher(sp), publisherCount).flatMapCompletable(key -> Completable.fromCompletionStage(this.cache.removeAsync(this.marshalKey(key))), false, this.batchSize);
Completable writeCompletable = Flowable.fromPublisher(writePublisher).flatMap(sp -> Flowable.fromPublisher(sp), publisherCount).flatMapCompletable(entry -> Completable.fromCompletionStage(this.cache.putAsync(entry.getKeyBytes(), this.marshalValue(entry.getMarshalledValue()))), false, this.batchSize);
return removeCompletable.mergeWith(writeCompletable).toCompletionStage(null);
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class TransformerTest method completableTransformerThrows.
@Test
public void completableTransformerThrows() {
try {
Completable.complete().compose(new CompletableTransformer() {
@Override
public Completable apply(Completable v) {
throw new TestException("Forced failure");
}
});
fail("Should have thrown!");
} catch (TestException ex) {
assertEquals("Forced failure", ex.getMessage());
}
}
Aggregations