use of io.reactivex.functions.Action in project requery by requery.
the class ReactiveTest method testQueryEmpty.
@Test
public void testQueryEmpty() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
data.select(Person.class).get().observable().subscribe(new Consumer<Person>() {
@Override
public void accept(Person person) throws Exception {
Assert.fail();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Assert.fail();
}
}, new Action() {
@Override
public void run() throws Exception {
latch.countDown();
}
});
if (!latch.await(1, TimeUnit.SECONDS)) {
Assert.fail();
}
}
use of io.reactivex.functions.Action in project RxJava by ReactiveX.
the class CompletableTimeoutTest method timeoutContinueOther.
@Test
public void timeoutContinueOther() throws Exception {
final int[] call = { 0 };
Completable other = Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
call[0]++;
}
});
Completable.never().timeout(100, TimeUnit.MILLISECONDS, Schedulers.io(), other).test().awaitDone(5, TimeUnit.SECONDS).assertResult();
assertEquals(1, call[0]);
}
use of io.reactivex.functions.Action 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.functions.Action in project RxJava by ReactiveX.
the class CompletableFromActionTest method fromAction.
@Test
public void fromAction() {
final AtomicInteger atomicInteger = new AtomicInteger();
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
atomicInteger.incrementAndGet();
}
}).test().assertResult();
assertEquals(1, atomicInteger.get());
}
use of io.reactivex.functions.Action in project RxJava by ReactiveX.
the class FlowableUnsubscribeOnTest method error.
@Test
public void error() {
final int[] calls = { 0 };
Flowable.error(new TestException()).doOnCancel(new Action() {
@Override
public void run() throws Exception {
calls[0]++;
}
}).unsubscribeOn(Schedulers.single()).test().assertFailure(TestException.class);
assertEquals(0, calls[0]);
}
Aggregations