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();
}
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>");
}
}
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>");
}
}
use of io.reactivex.Flowable in project retrofit by square.
the class RxJava2CallAdapterFactoryTest method responseTypes.
@Test
public void responseTypes() {
Type oBodyClass = new TypeToken<Observable<String>>() {
}.getType();
assertThat(factory.get(oBodyClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type sBodyClass = new TypeToken<Single<String>>() {
}.getType();
assertThat(factory.get(sBodyClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type mBodyClass = new TypeToken<Maybe<String>>() {
}.getType();
assertThat(factory.get(sBodyClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type fBodyClass = new TypeToken<Flowable<String>>() {
}.getType();
assertThat(factory.get(sBodyClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type oBodyWildcard = new TypeToken<Observable<? extends String>>() {
}.getType();
assertThat(factory.get(oBodyWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type sBodyWildcard = new TypeToken<Single<? extends String>>() {
}.getType();
assertThat(factory.get(sBodyWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type mBodyWildcard = new TypeToken<Maybe<? extends String>>() {
}.getType();
assertThat(factory.get(sBodyWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type fBodyWildcard = new TypeToken<Flowable<? extends String>>() {
}.getType();
assertThat(factory.get(sBodyWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type oBodyGeneric = new TypeToken<Observable<List<String>>>() {
}.getType();
assertThat(factory.get(oBodyGeneric, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(new TypeToken<List<String>>() {
}.getType());
Type sBodyGeneric = new TypeToken<Single<List<String>>>() {
}.getType();
assertThat(factory.get(sBodyGeneric, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(new TypeToken<List<String>>() {
}.getType());
Type mBodyGeneric = new TypeToken<Maybe<List<String>>>() {
}.getType();
assertThat(factory.get(sBodyGeneric, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(new TypeToken<List<String>>() {
}.getType());
Type fBodyGeneric = new TypeToken<Flowable<List<String>>>() {
}.getType();
assertThat(factory.get(sBodyGeneric, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(new TypeToken<List<String>>() {
}.getType());
Type oResponseClass = new TypeToken<Observable<Response<String>>>() {
}.getType();
assertThat(factory.get(oResponseClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type sResponseClass = new TypeToken<Single<Response<String>>>() {
}.getType();
assertThat(factory.get(sResponseClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type mResponseClass = new TypeToken<Maybe<Response<String>>>() {
}.getType();
assertThat(factory.get(sResponseClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type fResponseClass = new TypeToken<Flowable<Response<String>>>() {
}.getType();
assertThat(factory.get(sResponseClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type oResponseWildcard = new TypeToken<Observable<Response<? extends String>>>() {
}.getType();
assertThat(factory.get(oResponseWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type sResponseWildcard = new TypeToken<Single<Response<? extends String>>>() {
}.getType();
assertThat(factory.get(sResponseWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type mResponseWildcard = new TypeToken<Maybe<Response<? extends String>>>() {
}.getType();
assertThat(factory.get(sResponseWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type fResponseWildcard = new TypeToken<Flowable<Response<? extends String>>>() {
}.getType();
assertThat(factory.get(sResponseWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type oResultClass = new TypeToken<Observable<Result<String>>>() {
}.getType();
assertThat(factory.get(oResultClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type sResultClass = new TypeToken<Single<Result<String>>>() {
}.getType();
assertThat(factory.get(sResultClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type mResultClass = new TypeToken<Maybe<Result<String>>>() {
}.getType();
assertThat(factory.get(sResultClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type fResultClass = new TypeToken<Flowable<Result<String>>>() {
}.getType();
assertThat(factory.get(sResultClass, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type oResultWildcard = new TypeToken<Observable<Result<? extends String>>>() {
}.getType();
assertThat(factory.get(oResultWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type sResultWildcard = new TypeToken<Single<Result<? extends String>>>() {
}.getType();
assertThat(factory.get(sResultWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type mResultWildcard = new TypeToken<Maybe<Result<? extends String>>>() {
}.getType();
assertThat(factory.get(sResultWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
Type fResultWildcard = new TypeToken<Flowable<Result<? extends String>>>() {
}.getType();
assertThat(factory.get(sResultWildcard, NO_ANNOTATIONS, retrofit).responseType()).isEqualTo(String.class);
}
use of io.reactivex.Flowable in project Rocket.Chat.Android by RocketChat.
the class DDPClientImpl method connect.
public void connect(final TaskCompletionSource<DDPClientCallback.Connect> task, final String url, String session) {
try {
flowable = websocket.connect(url).autoConnect();
CompositeDisposable subscriptions = new CompositeDisposable();
subscriptions.add(flowable.filter(callback -> callback instanceof RxWebSocketCallback.Open).subscribe(callback -> {
sendMessage("connect", json -> (TextUtils.isEmpty(session) ? json : json.put("session", session)).put("version", "pre2").put("support", new JSONArray().put("pre2").put("pre1")), task);
}, err -> {
}));
subscriptions.add(flowable.filter(callback -> callback instanceof RxWebSocketCallback.Message).map(callback -> ((RxWebSocketCallback.Message) callback).responseBodyString).map(DDPClientImpl::toJson).timeout(7, TimeUnit.SECONDS).subscribe(response -> {
String msg = extractMsg(response);
if ("connected".equals(msg) && !response.isNull("session")) {
task.trySetResult(new DDPClientCallback.Connect(client, response.optString("session")));
subscriptions.dispose();
} else if ("error".equals(msg) && "Already connected".equals(response.optString("reason"))) {
task.trySetResult(new DDPClientCallback.Connect(client, null));
subscriptions.dispose();
} else if ("failed".equals(msg)) {
task.trySetError(new DDPClientCallback.Connect.Failed(client, response.optString("version")));
subscriptions.dispose();
}
}, err -> task.trySetError(new DDPClientCallback.Connect.Timeout(client))));
addErrorCallback(subscriptions, task);
subscribeBaseListeners();
} catch (Exception e) {
RCLog.e(e);
}
}
Aggregations