use of io.reactivex.Completable in project RxJava by ReactiveX.
the class CompletableFromRunnableTest method fromRunnableInvokesLazy.
@Test
public void fromRunnableInvokesLazy() {
final AtomicInteger atomicInteger = new AtomicInteger();
Completable completable = Completable.fromRunnable(new Runnable() {
@Override
public void run() {
atomicInteger.incrementAndGet();
}
});
assertEquals(0, atomicInteger.get());
completable.test().assertResult();
assertEquals(1, atomicInteger.get());
}
use of io.reactivex.Completable in project rxjava2-jdbc by davidmoten.
the class DatabaseTest method testSelectDependsOnCompletable.
@Test
public void testSelectDependsOnCompletable() {
Database db = db();
Completable a = //
db.update("update person set score=100 where name=?").parameters(//
"FRED").counts().ignoreElements();
//
db.select("select score from person where name=?").parameters(//
"FRED").dependsOn(//
a).getAs(//
Integer.class).test().assertValues(//
100).assertComplete();
}
use of io.reactivex.Completable in project RxJava by ReactiveX.
the class CompletableFromCallableTest method fromCallableInvokesLazy.
@Test
public void fromCallableInvokesLazy() {
final AtomicInteger atomicInteger = new AtomicInteger();
Completable completable = Completable.fromCallable(new Callable<Object>() {
@Override
public Object call() throws Exception {
atomicInteger.incrementAndGet();
return null;
}
});
assertEquals(0, atomicInteger.get());
completable.test().assertResult();
assertEquals(1, atomicInteger.get());
}
use of io.reactivex.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.Completable in project RxJava by ReactiveX.
the class SchedulerWhenTest method testRaceConditions.
@Test(timeout = 1000)
public void testRaceConditions() {
Scheduler comp = Schedulers.computation();
Scheduler limited = comp.when(new Function<Flowable<Flowable<Completable>>, Completable>() {
@Override
public Completable apply(Flowable<Flowable<Completable>> t) {
return Completable.merge(Flowable.merge(t, 10));
}
});
merge(just(just(1).subscribeOn(limited).observeOn(comp)).repeat(1000)).blockingSubscribe();
}
Aggregations