use of com.github.ljtfreitas.julian.Response 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));
}
use of com.github.ljtfreitas.julian.Response 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());
}
use of com.github.ljtfreitas.julian.Response 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());
}
use of com.github.ljtfreitas.julian.Response 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");
}
use of com.github.ljtfreitas.julian.Response 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());
}
Aggregations