Polishing
See gh-23846 See gh-29955 Closes gh-29992
This commit is contained in:
@@ -329,6 +329,7 @@ public class CacheControl {
|
||||
* Adding a {@link #maxAge(Duration) max-age} directive is strongly advised
|
||||
* to enforce the actual freshness lifetime.
|
||||
* @return {@code this}, to facilitate method chaining
|
||||
* @since 6.0.5
|
||||
* @see <a href="https://tools.ietf.org/html/rfc8246">rfc8246</a>
|
||||
*/
|
||||
public CacheControl immutable() {
|
||||
|
||||
@@ -74,6 +74,7 @@ public class MethodArgumentNotValidException extends BindException implements Er
|
||||
* Constructor for {@link MethodArgumentNotValidException}.
|
||||
* @param executable the executable that failed validation
|
||||
* @param bindingResult the results of the validation
|
||||
* @since 6.0.5
|
||||
*/
|
||||
public MethodArgumentNotValidException(Executable executable, BindingResult bindingResult) {
|
||||
super(bindingResult);
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.BDDMockito;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -37,6 +36,7 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.testfixture.http.MockHttpOutputMessage;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
@@ -187,9 +187,9 @@ public class ResourceRegionHttpMessageConverterTests {
|
||||
public void applicationOctetStreamDefaultContentType() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
ClassPathResource body = mock();
|
||||
BDDMockito.given(body.getFilename()).willReturn("spring.dat");
|
||||
BDDMockito.given(body.contentLength()).willReturn(12L);
|
||||
BDDMockito.given(body.getInputStream()).willReturn(new ByteArrayInputStream("Spring Framework".getBytes()));
|
||||
given(body.getFilename()).willReturn("spring.dat");
|
||||
given(body.contentLength()).willReturn(12L);
|
||||
given(body.getInputStream()).willReturn(new ByteArrayInputStream("Spring Framework".getBytes()));
|
||||
HttpRange range = HttpRange.createByteRange(0, 5);
|
||||
ResourceRegion resourceRegion = range.toResourceRegion(body);
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.ArgumentMatchers.*
|
||||
import org.mockito.BDDMockito
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.BDDMockito.given
|
||||
import org.mockito.Mockito.mock
|
||||
import org.springframework.core.MethodParameter
|
||||
import org.springframework.core.annotation.SynthesizingMethodParameter
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException
|
||||
@@ -51,7 +51,7 @@ class ModelAttributeMethodProcessorKotlinTests {
|
||||
fun setup() {
|
||||
container = ModelAndViewContainer()
|
||||
processor = ModelAttributeMethodProcessor(false)
|
||||
var method = ModelAttributeHandler::class.java.getDeclaredMethod("test",Param::class.java)
|
||||
val method = ModelAttributeHandler::class.java.getDeclaredMethod("test", Param::class.java)
|
||||
param = SynthesizingMethodParameter(method, 0)
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ class ModelAttributeMethodProcessorKotlinTests {
|
||||
fun resolveArgumentWithValue() {
|
||||
val mockRequest = MockHttpServletRequest().apply { addParameter("a", "b") }
|
||||
val requestWithParam = ServletWebRequest(mockRequest)
|
||||
val factory = Mockito.mock<WebDataBinderFactory>()
|
||||
BDDMockito.given(factory.createBinder(any(), any(), eq("param")))
|
||||
val factory = mock<WebDataBinderFactory>()
|
||||
given(factory.createBinder(any(), any(), eq("param")))
|
||||
.willAnswer { WebRequestDataBinder(it.getArgument(1)) }
|
||||
assertThat(processor.resolveArgument(this.param, container, requestWithParam, factory)).isEqualTo(Param("b"))
|
||||
}
|
||||
@@ -69,8 +69,8 @@ class ModelAttributeMethodProcessorKotlinTests {
|
||||
fun throwMethodArgumentNotValidExceptionWithNull() {
|
||||
val mockRequest = MockHttpServletRequest().apply { addParameter("a", null) }
|
||||
val requestWithParam = ServletWebRequest(mockRequest)
|
||||
val factory = Mockito.mock<WebDataBinderFactory>()
|
||||
BDDMockito.given(factory.createBinder(any(), any(), eq("param")))
|
||||
val factory = mock<WebDataBinderFactory>()
|
||||
given(factory.createBinder(any(), any(), eq("param")))
|
||||
.willAnswer { WebRequestDataBinder(it.getArgument(1)) }
|
||||
assertThatThrownBy {
|
||||
processor.resolveArgument(this.param, container, requestWithParam, factory)
|
||||
@@ -80,8 +80,8 @@ class ModelAttributeMethodProcessorKotlinTests {
|
||||
|
||||
private data class Param(val a: String)
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
private class ModelAttributeHandler {
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun test(param: Param) { }
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.web.server
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.BDDMockito
|
||||
import org.mockito.BDDMockito.given
|
||||
import org.mockito.Mockito
|
||||
import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest
|
||||
import org.springframework.web.testfixture.server.MockServerWebExchange
|
||||
@@ -35,7 +35,7 @@ class CoWebFilterTests {
|
||||
val exchange = MockServerWebExchange.from(MockServerHttpRequest.get("https://example.com"))
|
||||
|
||||
val chain = Mockito.mock(WebFilterChain::class.java)
|
||||
BDDMockito.given(chain.filter(exchange)).willReturn(Mono.empty())
|
||||
given(chain.filter(exchange)).willReturn(Mono.empty())
|
||||
|
||||
val filter = MyCoWebFilter()
|
||||
val result = filter.filter(exchange, chain)
|
||||
|
||||
Reference in New Issue
Block a user