Add method validation to Spring MVC

See gh-29825
This commit is contained in:
Rossen Stoyanchev
2023-06-08 15:39:22 +01:00
committed by rstoyanchev
parent cb04c3b335
commit bd054a4918
15 changed files with 1000 additions and 27 deletions

View File

@@ -60,7 +60,7 @@ class ModelAttributeMethodProcessorKotlinTests {
val mockRequest = MockHttpServletRequest().apply { addParameter("a", "b") }
val requestWithParam = ServletWebRequest(mockRequest)
val factory = mock<WebDataBinderFactory>()
given(factory.createBinder(any(), any(), eq("param")))
given(factory.createBinder(any(), any(), eq("param"), any()))
.willAnswer { WebRequestDataBinder(it.getArgument(1)) }
assertThat(processor.resolveArgument(this.param, container, requestWithParam, factory)).isEqualTo(Param("b"))
}
@@ -70,7 +70,7 @@ class ModelAttributeMethodProcessorKotlinTests {
val mockRequest = MockHttpServletRequest().apply { addParameter("a", null) }
val requestWithParam = ServletWebRequest(mockRequest)
val factory = mock<WebDataBinderFactory>()
given(factory.createBinder(any(), any(), eq("param")))
given(factory.createBinder(any(), any(), eq("param"), any()))
.willAnswer { WebRequestDataBinder(it.getArgument(1)) }
assertThatThrownBy {
processor.resolveArgument(this.param, container, requestWithParam, factory)