Search in sources :

Example 1 with Single

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);
}
Also used : Single(rx.Single) Phone(io.requery.test.model.Phone) Func1(rx.functions.Func1) Person(io.requery.test.model.Person) Test(org.junit.Test)

Example 2 with Single

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;
    });
}
Also used : Single(rx.Single) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) MethodParameter(org.springframework.core.MethodParameter) Test(org.junit.Test)

Example 3 with Single

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();
}
Also used : ServerWebInputException(org.springframework.web.server.ServerWebInputException) Single(rx.Single) MethodParameter(org.springframework.core.MethodParameter) Test(org.junit.Test)

Example 4 with Single

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());
}
Also used : ServerWebExchange(org.springframework.web.server.ServerWebExchange) MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Single(rx.Single) ResolvableType(org.springframework.core.ResolvableType) Test(org.junit.Test)

Example 5 with Single

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();
}
Also used : ServerWebInputException(org.springframework.web.server.ServerWebInputException) Single(rx.Single) ResolvableType(org.springframework.core.ResolvableType) Test(org.junit.Test)

Aggregations

Single (rx.Single)13 Test (org.junit.Test)12 Type (java.lang.reflect.Type)4 Observable (rx.Observable)4 Person (io.requery.test.model.Person)3 MethodParameter (org.springframework.core.MethodParameter)3 Phone (io.requery.test.model.Phone)2 ResolvableType (org.springframework.core.ResolvableType)2 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)2 ServerWebInputException (org.springframework.web.server.ServerWebInputException)2 Context (android.content.Context)1 Handler (android.os.Handler)1 HandlerThread (android.os.HandlerThread)1 Task (bolts.Task)1 DDPClientWrapper (chat.rocket.android.api.DDPClientWrapper)1 MethodCallHelper (chat.rocket.android.api.MethodCallHelper)1 LogIfError (chat.rocket.android.helper.LogIfError)1 TextUtils (chat.rocket.android.helper.TextUtils)1 RCLog (chat.rocket.android.log.RCLog)1 ActiveUsersSubscriber (chat.rocket.android.service.ddp.base.ActiveUsersSubscriber)1