Migrate to BDD Mockito
Migrate all tests to consistently use BDD Mockito. Also add checksyle rule to enforce going forwards.
This commit is contained in:
@@ -35,8 +35,8 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.withSettings;
|
||||
|
||||
/**
|
||||
@@ -53,10 +53,10 @@ public class DispatcherHandlerTests {
|
||||
public void handlerMappingOrder() {
|
||||
HandlerMapping hm1 = mock(HandlerMapping.class, withSettings().extraInterfaces(Ordered.class));
|
||||
HandlerMapping hm2 = mock(HandlerMapping.class, withSettings().extraInterfaces(Ordered.class));
|
||||
when(((Ordered) hm1).getOrder()).thenReturn(1);
|
||||
when(((Ordered) hm2).getOrder()).thenReturn(2);
|
||||
when((hm1).getHandler(any())).thenReturn(Mono.just((Supplier<String>) () -> "1"));
|
||||
when((hm2).getHandler(any())).thenReturn(Mono.just((Supplier<String>) () -> "2"));
|
||||
given(((Ordered) hm1).getOrder()).willReturn(1);
|
||||
given(((Ordered) hm2).getOrder()).willReturn(2);
|
||||
given((hm1).getHandler(any())).willReturn(Mono.just((Supplier<String>) () -> "1"));
|
||||
given((hm2).getHandler(any())).willReturn(Mono.just((Supplier<String>) () -> "2"));
|
||||
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
context.registerBean("b2", HandlerMapping.class, () -> hm2);
|
||||
|
||||
@@ -43,7 +43,7 @@ import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.BDDMockito.willAnswer;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
@@ -115,11 +115,11 @@ public class DelegatingWebFluxConfigurationTests {
|
||||
@Test
|
||||
public void resourceHandlerMapping() throws Exception {
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer));
|
||||
doAnswer(invocation -> {
|
||||
willAnswer(invocation -> {
|
||||
ResourceHandlerRegistry registry = invocation.getArgument(0);
|
||||
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static");
|
||||
return null;
|
||||
}).when(webFluxConfigurer).addResourceHandlers(any(ResourceHandlerRegistry.class));
|
||||
}).given(webFluxConfigurer).addResourceHandlers(any(ResourceHandlerRegistry.class));
|
||||
|
||||
delegatingConfig.resourceHandlerMapping(delegatingConfig.resourceUrlProvider());
|
||||
verify(webFluxConfigurer).addResourceHandlers(any(ResourceHandlerRegistry.class));
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.springframework.web.reactive.function.BodyInserter;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.http.HttpMethod.DELETE;
|
||||
import static org.springframework.http.HttpMethod.GET;
|
||||
import static org.springframework.http.HttpMethod.OPTIONS;
|
||||
@@ -131,7 +131,7 @@ public class DefaultClientRequestBuilderTests {
|
||||
messageWriters.add(new EncoderHttpMessageWriter<>(CharSequenceEncoder.allMimeTypes()));
|
||||
|
||||
ExchangeStrategies strategies = mock(ExchangeStrategies.class);
|
||||
when(strategies.messageWriters()).thenReturn(messageWriters);
|
||||
given(strategies.messageWriters()).willReturn(messageWriters);
|
||||
|
||||
MockClientHttpRequest request = new MockClientHttpRequest(GET, "/");
|
||||
result.writeTo(request, strategies).block();
|
||||
@@ -153,7 +153,7 @@ public class DefaultClientRequestBuilderTests {
|
||||
messageWriters.add(new EncoderHttpMessageWriter<>(CharSequenceEncoder.allMimeTypes()));
|
||||
|
||||
ExchangeStrategies strategies = mock(ExchangeStrategies.class);
|
||||
when(strategies.messageWriters()).thenReturn(messageWriters);
|
||||
given(strategies.messageWriters()).willReturn(messageWriters);
|
||||
|
||||
MockClientHttpRequest request = new MockClientHttpRequest(GET, "/");
|
||||
result.writeTo(request, strategies).block();
|
||||
@@ -176,7 +176,7 @@ public class DefaultClientRequestBuilderTests {
|
||||
messageWriters.add(new EncoderHttpMessageWriter<>(CharSequenceEncoder.allMimeTypes()));
|
||||
|
||||
ExchangeStrategies strategies = mock(ExchangeStrategies.class);
|
||||
when(strategies.messageWriters()).thenReturn(messageWriters);
|
||||
given(strategies.messageWriters()).willReturn(messageWriters);
|
||||
|
||||
MockClientHttpRequest request = new MockClientHttpRequest(GET, "/");
|
||||
result.writeTo(request, strategies).block();
|
||||
|
||||
@@ -49,8 +49,8 @@ import org.springframework.util.MultiValueMap;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.web.reactive.function.BodyExtractors.toMono;
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ public class DefaultClientResponseTests {
|
||||
@Test
|
||||
public void statusCode() {
|
||||
HttpStatus status = HttpStatus.CONTINUE;
|
||||
when(mockResponse.getStatusCode()).thenReturn(status);
|
||||
given(mockResponse.getStatusCode()).willReturn(status);
|
||||
|
||||
assertEquals(status, defaultClientResponse.statusCode());
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class DefaultClientResponseTests {
|
||||
@Test
|
||||
public void rawStatusCode() {
|
||||
int status = 999;
|
||||
when(mockResponse.getRawStatusCode()).thenReturn(status);
|
||||
given(mockResponse.getRawStatusCode()).willReturn(status);
|
||||
|
||||
assertEquals(status, defaultClientResponse.rawStatusCode());
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class DefaultClientResponseTests {
|
||||
List<HttpRange> range = Collections.singletonList(HttpRange.createByteRange(0, 42));
|
||||
httpHeaders.setRange(range);
|
||||
|
||||
when(mockResponse.getHeaders()).thenReturn(httpHeaders);
|
||||
given(mockResponse.getHeaders()).willReturn(httpHeaders);
|
||||
|
||||
ClientResponse.Headers headers = defaultClientResponse.headers();
|
||||
assertEquals(OptionalLong.of(contentLength), headers.contentLength());
|
||||
@@ -116,7 +116,7 @@ public class DefaultClientResponseTests {
|
||||
MultiValueMap<String, ResponseCookie> cookies = new LinkedMultiValueMap<>();
|
||||
cookies.add("foo", cookie);
|
||||
|
||||
when(mockResponse.getCookies()).thenReturn(cookies);
|
||||
given(mockResponse.getCookies()).willReturn(cookies);
|
||||
|
||||
assertSame(cookies, defaultClientResponse.cookies());
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class DefaultClientResponseTests {
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
Mono<String> resultMono = defaultClientResponse.body(toMono(String.class));
|
||||
assertEquals("foo", resultMono.block());
|
||||
@@ -148,7 +148,7 @@ public class DefaultClientResponseTests {
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
Mono<String> resultMono = defaultClientResponse.bodyToMono(String.class);
|
||||
assertEquals("foo", resultMono.block());
|
||||
@@ -164,7 +164,7 @@ public class DefaultClientResponseTests {
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
Mono<String> resultMono =
|
||||
defaultClientResponse.bodyToMono(new ParameterizedTypeReference<String>() {
|
||||
@@ -182,7 +182,7 @@ public class DefaultClientResponseTests {
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
Flux<String> resultFlux = defaultClientResponse.bodyToFlux(String.class);
|
||||
Mono<List<String>> result = resultFlux.collectList();
|
||||
@@ -199,7 +199,7 @@ public class DefaultClientResponseTests {
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
Flux<String> resultFlux =
|
||||
defaultClientResponse.bodyToFlux(new ParameterizedTypeReference<String>() {
|
||||
@@ -218,7 +218,7 @@ public class DefaultClientResponseTests {
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
ResponseEntity<String> result = defaultClientResponse.toEntity(String.class).block();
|
||||
assertEquals("foo", result.getBody());
|
||||
@@ -236,14 +236,14 @@ public class DefaultClientResponseTests {
|
||||
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||
when(mockResponse.getHeaders()).thenReturn(httpHeaders);
|
||||
when(mockResponse.getStatusCode()).thenThrow(new IllegalArgumentException("999"));
|
||||
when(mockResponse.getRawStatusCode()).thenReturn(999);
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
given(mockResponse.getHeaders()).willReturn(httpHeaders);
|
||||
given(mockResponse.getStatusCode()).willThrow(new IllegalArgumentException("999"));
|
||||
given(mockResponse.getRawStatusCode()).willReturn(999);
|
||||
given(mockResponse.getBody()).willReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
ResponseEntity<String> result = defaultClientResponse.toEntity(String.class).block();
|
||||
assertEquals("foo", result.getBody());
|
||||
@@ -268,7 +268,7 @@ public class DefaultClientResponseTests {
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
ResponseEntity<String> result = defaultClientResponse.toEntity(
|
||||
new ParameterizedTypeReference<String>() {
|
||||
@@ -289,7 +289,7 @@ public class DefaultClientResponseTests {
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
ResponseEntity<List<String>> result = defaultClientResponse.toEntityList(String.class).block();
|
||||
assertEquals(Collections.singletonList("foo"), result.getBody());
|
||||
@@ -307,14 +307,14 @@ public class DefaultClientResponseTests {
|
||||
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||
when(mockResponse.getHeaders()).thenReturn(httpHeaders);
|
||||
when(mockResponse.getStatusCode()).thenThrow(new IllegalArgumentException("999"));
|
||||
when(mockResponse.getRawStatusCode()).thenReturn(999);
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
given(mockResponse.getHeaders()).willReturn(httpHeaders);
|
||||
given(mockResponse.getStatusCode()).willThrow(new IllegalArgumentException("999"));
|
||||
given(mockResponse.getRawStatusCode()).willReturn(999);
|
||||
given(mockResponse.getBody()).willReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
ResponseEntity<List<String>> result = defaultClientResponse.toEntityList(String.class).block();
|
||||
assertEquals(Collections.singletonList("foo"), result.getBody());
|
||||
@@ -340,7 +340,7 @@ public class DefaultClientResponseTests {
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
given(mockExchangeStrategies.messageReaders()).willReturn(messageReaders);
|
||||
|
||||
ResponseEntity<List<String>> result = defaultClientResponse.toEntityList(
|
||||
new ParameterizedTypeReference<String>() {
|
||||
@@ -355,10 +355,10 @@ public class DefaultClientResponseTests {
|
||||
private void mockTextPlainResponse(Flux<DataBuffer> body) {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||
when(mockResponse.getHeaders()).thenReturn(httpHeaders);
|
||||
when(mockResponse.getStatusCode()).thenReturn(HttpStatus.OK);
|
||||
when(mockResponse.getRawStatusCode()).thenReturn(HttpStatus.OK.value());
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
given(mockResponse.getHeaders()).willReturn(httpHeaders);
|
||||
given(mockResponse.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
given(mockResponse.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(mockResponse.getBody()).willReturn(body);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DefaultWebClient}.
|
||||
@@ -64,7 +64,7 @@ public class DefaultWebClientTests {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.exchangeFunction = mock(ExchangeFunction.class);
|
||||
ClientResponse mockResponse = mock(ClientResponse.class);
|
||||
when(this.exchangeFunction.exchange(this.captor.capture())).thenReturn(Mono.just(mockResponse));
|
||||
given(this.exchangeFunction.exchange(this.captor.capture())).willReturn(Mono.just(mockResponse));
|
||||
this.builder = WebClient.builder().baseUrl("/base").exchangeFunction(this.exchangeFunction);
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ public class DefaultWebClientTests {
|
||||
@Test
|
||||
public void switchToErrorOnEmptyClientResponseMono() {
|
||||
ExchangeFunction exchangeFunction = mock(ExchangeFunction.class);
|
||||
when(exchangeFunction.exchange(any())).thenReturn(Mono.empty());
|
||||
given(exchangeFunction.exchange(any())).willReturn(Mono.empty());
|
||||
WebClient.Builder builder = WebClient.builder().baseUrl("/base").exchangeFunction(exchangeFunction);
|
||||
StepVerifier.create(builder.build().get().uri("/path").exchange())
|
||||
.expectErrorMessage("The underlying HTTP client completed without emitting a response.")
|
||||
|
||||
@@ -36,8 +36,8 @@ import org.springframework.web.reactive.function.BodyExtractors;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ExchangeFilterFunctions}.
|
||||
@@ -165,7 +165,7 @@ public class ExchangeFilterFunctionsTests {
|
||||
public void statusHandlerMatch() {
|
||||
ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL).build();
|
||||
ClientResponse response = mock(ClientResponse.class);
|
||||
when(response.statusCode()).thenReturn(HttpStatus.NOT_FOUND);
|
||||
given(response.statusCode()).willReturn(HttpStatus.NOT_FOUND);
|
||||
|
||||
ExchangeFunction exchange = r -> Mono.just(response);
|
||||
|
||||
@@ -183,7 +183,7 @@ public class ExchangeFilterFunctionsTests {
|
||||
public void statusHandlerNoMatch() {
|
||||
ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL).build();
|
||||
ClientResponse response = mock(ClientResponse.class);
|
||||
when(response.statusCode()).thenReturn(HttpStatus.NOT_FOUND);
|
||||
given(response.statusCode()).willReturn(HttpStatus.NOT_FOUND);
|
||||
|
||||
Mono<ClientResponse> result = ExchangeFilterFunctions
|
||||
.statusError(HttpStatus::is5xxServerError, req -> new MyException())
|
||||
|
||||
@@ -36,8 +36,8 @@ import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -62,7 +62,7 @@ public class ClientResponseWrapperTests {
|
||||
@Test
|
||||
public void statusCode() {
|
||||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||
when(mockResponse.statusCode()).thenReturn(status);
|
||||
given(mockResponse.statusCode()).willReturn(status);
|
||||
|
||||
assertSame(status, wrapper.statusCode());
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class ClientResponseWrapperTests {
|
||||
@Test
|
||||
public void rawStatusCode() {
|
||||
int status = 999;
|
||||
when(mockResponse.rawStatusCode()).thenReturn(status);
|
||||
given(mockResponse.rawStatusCode()).willReturn(status);
|
||||
|
||||
assertEquals(status, wrapper.rawStatusCode());
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class ClientResponseWrapperTests {
|
||||
@Test
|
||||
public void headers() {
|
||||
ClientResponse.Headers headers = mock(ClientResponse.Headers.class);
|
||||
when(mockResponse.headers()).thenReturn(headers);
|
||||
given(mockResponse.headers()).willReturn(headers);
|
||||
|
||||
assertSame(headers, wrapper.headers());
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class ClientResponseWrapperTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void cookies() {
|
||||
MultiValueMap<String, ResponseCookie> cookies = mock(MultiValueMap.class);
|
||||
when(mockResponse.cookies()).thenReturn(cookies);
|
||||
given(mockResponse.cookies()).willReturn(cookies);
|
||||
|
||||
assertSame(cookies, wrapper.cookies());
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class ClientResponseWrapperTests {
|
||||
public void bodyExtractor() {
|
||||
Mono<String> result = Mono.just("foo");
|
||||
BodyExtractor<Mono<String>, ReactiveHttpInputMessage> extractor = BodyExtractors.toMono(String.class);
|
||||
when(mockResponse.body(extractor)).thenReturn(result);
|
||||
given(mockResponse.body(extractor)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.body(extractor));
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class ClientResponseWrapperTests {
|
||||
@Test
|
||||
public void bodyToMonoClass() {
|
||||
Mono<String> result = Mono.just("foo");
|
||||
when(mockResponse.bodyToMono(String.class)).thenReturn(result);
|
||||
given(mockResponse.bodyToMono(String.class)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.bodyToMono(String.class));
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class ClientResponseWrapperTests {
|
||||
public void bodyToMonoParameterizedTypeReference() {
|
||||
Mono<String> result = Mono.just("foo");
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
when(mockResponse.bodyToMono(reference)).thenReturn(result);
|
||||
given(mockResponse.bodyToMono(reference)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.bodyToMono(reference));
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class ClientResponseWrapperTests {
|
||||
@Test
|
||||
public void bodyToFluxClass() {
|
||||
Flux<String> result = Flux.just("foo");
|
||||
when(mockResponse.bodyToFlux(String.class)).thenReturn(result);
|
||||
given(mockResponse.bodyToFlux(String.class)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.bodyToFlux(String.class));
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class ClientResponseWrapperTests {
|
||||
public void bodyToFluxParameterizedTypeReference() {
|
||||
Flux<String> result = Flux.just("foo");
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
when(mockResponse.bodyToFlux(reference)).thenReturn(result);
|
||||
given(mockResponse.bodyToFlux(reference)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.bodyToFlux(reference));
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class ClientResponseWrapperTests {
|
||||
@Test
|
||||
public void toEntityClass() {
|
||||
Mono<ResponseEntity<String>> result = Mono.just(new ResponseEntity<>("foo", HttpStatus.OK));
|
||||
when(mockResponse.toEntity(String.class)).thenReturn(result);
|
||||
given(mockResponse.toEntity(String.class)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.toEntity(String.class));
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public class ClientResponseWrapperTests {
|
||||
public void toEntityParameterizedTypeReference() {
|
||||
Mono<ResponseEntity<String>> result = Mono.just(new ResponseEntity<>("foo", HttpStatus.OK));
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
when(mockResponse.toEntity(reference)).thenReturn(result);
|
||||
given(mockResponse.toEntity(reference)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.toEntity(reference));
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class ClientResponseWrapperTests {
|
||||
@Test
|
||||
public void toEntityListClass() {
|
||||
Mono<ResponseEntity<List<String>>> result = Mono.just(new ResponseEntity<>(singletonList("foo"), HttpStatus.OK));
|
||||
when(mockResponse.toEntityList(String.class)).thenReturn(result);
|
||||
given(mockResponse.toEntityList(String.class)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.toEntityList(String.class));
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class ClientResponseWrapperTests {
|
||||
public void toEntityListParameterizedTypeReference() {
|
||||
Mono<ResponseEntity<List<String>>> result = Mono.just(new ResponseEntity<>(singletonList("foo"), HttpStatus.OK));
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
when(mockResponse.toEntityList(reference)).thenReturn(result);
|
||||
given(mockResponse.toEntityList(reference)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.toEntityList(reference));
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -139,14 +139,14 @@ public class DefaultRenderingResponseTests {
|
||||
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("http://localhost"));
|
||||
ViewResolver viewResolver = mock(ViewResolver.class);
|
||||
View view = mock(View.class);
|
||||
when(viewResolver.resolveViewName("view", Locale.ENGLISH)).thenReturn(Mono.just(view));
|
||||
when(view.render(model, null, exchange)).thenReturn(Mono.empty());
|
||||
given(viewResolver.resolveViewName("view", Locale.ENGLISH)).willReturn(Mono.just(view));
|
||||
given(view.render(model, null, exchange)).willReturn(Mono.empty());
|
||||
|
||||
List<ViewResolver> viewResolvers = new ArrayList<>();
|
||||
viewResolvers.add(viewResolver);
|
||||
|
||||
HandlerStrategies mockConfig = mock(HandlerStrategies.class);
|
||||
when(mockConfig.viewResolvers()).thenReturn(viewResolvers);
|
||||
given(mockConfig.viewResolvers()).willReturn(viewResolvers);
|
||||
|
||||
StepVerifier.create(result)
|
||||
.expectNextMatches(response -> "view".equals(response.name()) &&
|
||||
@@ -162,13 +162,13 @@ public class DefaultRenderingResponseTests {
|
||||
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("http://localhost"));
|
||||
TestView view = new TestView();
|
||||
ViewResolver viewResolver = mock(ViewResolver.class);
|
||||
when(viewResolver.resolveViewName(any(), any())).thenReturn(Mono.just(view));
|
||||
given(viewResolver.resolveViewName(any(), any())).willReturn(Mono.just(view));
|
||||
|
||||
List<ViewResolver> viewResolvers = new ArrayList<>();
|
||||
viewResolvers.add(viewResolver);
|
||||
|
||||
ServerResponse.Context context = mock(ServerResponse.Context.class);
|
||||
when(context.viewResolvers()).thenReturn(viewResolvers);
|
||||
given(context.viewResolvers()).willReturn(viewResolvers);
|
||||
|
||||
StepVerifier.create(result.flatMap(response -> response.writeTo(exchange, context)))
|
||||
.verifyComplete();
|
||||
|
||||
@@ -33,8 +33,8 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.web.reactive.function.server.support.ServerRequestWrapper;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -56,7 +56,7 @@ public class HeadersWrapperTests {
|
||||
@Test
|
||||
public void accept() {
|
||||
List<MediaType> accept = Collections.singletonList(MediaType.APPLICATION_JSON);
|
||||
when(mockHeaders.accept()).thenReturn(accept);
|
||||
given(mockHeaders.accept()).willReturn(accept);
|
||||
|
||||
assertSame(accept, wrapper.accept());
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class HeadersWrapperTests {
|
||||
@Test
|
||||
public void acceptCharset() {
|
||||
List<Charset> acceptCharset = Collections.singletonList(StandardCharsets.UTF_8);
|
||||
when(mockHeaders.acceptCharset()).thenReturn(acceptCharset);
|
||||
given(mockHeaders.acceptCharset()).willReturn(acceptCharset);
|
||||
|
||||
assertSame(acceptCharset, wrapper.acceptCharset());
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class HeadersWrapperTests {
|
||||
@Test
|
||||
public void contentLength() {
|
||||
OptionalLong contentLength = OptionalLong.of(42L);
|
||||
when(mockHeaders.contentLength()).thenReturn(contentLength);
|
||||
given(mockHeaders.contentLength()).willReturn(contentLength);
|
||||
|
||||
assertSame(contentLength, wrapper.contentLength());
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class HeadersWrapperTests {
|
||||
@Test
|
||||
public void contentType() {
|
||||
Optional<MediaType> contentType = Optional.of(MediaType.APPLICATION_JSON);
|
||||
when(mockHeaders.contentType()).thenReturn(contentType);
|
||||
given(mockHeaders.contentType()).willReturn(contentType);
|
||||
|
||||
assertSame(contentType, wrapper.contentType());
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class HeadersWrapperTests {
|
||||
@Test
|
||||
public void host() {
|
||||
InetSocketAddress host = InetSocketAddress.createUnresolved("example.com", 42);
|
||||
when(mockHeaders.host()).thenReturn(host);
|
||||
given(mockHeaders.host()).willReturn(host);
|
||||
|
||||
assertSame(host, wrapper.host());
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class HeadersWrapperTests {
|
||||
@Test
|
||||
public void range() {
|
||||
List<HttpRange> range = Collections.singletonList(HttpRange.createByteRange(42));
|
||||
when(mockHeaders.range()).thenReturn(range);
|
||||
given(mockHeaders.range()).willReturn(range);
|
||||
|
||||
assertSame(range, wrapper.range());
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class HeadersWrapperTests {
|
||||
public void header() {
|
||||
String name = "foo";
|
||||
List<String> value = Collections.singletonList("bar");
|
||||
when(mockHeaders.header(name)).thenReturn(value);
|
||||
given(mockHeaders.header(name)).willReturn(value);
|
||||
|
||||
assertSame(value, wrapper.header(name));
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class HeadersWrapperTests {
|
||||
@Test
|
||||
public void asHttpHeaders() {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
when(mockHeaders.asHttpHeaders()).thenReturn(httpHeaders);
|
||||
given(mockHeaders.asHttpHeaders()).willReturn(httpHeaders);
|
||||
|
||||
assertSame(httpHeaders, wrapper.asHttpHeaders());
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.springframework.web.server.WebFilterChain;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -55,7 +55,7 @@ public class RouterFunctionsTests {
|
||||
|
||||
MockServerRequest request = MockServerRequest.builder().build();
|
||||
RequestPredicate requestPredicate = mock(RequestPredicate.class);
|
||||
when(requestPredicate.test(request)).thenReturn(true);
|
||||
given(requestPredicate.test(request)).willReturn(true);
|
||||
|
||||
RouterFunction<ServerResponse>
|
||||
result = RouterFunctions.route(requestPredicate, handlerFunction);
|
||||
@@ -75,7 +75,7 @@ public class RouterFunctionsTests {
|
||||
|
||||
MockServerRequest request = MockServerRequest.builder().build();
|
||||
RequestPredicate requestPredicate = mock(RequestPredicate.class);
|
||||
when(requestPredicate.test(request)).thenReturn(false);
|
||||
given(requestPredicate.test(request)).willReturn(false);
|
||||
|
||||
RouterFunction<ServerResponse> result = RouterFunctions.route(requestPredicate, handlerFunction);
|
||||
assertNotNull(result);
|
||||
@@ -93,7 +93,7 @@ public class RouterFunctionsTests {
|
||||
|
||||
MockServerRequest request = MockServerRequest.builder().build();
|
||||
RequestPredicate requestPredicate = mock(RequestPredicate.class);
|
||||
when(requestPredicate.nest(request)).thenReturn(Optional.of(request));
|
||||
given(requestPredicate.nest(request)).willReturn(Optional.of(request));
|
||||
|
||||
RouterFunction<ServerResponse> result = RouterFunctions.nest(requestPredicate, routerFunction);
|
||||
assertNotNull(result);
|
||||
@@ -112,7 +112,7 @@ public class RouterFunctionsTests {
|
||||
|
||||
MockServerRequest request = MockServerRequest.builder().build();
|
||||
RequestPredicate requestPredicate = mock(RequestPredicate.class);
|
||||
when(requestPredicate.nest(request)).thenReturn(Optional.empty());
|
||||
given(requestPredicate.nest(request)).willReturn(Optional.empty());
|
||||
|
||||
RouterFunction<ServerResponse> result = RouterFunctions.nest(requestPredicate, routerFunction);
|
||||
assertNotNull(result);
|
||||
|
||||
@@ -37,8 +37,8 @@ import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -58,7 +58,7 @@ public class ServerRequestWrapperTests {
|
||||
@Test
|
||||
public void method() {
|
||||
HttpMethod method = HttpMethod.POST;
|
||||
when(mockRequest.method()).thenReturn(method);
|
||||
given(mockRequest.method()).willReturn(method);
|
||||
|
||||
assertSame(method, wrapper.method());
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class ServerRequestWrapperTests {
|
||||
@Test
|
||||
public void uri() {
|
||||
URI uri = URI.create("https://example.com");
|
||||
when(mockRequest.uri()).thenReturn(uri);
|
||||
given(mockRequest.uri()).willReturn(uri);
|
||||
|
||||
assertSame(uri, wrapper.uri());
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class ServerRequestWrapperTests {
|
||||
@Test
|
||||
public void path() {
|
||||
String path = "/foo/bar";
|
||||
when(mockRequest.path()).thenReturn(path);
|
||||
given(mockRequest.path()).willReturn(path);
|
||||
|
||||
assertSame(path, wrapper.path());
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class ServerRequestWrapperTests {
|
||||
@Test
|
||||
public void headers() {
|
||||
ServerRequest.Headers headers = mock(ServerRequest.Headers.class);
|
||||
when(mockRequest.headers()).thenReturn(headers);
|
||||
given(mockRequest.headers()).willReturn(headers);
|
||||
|
||||
assertSame(headers, wrapper.headers());
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class ServerRequestWrapperTests {
|
||||
public void attribute() {
|
||||
String name = "foo";
|
||||
String value = "bar";
|
||||
when(mockRequest.attribute(name)).thenReturn(Optional.of(value));
|
||||
given(mockRequest.attribute(name)).willReturn(Optional.of(value));
|
||||
|
||||
assertEquals(Optional.of(value), wrapper.attribute(name));
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class ServerRequestWrapperTests {
|
||||
public void queryParam() {
|
||||
String name = "foo";
|
||||
String value = "bar";
|
||||
when(mockRequest.queryParam(name)).thenReturn(Optional.of(value));
|
||||
given(mockRequest.queryParam(name)).willReturn(Optional.of(value));
|
||||
|
||||
assertEquals(Optional.of(value), wrapper.queryParam(name));
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class ServerRequestWrapperTests {
|
||||
public void queryParams() {
|
||||
MultiValueMap<String, String> value = new LinkedMultiValueMap<>();
|
||||
value.add("foo", "bar");
|
||||
when(mockRequest.queryParams()).thenReturn(value);
|
||||
given(mockRequest.queryParams()).willReturn(value);
|
||||
|
||||
assertSame(value, wrapper.queryParams());
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class ServerRequestWrapperTests {
|
||||
public void pathVariable() {
|
||||
String name = "foo";
|
||||
String value = "bar";
|
||||
when(mockRequest.pathVariable(name)).thenReturn(value);
|
||||
given(mockRequest.pathVariable(name)).willReturn(value);
|
||||
|
||||
assertEquals(value, wrapper.pathVariable(name));
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class ServerRequestWrapperTests {
|
||||
@Test
|
||||
public void pathVariables() {
|
||||
Map<String, String> pathVariables = Collections.singletonMap("foo", "bar");
|
||||
when(mockRequest.pathVariables()).thenReturn(pathVariables);
|
||||
given(mockRequest.pathVariables()).willReturn(pathVariables);
|
||||
|
||||
assertSame(pathVariables, wrapper.pathVariables());
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class ServerRequestWrapperTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void cookies() {
|
||||
MultiValueMap<String, HttpCookie> cookies = mock(MultiValueMap.class);
|
||||
when(mockRequest.cookies()).thenReturn(cookies);
|
||||
given(mockRequest.cookies()).willReturn(cookies);
|
||||
|
||||
assertSame(cookies, wrapper.cookies());
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class ServerRequestWrapperTests {
|
||||
public void bodyExtractor() {
|
||||
Mono<String> result = Mono.just("foo");
|
||||
BodyExtractor<Mono<String>, ReactiveHttpInputMessage> extractor = BodyExtractors.toMono(String.class);
|
||||
when(mockRequest.body(extractor)).thenReturn(result);
|
||||
given(mockRequest.body(extractor)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.body(extractor));
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public class ServerRequestWrapperTests {
|
||||
@Test
|
||||
public void bodyToMonoClass() {
|
||||
Mono<String> result = Mono.just("foo");
|
||||
when(mockRequest.bodyToMono(String.class)).thenReturn(result);
|
||||
given(mockRequest.bodyToMono(String.class)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.bodyToMono(String.class));
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public class ServerRequestWrapperTests {
|
||||
public void bodyToMonoParameterizedTypeReference() {
|
||||
Mono<String> result = Mono.just("foo");
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
when(mockRequest.bodyToMono(reference)).thenReturn(result);
|
||||
given(mockRequest.bodyToMono(reference)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.bodyToMono(reference));
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class ServerRequestWrapperTests {
|
||||
@Test
|
||||
public void bodyToFluxClass() {
|
||||
Flux<String> result = Flux.just("foo");
|
||||
when(mockRequest.bodyToFlux(String.class)).thenReturn(result);
|
||||
given(mockRequest.bodyToFlux(String.class)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.bodyToFlux(String.class));
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public class ServerRequestWrapperTests {
|
||||
public void bodyToFluxParameterizedTypeReference() {
|
||||
Flux<String> result = Flux.just("foo");
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
when(mockRequest.bodyToFlux(reference)).thenReturn(result);
|
||||
given(mockRequest.bodyToFlux(reference)).willReturn(result);
|
||||
|
||||
assertSame(result, wrapper.bodyToFlux(reference));
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ResourceWebHandler}.
|
||||
@@ -250,10 +250,10 @@ public class ResourceWebHandlerTests {
|
||||
// Use mock ResourceResolver: i.e. we're only testing upfront validations...
|
||||
|
||||
Resource resource = mock(Resource.class);
|
||||
when(resource.getFilename()).thenThrow(new AssertionError("Resource should not be resolved"));
|
||||
when(resource.getInputStream()).thenThrow(new AssertionError("Resource should not be resolved"));
|
||||
given(resource.getFilename()).willThrow(new AssertionError("Resource should not be resolved"));
|
||||
given(resource.getInputStream()).willThrow(new AssertionError("Resource should not be resolved"));
|
||||
ResourceResolver resolver = mock(ResourceResolver.class);
|
||||
when(resolver.resolveResource(any(), any(), any(), any())).thenReturn(Mono.just(resource));
|
||||
given(resolver.resolveResource(any(), any(), any(), any())).willReturn(Mono.just(resource));
|
||||
|
||||
ResourceWebHandler handler = new ResourceWebHandler();
|
||||
handler.setLocations(Collections.singletonList(new ClassPathResource("test/", getClass())));
|
||||
|
||||
@@ -50,8 +50,8 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get;
|
||||
|
||||
/**
|
||||
@@ -253,8 +253,8 @@ public class InvocableHandlerMethodTests {
|
||||
|
||||
private <T> HandlerMethodArgumentResolver stubResolver(Mono<Object> stubValue) {
|
||||
HandlerMethodArgumentResolver resolver = mock(HandlerMethodArgumentResolver.class);
|
||||
when(resolver.supportsParameter(any())).thenReturn(true);
|
||||
when(resolver.resolveArgument(any(), any(), any())).thenReturn(stubValue);
|
||||
given(resolver.supportsParameter(any())).willReturn(true);
|
||||
given(resolver.resolveArgument(any(), any(), any())).willReturn(stubValue);
|
||||
return resolver;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link SessionAttributeMethodArgumentResolver}.
|
||||
@@ -90,7 +90,7 @@ public class SessionAttributeMethodArgumentResolverTests {
|
||||
StepVerifier.create(mono).expectError(ServerWebInputException.class).verify();
|
||||
|
||||
Foo foo = new Foo();
|
||||
when(this.session.getAttribute("foo")).thenReturn(foo);
|
||||
given(this.session.getAttribute("foo")).willReturn(foo);
|
||||
mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange);
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class SessionAttributeMethodArgumentResolverTests {
|
||||
public void resolveWithName() {
|
||||
MethodParameter param = initMethodParameter(1);
|
||||
Foo foo = new Foo();
|
||||
when(this.session.getAttribute("specialFoo")).thenReturn(foo);
|
||||
given(this.session.getAttribute("specialFoo")).willReturn(foo);
|
||||
Mono<Object> mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange);
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class SessionAttributeMethodArgumentResolverTests {
|
||||
assertNull(mono.block());
|
||||
|
||||
Foo foo = new Foo();
|
||||
when(this.session.getAttribute("foo")).thenReturn(foo);
|
||||
given(this.session.getAttribute("foo")).willReturn(foo);
|
||||
mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange);
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class SessionAttributeMethodArgumentResolverTests {
|
||||
BindingContext bindingContext = new BindingContext(initializer);
|
||||
|
||||
Foo foo = new Foo();
|
||||
when(this.session.getAttribute("foo")).thenReturn(foo);
|
||||
given(this.session.getAttribute("foo")).willReturn(foo);
|
||||
actual = (Optional<Object>) this.resolver.resolveArgument(param, bindingContext, this.exchange).block();
|
||||
|
||||
assertNotNull(actual);
|
||||
|
||||
Reference in New Issue
Block a user