use of rx.Single in project requery by requery.
the class RxTest method testQueryObservableFromEntity.
@Test
public void testQueryObservableFromEntity() throws Exception {
final Person person = randomPerson();
data.insert(person).map(new Func1<Person, Phone>() {
@Override
public Phone call(Person person) {
Phone phone1 = randomPhone();
phone1.setOwner(person);
return phone1;
}
}).flatMap(new Func1<Phone, Single<?>>() {
@Override
public Single<?> call(Phone phone) {
return data.insert(phone);
}
}).toBlocking().value();
int count = person.getPhoneNumbers().toList().size();
assertEquals(1, count);
}
use of rx.Single in project spring-framework by spring-projects.
the class ModelAttributeMethodArgumentResolverTests method createAndBindToSingle.
@Test
public void createAndBindToSingle() throws Exception {
MethodParameter parameter = this.testMethod.annotPresent(ModelAttribute.class).arg(Single.class, Foo.class);
testBindFoo(parameter, single -> {
assertTrue(single.getClass().getName(), single instanceof Single);
Object value = ((Single<?>) single).toBlocking().value();
assertEquals(Foo.class, value.getClass());
return (Foo) value;
});
}
use of rx.Single in project spring-framework by spring-projects.
the class RequestBodyArgumentResolverTests method emptyBodyWithSingle.
@Test
public void emptyBodyWithSingle() throws Exception {
MethodParameter param = this.testMethod.annot(requestBody()).arg(Single.class, String.class);
Single<String> single = resolveValueWithEmptyBody(param);
StepVerifier.create(RxReactiveStreams.toPublisher(single)).expectNextCount(0).expectError(ServerWebInputException.class).verify();
param = this.testMethod.annot(requestBody().notRequired()).arg(Single.class, String.class);
single = resolveValueWithEmptyBody(param);
StepVerifier.create(RxReactiveStreams.toPublisher(single)).expectNextCount(0).expectError(ServerWebInputException.class).verify();
}
use of rx.Single in project spring-framework by spring-projects.
the class HttpEntityArgumentResolverTests method httpEntityWithSingleBody.
@Test
public void httpEntityWithSingleBody() throws Exception {
ServerWebExchange exchange = postExchange("line1");
ResolvableType type = httpEntityType(Single.class, String.class);
HttpEntity<Single<String>> httpEntity = resolveValue(exchange, type);
assertEquals(exchange.getRequest().getHeaders(), httpEntity.getHeaders());
assertEquals("line1", httpEntity.getBody().toBlocking().value());
}
use of rx.Single in project spring-framework by spring-projects.
the class HttpEntityArgumentResolverTests method emptyBodyWithSingle.
@Test
public void emptyBodyWithSingle() throws Exception {
ResolvableType type = httpEntityType(Single.class, String.class);
HttpEntity<Single<String>> entity = resolveValueWithEmptyBody(type);
StepVerifier.create(RxReactiveStreams.toPublisher(entity.getBody())).expectNextCount(0).expectError(ServerWebInputException.class).verify();
}
Aggregations