Search in sources :

Example 6 with ObjectResponseT

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

the class SeqResponseTTest method bindNullCollection.

@Test
void bindNullCollection() {
    when(endpoint.returnType()).thenReturn(JavaType.parameterized(Collection.class, String.class));
    Promise<Response<Collection<String>>> promise = Promise.done(Response.done(null));
    ResponseFn<Collection<String>, Collection<Object>> fn = new CollectionResponseT().bind(endpoint, new ObjectResponseT<Collection<Object>>().bind(endpoint, null));
    Seq<Object> seq = responseT.bind(endpoint, fn).join(promise, Arguments.empty());
    assertTrue(seq.isEmpty());
}
Also used : Response(com.github.ljtfreitas.julian.Response) CollectionResponseT(com.github.ljtfreitas.julian.CollectionResponseT) Collection(java.util.Collection) ObjectResponseT(com.github.ljtfreitas.julian.ObjectResponseT) Test(org.junit.jupiter.api.Test)

Example 7 with ObjectResponseT

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

the class FlowableResponseTTest method bind.

@Test
void bind() {
    Promise<Response<Collection<String>>> response = new SinglePromise<>(Single.just(Response.done(List.of("one", "two", "three"))));
    ResponseFn<Collection<String>, Collection<Object>> fn = new CollectionResponseT().bind(endpoint, new ObjectResponseT<Collection<Object>>().bind(endpoint, null));
    when(endpoint.returnType()).thenReturn(JavaType.parameterized(Collection.class, String.class));
    Flowable<Object> flowable = subject.bind(endpoint, fn).join(response, Arguments.empty());
    TestSubscriber<Object> subscriber = new TestSubscriber<>();
    flowable.subscribe(subscriber);
    subscriber.assertComplete().assertNoErrors().assertValues("one", "two", "three");
}
Also used : Response(com.github.ljtfreitas.julian.Response) CollectionResponseT(com.github.ljtfreitas.julian.CollectionResponseT) Collection(java.util.Collection) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) ObjectResponseT(com.github.ljtfreitas.julian.ObjectResponseT) Test(org.junit.jupiter.api.Test)

Example 8 with ObjectResponseT

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

the class ArrayResponseTTest method bindNullCollection.

@Test
void bindNullCollection() {
    when(endpoint.returnType()).thenReturn(JavaType.parameterized(Collection.class, String.class));
    Promise<Response<Collection<String>>> promise = Promise.done(Response.done(null));
    ResponseFn<Collection<String>, Collection<Object>> fn = new CollectionResponseT().bind(endpoint, new ObjectResponseT<Collection<Object>>().bind(endpoint, null));
    Array<Object> array = responseT.bind(endpoint, fn).join(promise, Arguments.empty());
    assertTrue(array.isEmpty());
}
Also used : Response(com.github.ljtfreitas.julian.Response) CollectionResponseT(com.github.ljtfreitas.julian.CollectionResponseT) Collection(java.util.Collection) ObjectResponseT(com.github.ljtfreitas.julian.ObjectResponseT) Test(org.junit.jupiter.api.Test)

Example 9 with ObjectResponseT

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

the class ObservableResponseTTest method bind.

@Test
void bind() {
    Promise<Response<Collection<String>>> response = new SinglePromise<>(Single.just(Response.done(List.of("one", "two", "three"))));
    ResponseFn<Collection<String>, Collection<Object>> fn = new CollectionResponseT().bind(endpoint, new ObjectResponseT<Collection<Object>>().bind(endpoint, null));
    when(endpoint.returnType()).thenReturn(JavaType.parameterized(Collection.class, String.class));
    Observable<Object> observable = subject.bind(endpoint, fn).join(response, Arguments.empty());
    TestObserver<Object> observer = new TestObserver<>();
    observable.subscribe(observer);
    observer.assertComplete().assertNoErrors().assertValues("one", "two", "three");
}
Also used : Response(com.github.ljtfreitas.julian.Response) CollectionResponseT(com.github.ljtfreitas.julian.CollectionResponseT) Collection(java.util.Collection) ObjectResponseT(com.github.ljtfreitas.julian.ObjectResponseT) TestObserver(io.reactivex.rxjava3.observers.TestObserver) Test(org.junit.jupiter.api.Test)

Example 10 with ObjectResponseT

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

the class MultiResponseTTest method bind.

@Test
void bind() {
    Promise<Response<Collection<String>>> response = Promise.done(Response.done(List.of("one", "two", "three")));
    when(endpoint.returnType()).thenReturn(JavaType.parameterized(Collection.class, String.class));
    ResponseFn<Collection<String>, Collection<Object>> fn = new CollectionResponseT().bind(endpoint, new ObjectResponseT<Collection<Object>>().bind(endpoint, null));
    Multi<Object> multi = subject.bind(endpoint, fn).join(response, Arguments.empty());
    AssertSubscriber<Object> subscriber = multi.subscribe().withSubscriber(AssertSubscriber.create(3));
    subscriber.assertCompleted().assertItems("one", "two", "three");
}
Also used : Response(com.github.ljtfreitas.julian.Response) CollectionResponseT(com.github.ljtfreitas.julian.CollectionResponseT) Collection(java.util.Collection) ObjectResponseT(com.github.ljtfreitas.julian.ObjectResponseT) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectResponseT (com.github.ljtfreitas.julian.ObjectResponseT)24 Response (com.github.ljtfreitas.julian.Response)24 Test (org.junit.jupiter.api.Test)24 CollectionResponseT (com.github.ljtfreitas.julian.CollectionResponseT)22 Collection (java.util.Collection)22 DefaultResponseT (com.github.ljtfreitas.julian.DefaultResponseT)2 TestObserver (io.reactivex.rxjava3.observers.TestObserver)2 Completable (io.reactivex.rxjava3.core.Completable)1 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)1