Search in sources :

Example 26 with Flowable

use of io.reactivex.Flowable in project retrofit by square.

the class RxJava2CallAdapterFactoryTest method rawResponseTypeThrows.

@Test
public void rawResponseTypeThrows() {
    Type observableType = new TypeToken<Observable<Response>>() {
    }.getType();
    try {
        factory.get(observableType, NO_ANNOTATIONS, retrofit);
        fail();
    } catch (IllegalStateException e) {
        assertThat(e).hasMessage("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
    }
    Type singleType = new TypeToken<Single<Response>>() {
    }.getType();
    try {
        factory.get(singleType, NO_ANNOTATIONS, retrofit);
        fail();
    } catch (IllegalStateException e) {
        assertThat(e).hasMessage("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
    }
    Type maybeType = new TypeToken<Maybe<Response>>() {
    }.getType();
    try {
        factory.get(maybeType, NO_ANNOTATIONS, retrofit);
        fail();
    } catch (IllegalStateException e) {
        assertThat(e).hasMessage("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
    }
    Type flowableType = new TypeToken<Flowable<Response>>() {
    }.getType();
    try {
        factory.get(flowableType, NO_ANNOTATIONS, retrofit);
        fail();
    } catch (IllegalStateException e) {
        assertThat(e).hasMessage("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
    }
}
Also used : Type(java.lang.reflect.Type) Maybe(io.reactivex.Maybe) Single(io.reactivex.Single) Observable(io.reactivex.Observable) Flowable(io.reactivex.Flowable) Test(org.junit.Test)

Example 27 with Flowable

use of io.reactivex.Flowable in project retrofit by square.

the class RxJava2CallAdapterFactoryTest method rawResultTypeThrows.

@Test
public void rawResultTypeThrows() {
    Type observableType = new TypeToken<Observable<Result>>() {
    }.getType();
    try {
        factory.get(observableType, NO_ANNOTATIONS, retrofit);
        fail();
    } catch (IllegalStateException e) {
        assertThat(e).hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
    }
    Type singleType = new TypeToken<Single<Result>>() {
    }.getType();
    try {
        factory.get(singleType, NO_ANNOTATIONS, retrofit);
        fail();
    } catch (IllegalStateException e) {
        assertThat(e).hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
    }
    Type maybeType = new TypeToken<Maybe<Result>>() {
    }.getType();
    try {
        factory.get(maybeType, NO_ANNOTATIONS, retrofit);
        fail();
    } catch (IllegalStateException e) {
        assertThat(e).hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
    }
    Type flowableType = new TypeToken<Flowable<Result>>() {
    }.getType();
    try {
        factory.get(flowableType, NO_ANNOTATIONS, retrofit);
        fail();
    } catch (IllegalStateException e) {
        assertThat(e).hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
    }
}
Also used : Type(java.lang.reflect.Type) Maybe(io.reactivex.Maybe) Single(io.reactivex.Single) Observable(io.reactivex.Observable) Flowable(io.reactivex.Flowable) Test(org.junit.Test)

Example 28 with Flowable

use of io.reactivex.Flowable in project spring-framework by spring-projects.

the class HttpEntityArgumentResolverTests method emptyBodyWithFlowable.

@Test
public void emptyBodyWithFlowable() throws Exception {
    ResolvableType type = httpEntityType(Flowable.class, String.class);
    HttpEntity<Flowable<String>> entity = resolveValueWithEmptyBody(type);
    StepVerifier.create(entity.getBody()).expectNextCount(0).expectComplete().verify();
}
Also used : ResolvableType(org.springframework.core.ResolvableType) Flowable(io.reactivex.Flowable) Test(org.junit.Test)

Example 29 with Flowable

use of io.reactivex.Flowable in project RxJava by ReactiveX.

the class FlowableMergeDelayErrorTest method mergeMany.

@SuppressWarnings("unchecked")
@Test
@Ignore("No 2-9 parameter mergeDelayError() overloads")
public void mergeMany() throws Exception {
    for (int i = 2; i < 10; i++) {
        Class<?>[] clazz = new Class[i];
        Arrays.fill(clazz, Flowable.class);
        Flowable<Integer>[] obs = new Flowable[i];
        Arrays.fill(obs, Flowable.just(1));
        Integer[] expected = new Integer[i];
        Arrays.fill(expected, 1);
        Method m = Flowable.class.getMethod("mergeDelayError", clazz);
        TestSubscriber<Integer> ts = TestSubscriber.create();
        ((Flowable<Integer>) m.invoke(null, (Object[]) obs)).subscribe(ts);
        ts.assertValues(expected);
        ts.assertNoErrors();
        ts.assertComplete();
    }
}
Also used : Method(java.lang.reflect.Method) Flowable(io.reactivex.Flowable)

Example 30 with Flowable

use of io.reactivex.Flowable 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();
}
Also used : Completable(io.reactivex.Completable) Scheduler(io.reactivex.Scheduler) TestScheduler(io.reactivex.schedulers.TestScheduler) Flowable(io.reactivex.Flowable) Test(org.junit.Test)

Aggregations

Flowable (io.reactivex.Flowable)65 Test (org.junit.Test)29 List (java.util.List)21 TimeUnit (java.util.concurrent.TimeUnit)19 Observable (io.reactivex.Observable)14 TestSubscriber (io.reactivex.subscribers.TestSubscriber)14 Assert.assertTrue (org.junit.Assert.assertTrue)14 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)13 Single (io.reactivex.Single)13 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)13 ClientBuilder (javax.ws.rs.client.ClientBuilder)13 MediaType (javax.ws.rs.core.MediaType)13 AbstractResourceInfo (org.apache.cxf.jaxrs.model.AbstractResourceInfo)13 FlowableRxInvoker (org.apache.cxf.jaxrs.rx2.client.FlowableRxInvoker)13 FlowableRxInvokerProvider (org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider)13 AbstractBusClientServerTestBase (org.apache.cxf.testutil.common.AbstractBusClientServerTestBase)13 BeforeClass (org.junit.BeforeClass)13 Collections (java.util.Collections)9 Response (javax.ws.rs.core.Response)9 Assert.assertEquals (org.junit.Assert.assertEquals)9