Search in sources :

Example 26 with ResolvableType

use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.

the class HttpEntityArgumentResolverTests method emptyBodyWithRxJava2Single.

@Test
public void emptyBodyWithRxJava2Single() throws Exception {
    ResolvableType type = httpEntityType(io.reactivex.Single.class, String.class);
    HttpEntity<io.reactivex.Single<String>> entity = resolveValueWithEmptyBody(type);
    StepVerifier.create(entity.getBody().toFlowable()).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)

Example 27 with ResolvableType

use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.

the class HttpEntityArgumentResolverTests method emptyBodyWithRxJava2Maybe.

@Test
public void emptyBodyWithRxJava2Maybe() throws Exception {
    ResolvableType type = httpEntityType(Maybe.class, String.class);
    HttpEntity<Maybe<String>> entity = resolveValueWithEmptyBody(type);
    StepVerifier.create(entity.getBody().toFlowable()).expectNextCount(0).expectComplete().verify();
}
Also used : Maybe(io.reactivex.Maybe) ResolvableType(org.springframework.core.ResolvableType) Test(org.junit.Test)

Example 28 with ResolvableType

use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.

the class HttpEntityArgumentResolverTests method requestEntity.

@Test
public void requestEntity() throws Exception {
    ServerWebExchange exchange = postExchange("line1");
    ResolvableType type = forClassWithGenerics(RequestEntity.class, String.class);
    RequestEntity<String> requestEntity = resolveValue(exchange, type);
    assertEquals(exchange.getRequest().getMethod(), requestEntity.getMethod());
    assertEquals(exchange.getRequest().getURI(), requestEntity.getUrl());
    assertEquals(exchange.getRequest().getHeaders(), requestEntity.getHeaders());
    assertEquals("line1", requestEntity.getBody());
}
Also used : ServerWebExchange(org.springframework.web.server.ServerWebExchange) MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) ResolvableType(org.springframework.core.ResolvableType) Test(org.junit.Test)

Example 29 with ResolvableType

use of org.springframework.core.ResolvableType 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 30 with ResolvableType

use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.

the class HttpEntityArgumentResolverTests method httpEntityWithRxJava2SingleBody.

@Test
public void httpEntityWithRxJava2SingleBody() throws Exception {
    ServerWebExchange exchange = postExchange("line1");
    ResolvableType type = httpEntityType(io.reactivex.Single.class, String.class);
    HttpEntity<io.reactivex.Single<String>> httpEntity = resolveValue(exchange, type);
    assertEquals(exchange.getRequest().getHeaders(), httpEntity.getHeaders());
    assertEquals("line1", httpEntity.getBody().blockingGet());
}
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)

Aggregations

ResolvableType (org.springframework.core.ResolvableType)96 Test (org.junit.Test)66 MethodParameter (org.springframework.core.MethodParameter)20 DataBuffer (org.springframework.core.io.buffer.DataBuffer)15 ServerWebExchange (org.springframework.web.server.ServerWebExchange)14 List (java.util.List)11 MediaType (org.springframework.http.MediaType)10 Flux (reactor.core.publisher.Flux)10 Mono (reactor.core.publisher.Mono)10 Map (java.util.Map)9 Assert (org.springframework.util.Assert)7 Collections (java.util.Collections)6 MockServerWebExchange (org.springframework.mock.http.server.reactive.test.MockServerWebExchange)6 ArrayList (java.util.ArrayList)5 ReactiveAdapter (org.springframework.core.ReactiveAdapter)5 Pojo (org.springframework.http.codec.Pojo)5 ServerWebInputException (org.springframework.web.server.ServerWebInputException)5 Publisher (org.reactivestreams.Publisher)4 HttpMessageReader (org.springframework.http.codec.HttpMessageReader)4 Single (rx.Single)4