Search in sources :

Example 1 with MockServerHttpRequest.get

use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get in project spring-framework by spring-projects.

the class InvocableHandlerMethodTests method checkNotModified.

@Test
public void checkNotModified() {
    MockServerHttpRequest request = MockServerHttpRequest.get("/").ifModifiedSince(10 * 1000 * 1000).build();
    ServerWebExchange exchange = MockServerWebExchange.from(request);
    this.resolvers.add(stubResolver(exchange));
    Method method = ResolvableMethod.on(TestController.class).mockCall(c -> c.notModified(exchange)).method();
    HandlerResult result = invokeForResult(new TestController(), method);
    assertThat(result).as("Expected no result (i.e. fully handled)").isNull();
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) StepVerifier(reactor.test.StepVerifier) DefaultDataBufferFactory(org.springframework.core.io.buffer.DefaultDataBufferFactory) ServerHttpResponse(org.springframework.http.server.reactive.ServerHttpResponse) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MockServerWebExchange(org.springframework.web.testfixture.server.MockServerWebExchange) BindingContext(org.springframework.web.reactive.BindingContext) ArrayList(java.util.ArrayList) ServerWebExchange(org.springframework.web.server.ServerWebExchange) MockServerHttpRequest.get(org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get) UnsupportedMediaTypeStatusException(org.springframework.web.server.UnsupportedMediaTypeStatusException) BDDMockito.given(org.mockito.BDDMockito.given) Duration(java.time.Duration) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) Nullable(org.springframework.lang.Nullable) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) Method(java.lang.reflect.Method) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Mono(reactor.core.publisher.Mono) Instant(java.time.Instant) DataBuffer(org.springframework.core.io.buffer.DataBuffer) HandlerResult(org.springframework.web.reactive.HandlerResult) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) Flux(reactor.core.publisher.Flux) HttpStatus(org.springframework.http.HttpStatus) MockServerHttpRequest(org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest) List(java.util.List) ResolvableMethod(org.springframework.web.testfixture.method.ResolvableMethod) Mockito.mock(org.mockito.Mockito.mock) MockServerWebExchange(org.springframework.web.testfixture.server.MockServerWebExchange) ServerWebExchange(org.springframework.web.server.ServerWebExchange) MockServerHttpRequest(org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest) HandlerResult(org.springframework.web.reactive.HandlerResult) Method(java.lang.reflect.Method) ResolvableMethod(org.springframework.web.testfixture.method.ResolvableMethod) Test(org.junit.jupiter.api.Test)

Aggregations

Method (java.lang.reflect.Method)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)1 Assertions.assertThatIllegalStateException (org.assertj.core.api.Assertions.assertThatIllegalStateException)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 BDDMockito.given (org.mockito.BDDMockito.given)1 Mockito.mock (org.mockito.Mockito.mock)1 DataBuffer (org.springframework.core.io.buffer.DataBuffer)1 DefaultDataBufferFactory (org.springframework.core.io.buffer.DefaultDataBufferFactory)1 HttpStatus (org.springframework.http.HttpStatus)1 ServerHttpResponse (org.springframework.http.server.reactive.ServerHttpResponse)1 Nullable (org.springframework.lang.Nullable)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1 BindingContext (org.springframework.web.reactive.BindingContext)1