Search in sources :

Example 56 with Function

use of org.apache.cassandra.cql3.functions.Function in project RxJava by ReactiveX.

the class ObservableDebounceTest method debounceSelectorNormal1.

@Test
public void debounceSelectorNormal1() {
    PublishSubject<Integer> source = PublishSubject.create();
    final PublishSubject<Integer> debouncer = PublishSubject.create();
    Function<Integer, Observable<Integer>> debounceSel = new Function<Integer, Observable<Integer>>() {

        @Override
        public Observable<Integer> apply(Integer t1) {
            return debouncer;
        }
    };
    Observer<Object> o = TestHelper.mockObserver();
    InOrder inOrder = inOrder(o);
    source.debounce(debounceSel).subscribe(o);
    source.onNext(1);
    debouncer.onNext(1);
    source.onNext(2);
    source.onNext(3);
    source.onNext(4);
    debouncer.onNext(2);
    source.onNext(5);
    source.onComplete();
    inOrder.verify(o).onNext(1);
    inOrder.verify(o).onNext(4);
    inOrder.verify(o).onNext(5);
    inOrder.verify(o).onComplete();
    verify(o, never()).onError(any(Throwable.class));
}
Also used : Function(io.reactivex.rxjava3.functions.Function) InOrder(org.mockito.InOrder)

Example 57 with Function

use of org.apache.cassandra.cql3.functions.Function in project RxJava by ReactiveX.

the class ObservableConcatMapCompletableTest method onErrorRace.

@Test
public void onErrorRace() {
    for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
        List<Throwable> errors = TestHelper.trackPluginErrors();
        try {
            final PublishSubject<Integer> ps1 = PublishSubject.create();
            final PublishSubject<Integer> ps2 = PublishSubject.create();
            TestObserver<Void> to = ps1.concatMapCompletable(new Function<Integer, CompletableSource>() {

                @Override
                public CompletableSource apply(Integer v) throws Exception {
                    return Completable.fromObservable(ps2);
                }
            }).test();
            final TestException ex1 = new TestException();
            final TestException ex2 = new TestException();
            Runnable r1 = new Runnable() {

                @Override
                public void run() {
                    ps1.onError(ex1);
                }
            };
            Runnable r2 = new Runnable() {

                @Override
                public void run() {
                    ps2.onError(ex2);
                }
            };
            TestHelper.race(r1, r2);
            to.assertFailure(TestException.class);
            if (!errors.isEmpty()) {
                TestHelper.assertError(errors, 0, TestException.class);
            }
        } finally {
            RxJavaPlugins.reset();
        }
    }
}
Also used : Function(io.reactivex.rxjava3.functions.Function) TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 58 with Function

use of org.apache.cassandra.cql3.functions.Function in project RxJava by ReactiveX.

the class ObservableDebounceTest method debounceSelectorObservableThrows.

@Test
public void debounceSelectorObservableThrows() {
    PublishSubject<Integer> source = PublishSubject.create();
    Function<Integer, Observable<Integer>> debounceSel = new Function<Integer, Observable<Integer>>() {

        @Override
        public Observable<Integer> apply(Integer t1) {
            return Observable.error(new TestException());
        }
    };
    Observer<Object> o = TestHelper.mockObserver();
    source.debounce(debounceSel).subscribe(o);
    source.onNext(1);
    verify(o, never()).onNext(any());
    verify(o, never()).onComplete();
    verify(o).onError(any(TestException.class));
}
Also used : Function(io.reactivex.rxjava3.functions.Function) TestException(io.reactivex.rxjava3.exceptions.TestException)

Aggregations

Test (org.junit.Test)34 Function (io.reactivex.rxjava3.functions.Function)20 FunctionName (org.apache.cassandra.cql3.functions.FunctionName)13 ByteBuffer (java.nio.ByteBuffer)7 Function (org.apache.cassandra.cql3.functions.Function)7 AbstractType (org.apache.cassandra.db.marshal.AbstractType)6 InvalidRequestException (org.apache.cassandra.exceptions.InvalidRequestException)6 KeyspaceMetadata (org.apache.cassandra.schema.KeyspaceMetadata)6 TableMetadata (org.apache.cassandra.schema.TableMetadata)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)5 ProtocolVersion (org.apache.cassandra.transport.ProtocolVersion)5 InOrder (org.mockito.InOrder)5 List (java.util.List)4 UntypedResultSet (org.apache.cassandra.cql3.UntypedResultSet)4 UDFunction (org.apache.cassandra.cql3.functions.UDFunction)4 ViewMetadata (org.apache.cassandra.schema.ViewMetadata)4 TestException (io.reactivex.rxjava3.exceptions.TestException)3 java.util (java.util)3 ArrayList (java.util.ArrayList)3