Search in sources :

Example 1 with ObjectResponseT

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

the class SetResponseTTest 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));
    Set<Object> set = responseT.bind(endpoint, fn).join(promise, Arguments.empty());
    assertTrue(set.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 2 with ObjectResponseT

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

the class TraversableResponseTTest method bind.

@Test
void bind() {
    when(endpoint.returnType()).thenReturn(JavaType.parameterized(Collection.class, String.class));
    Collection<String> values = java.util.List.of("one", "two", "three");
    Promise<Response<Collection<String>>> promise = Promise.done(Response.done(values));
    ResponseFn<Collection<String>, Collection<Object>> fn = new CollectionResponseT().bind(endpoint, new ObjectResponseT<Collection<Object>>().bind(endpoint, null));
    Traversable<Object> traversable = responseT.bind(endpoint, fn).join(promise, Arguments.empty());
    assertTrue(traversable.containsAll(values));
}
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 3 with ObjectResponseT

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

the class VectorResponseTTest 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));
    Vector<Object> vector = responseT.bind(endpoint, fn).join(promise, Arguments.empty());
    assertTrue(vector.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 4 with ObjectResponseT

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

the class IndexedSeqResponseTTest method bind.

@Test
void bind() {
    when(endpoint.returnType()).thenReturn(JavaType.parameterized(Collection.class, String.class));
    Collection<String> values = List.of("one", "two", "three");
    Promise<Response<Collection<String>>> promise = Promise.done(Response.done(values));
    ResponseFn<Collection<String>, Collection<Object>> fn = new CollectionResponseT().bind(endpoint, new ObjectResponseT<Collection<Object>>().bind(endpoint, null));
    IndexedSeq<Object> seq = responseT.bind(endpoint, fn).join(promise, Arguments.empty());
    assertTrue(seq.containsAll(values));
}
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 5 with ObjectResponseT

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

the class QueueResponseTTest 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));
    Queue<Object> queue = responseT.bind(endpoint, fn).join(promise, Arguments.empty());
    assertTrue(queue.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)

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