28
28
import org .springframework .core .MethodParameter ;
29
29
import org .springframework .core .annotation .SynthesizingMethodParameter ;
30
30
import org .springframework .format .support .DefaultFormattingConversionService ;
31
- import org .springframework .validation .BindException ;
32
31
import org .springframework .validation .BindingResult ;
33
32
import org .springframework .validation .Errors ;
33
+ import org .springframework .web .bind .MethodArgumentNotValidException ;
34
34
import org .springframework .web .bind .WebDataBinder ;
35
35
import org .springframework .web .bind .annotation .ModelAttribute ;
36
36
import org .springframework .web .bind .annotation .SessionAttributes ;
@@ -109,7 +109,7 @@ public void setup() throws Exception {
109
109
110
110
111
111
@ Test
112
- public void supportedParameters () throws Exception {
112
+ public void supportedParameters () {
113
113
assertThat (this .processor .supportsParameter (this .paramNamedValidModelAttr )).isTrue ();
114
114
assertThat (this .processor .supportsParameter (this .paramModelAttr )).isTrue ();
115
115
@@ -119,8 +119,8 @@ public void supportedParameters() throws Exception {
119
119
}
120
120
121
121
@ Test
122
- public void supportedParametersInDefaultResolutionMode () throws Exception {
123
- processor = new ModelAttributeMethodProcessor (true );
122
+ public void supportedParametersInDefaultResolutionMode () {
123
+ this . processor = new ModelAttributeMethodProcessor (true );
124
124
125
125
// Only non-simple types, even if not annotated
126
126
assertThat (this .processor .supportsParameter (this .paramNamedValidModelAttr )).isTrue ();
@@ -132,21 +132,21 @@ public void supportedParametersInDefaultResolutionMode() throws Exception {
132
132
}
133
133
134
134
@ Test
135
- public void supportedReturnTypes () throws Exception {
136
- processor = new ModelAttributeMethodProcessor (false );
135
+ public void supportedReturnTypes () {
136
+ this . processor = new ModelAttributeMethodProcessor (false );
137
137
assertThat (this .processor .supportsReturnType (returnParamNamedModelAttr )).isTrue ();
138
138
assertThat (this .processor .supportsReturnType (returnParamNonSimpleType )).isFalse ();
139
139
}
140
140
141
141
@ Test
142
- public void supportedReturnTypesInDefaultResolutionMode () throws Exception {
143
- processor = new ModelAttributeMethodProcessor (true );
142
+ public void supportedReturnTypesInDefaultResolutionMode () {
143
+ this . processor = new ModelAttributeMethodProcessor (true );
144
144
assertThat (this .processor .supportsReturnType (returnParamNamedModelAttr )).isTrue ();
145
145
assertThat (this .processor .supportsReturnType (returnParamNonSimpleType )).isTrue ();
146
146
}
147
147
148
148
@ Test
149
- public void bindExceptionRequired () throws Exception {
149
+ public void bindExceptionRequired () {
150
150
assertThat (this .processor .isBindExceptionRequired (null , this .paramNonSimpleType )).isTrue ();
151
151
assertThat (this .processor .isBindExceptionRequired (null , this .paramNamedValidModelAttr )).isFalse ();
152
152
}
@@ -227,11 +227,13 @@ public void resolveArgumentBindException() throws Exception {
227
227
228
228
StubRequestDataBinder dataBinder = new StubRequestDataBinder (target , name );
229
229
dataBinder .getBindingResult ().reject ("error" );
230
+
230
231
WebDataBinderFactory binderFactory = mock ();
231
232
given (binderFactory .createBinder (this .request , target , name )).willReturn (dataBinder );
232
233
233
- assertThatExceptionOfType (BindException .class ).isThrownBy (() ->
234
+ assertThatExceptionOfType (MethodArgumentNotValidException .class ).isThrownBy (() ->
234
235
this .processor .resolveArgument (this .paramNonSimpleType , this .container , this .request , binderFactory ));
236
+
235
237
verify (binderFactory ).createBinder (this .request , target , name );
236
238
}
237
239
0 commit comments