Search in sources :

Example 31 with ResolvableType

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

the class HttpEntityArgumentResolverTests method emptyBodyWithFlux.

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

Example 32 with ResolvableType

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

Example 33 with ResolvableType

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

the class HttpEntityArgumentResolverTests method httpEntityWithStringBody.

@Test
public void httpEntityWithStringBody() throws Exception {
    ServerWebExchange exchange = postExchange("line1");
    ResolvableType type = httpEntityType(String.class);
    HttpEntity<String> httpEntity = resolveValue(exchange, type);
    assertEquals(exchange.getRequest().getHeaders(), httpEntity.getHeaders());
    assertEquals("line1", httpEntity.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 34 with ResolvableType

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

the class HttpEntityArgumentResolverTests method emptyBodyWithObservable.

@Test
public void emptyBodyWithObservable() throws Exception {
    ResolvableType type = httpEntityType(Observable.class, String.class);
    HttpEntity<Observable<String>> entity = resolveValueWithEmptyBody(type);
    StepVerifier.create(RxReactiveStreams.toPublisher(entity.getBody())).expectNextCount(0).expectComplete().verify();
}
Also used : ResolvableType(org.springframework.core.ResolvableType) Observable(rx.Observable) Test(org.junit.Test)

Example 35 with ResolvableType

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

the class HttpEntityArgumentResolverTests method httpEntityWithFluxBody.

@Test
public void httpEntityWithFluxBody() throws Exception {
    ServerWebExchange exchange = postExchange("line1\nline2\nline3\n");
    ResolvableType type = httpEntityType(Flux.class, String.class);
    HttpEntity<Flux<String>> httpEntity = resolveValue(exchange, type);
    assertEquals(exchange.getRequest().getHeaders(), httpEntity.getHeaders());
    StepVerifier.create(httpEntity.getBody()).expectNext("line1\n").expectNext("line2\n").expectNext("line3\n").expectComplete().verify();
}
Also used : ServerWebExchange(org.springframework.web.server.ServerWebExchange) MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Flux(reactor.core.publisher.Flux) 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