Search in sources :

Example 1 with DefaultResponseT

use of com.github.ljtfreitas.julian.DefaultResponseT in project julian-http-client by ljtfreitas.

the class CompletableResponseTTest method bind.

@Test
void bind() {
    Promise<Response<Void>> response = new SinglePromise<>(Single.just(Response.done(null)));
    ResponseFn<Void, Response<Object>> fn = new DefaultResponseT().bind(endpoint, new ObjectResponseT<>().bind(endpoint, null));
    Completable completable = subject.bind(endpoint, fn).join(response, Arguments.empty());
    TestObserver<Void> observer = new TestObserver<>();
    completable.subscribe(observer);
    observer.assertComplete().assertNoErrors();
}
Also used : Response(com.github.ljtfreitas.julian.Response) Completable(io.reactivex.rxjava3.core.Completable) DefaultResponseT(com.github.ljtfreitas.julian.DefaultResponseT) ObjectResponseT(com.github.ljtfreitas.julian.ObjectResponseT) TestObserver(io.reactivex.rxjava3.observers.TestObserver) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultResponseT

use of com.github.ljtfreitas.julian.DefaultResponseT in project julian-http-client by ljtfreitas.

the class HTTPResponseTTest method compose.

@Test
void compose() {
    Promise<HTTPResponse<String>> promise = Promise.done(HTTPResponse.success(HTTPStatus.valueOf(HTTPStatusCode.OK), HTTPHeaders.empty(), "hello"));
    ResponseFn<String, Response<Object>> fn = new DefaultResponseT().bind(endpoint, new ObjectResponseT<>().bind(endpoint, null));
    HTTPResponse<Object> actual = responseT.bind(endpoint, fn).join(promise, Arguments.empty());
    assertEquals("hello", actual.body().unsafe());
}
Also used : Response(com.github.ljtfreitas.julian.Response) DefaultResponseT(com.github.ljtfreitas.julian.DefaultResponseT) ObjectResponseT(com.github.ljtfreitas.julian.ObjectResponseT) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultResponseT (com.github.ljtfreitas.julian.DefaultResponseT)2 ObjectResponseT (com.github.ljtfreitas.julian.ObjectResponseT)2 Response (com.github.ljtfreitas.julian.Response)2 Test (org.junit.jupiter.api.Test)2 Completable (io.reactivex.rxjava3.core.Completable)1 TestObserver (io.reactivex.rxjava3.observers.TestObserver)1