use of com.github.ljtfreitas.julian.Response in project julian-http-client by ljtfreitas.
the class VectorResponseTTest 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));
Vector<Object> vector = responseT.bind(endpoint, fn).join(promise, Arguments.empty());
assertTrue(vector.containsAll(values));
}
use of com.github.ljtfreitas.julian.Response in project julian-http-client by ljtfreitas.
the class IndexedSeqResponseTTest 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));
IndexedSeq<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 LinearSeqResponseTTest 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));
LinearSeq<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 LinearSeqResponseTTest 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));
LinearSeq<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 ListResponseTTest 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));
List<Object> list = responseT.bind(endpoint, fn).join(promise, Arguments.empty());
assertTrue(list.containsAll(values));
}
Aggregations