Search in sources :

Example 1 with Completable

use of io.reactivex.rxjava3.core.Completable in project redisson by redisson.

the class RedissonBatchRxTest method testConvertor.

@ParameterizedTest
@MethodSource("data")
public void testConvertor(BatchOptions batchOptions) {
    RBatchRx batch = redisson.createBatch(batchOptions);
    Single<Double> f1 = batch.getScoredSortedSet("myZKey").addScore("abc", 1d);
    Completable f2 = batch.getBucket("test").set("1");
    sync(batch.execute());
    assertThat(sync(f1)).isEqualTo(1d);
    sync(f2);
    RScoredSortedSetRx<String> set = redisson.getScoredSortedSet("myZKey");
    assertThat(sync(set.getScore("abc"))).isEqualTo(1d);
    RBucketRx<String> bucket = redisson.getBucket("test");
    assertThat(sync(bucket.get())).isEqualTo("1");
    RBatchRx batch2 = redisson.createBatch(batchOptions);
    Single<Double> b2f1 = batch2.getScoredSortedSet("myZKey2").addScore("abc", 1d);
    Single<Double> b2f2 = batch2.getScoredSortedSet("myZKey2").addScore("abc", 1d);
    sync(batch2.execute());
    assertThat(sync(b2f1)).isEqualTo(1d);
    assertThat(sync(b2f2)).isEqualTo(2d);
}
Also used : Completable(io.reactivex.rxjava3.core.Completable) RBatchRx(org.redisson.api.RBatchRx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with Completable

use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.

the class CompletableCacheTest method error.

@Test
public void error() {
    Completable c = Completable.error(new TestException()).doOnSubscribe(this).cache();
    assertEquals(0, count);
    c.test().assertFailure(TestException.class);
    assertEquals(1, count);
    c.test().assertFailure(TestException.class);
    assertEquals(1, count);
    c.test().assertFailure(TestException.class);
    assertEquals(1, count);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 3 with Completable

use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.

the class CompletableCacheTest method crossDisposeOnError.

@Test
public void crossDisposeOnError() {
    PublishSubject<Integer> ps = PublishSubject.create();
    final TestObserver<Void> to1 = new TestObserver<>();
    final TestObserver<Void> to2 = new TestObserver<Void>() {

        @Override
        public void onError(Throwable ex) {
            super.onError(ex);
            to1.dispose();
        }
    };
    Completable c = ps.ignoreElements().cache();
    c.subscribe(to2);
    c.subscribe(to1);
    ps.onError(new TestException());
    to1.assertEmpty();
    to2.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) TestObserver(io.reactivex.rxjava3.observers.TestObserver) Test(org.junit.Test)

Example 4 with Completable

use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.

the class SingleConcatMapCompletableTest method mapperThrows.

@Test
public void mapperThrows() {
    final boolean[] b = { false };
    Single.just(1).concatMapCompletable(new Function<Integer, Completable>() {

        @Override
        public Completable apply(Integer t) throws Exception {
            throw new TestException();
        }
    }).test().assertFailure(TestException.class);
    assertFalse(b[0]);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 5 with Completable

use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.

the class SingleFlatMapTest method mapperThrows.

@Test
public void mapperThrows() {
    final boolean[] b = { false };
    Single.just(1).flatMapCompletable(new Function<Integer, Completable>() {

        @Override
        public Completable apply(Integer t) throws Exception {
            throw new TestException();
        }
    }).test().assertFailure(TestException.class);
    assertFalse(b[0]);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)36 TestException (io.reactivex.rxjava3.exceptions.TestException)21 Action (io.reactivex.rxjava3.functions.Action)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 RxMethod (io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod)6 Disposable (io.reactivex.rxjava3.disposables.Disposable)5 IOException (java.io.IOException)4 Completable (io.reactivex.rxjava3.core.Completable)3 AtomicThrowable (io.reactivex.rxjava3.internal.util.AtomicThrowable)3 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)3 Flowable (io.reactivex.rxjava3.core.Flowable)2 TestObserver (io.reactivex.rxjava3.observers.TestObserver)2 CompletableSubject (io.reactivex.rxjava3.subjects.CompletableSubject)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Pattern (java.util.regex.Pattern)2 InOrder (org.mockito.InOrder)2 ConverterTest (io.reactivex.rxjava3.core.ConverterTest)1 Observable (io.reactivex.rxjava3.core.Observable)1 Observer (io.reactivex.rxjava3.core.Observer)1 ConnectableFlowable (io.reactivex.rxjava3.flowables.ConnectableFlowable)1