use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class FlowableFirstTest method firstWithPredicateAndEmpty.
@Test
public void firstWithPredicateAndEmpty() {
Maybe<Integer> maybe = Flowable.just(1).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).firstElement();
maybe.subscribe(wm);
InOrder inOrder = inOrder(wm);
inOrder.verify(wm).onComplete();
inOrder.verify(wm, never()).onError(any(Throwable.class));
inOrder.verifyNoMoreInteractions();
}
use of io.reactivex.rxjava3.core.Maybe in project cxf by apache.
the class ReactiveIOInvoker method handleMaybe.
protected AsyncResponseImpl handleMaybe(Message inMessage, Maybe<?> maybe) {
final AsyncResponseImpl asyncResponse = new AsyncResponseImpl(inMessage);
Disposable d = subscribe(maybe, asyncResponse);
if (d == null) {
throw new IllegalStateException("Subscribe did not return a Disposable");
}
return asyncResponse;
}
use of io.reactivex.rxjava3.core.Maybe in project cxf by apache.
the class JAXRSRxJava3MaybeTest method testGetString.
@Test
public void testGetString() throws Exception {
String address = "http://localhost:" + PORT + "/rx3/maybe/textAsync";
final Flowable<String> obs = ClientBuilder.newClient().register(new FlowableRxInvokerProvider()).target(address).request(MediaType.TEXT_PLAIN).rx(FlowableRxInvoker.class).get(String.class);
final TestSubscriber<String> subscriber = new TestSubscriber<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertValue(r -> "Hello, world!".equals(r)).assertComplete();
}
use of io.reactivex.rxjava3.core.Maybe in project cxf by apache.
the class JAXRSRxJava3MaybeTest method testGetError.
@Test
public void testGetError() throws Exception {
String address = "http://localhost:" + PORT + "/rx3/maybe/error";
final Flowable<String> obs = ClientBuilder.newClient().register(new FlowableRxInvokerProvider()).target(address).request(MediaType.APPLICATION_JSON).rx(FlowableRxInvoker.class).get(String.class);
final TestSubscriber<String> subscriber = new TestSubscriber<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertError(InternalServerErrorException.class);
}
use of io.reactivex.rxjava3.core.Maybe in project retrofit by square.
the class RxJava3CallAdapterFactoryTest 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>");
}
}
Aggregations