1
1
/*
2
- * Copyright 2002-2022 the original author or authors.
2
+ * Copyright 2002-2023 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -91,8 +91,8 @@ public void supportsParameter() {
91
91
assertThat (this .resolver .supportsParameter (this .paramAnnotated )).isTrue ();
92
92
assertThat (this .resolver .supportsParameter (this .paramNotAnnotated )).isTrue ();
93
93
94
- PayloadMethodArgumentResolver strictResolver = new PayloadMethodArgumentResolver (
95
- new StringMessageConverter (), testValidator (), false );
94
+ PayloadMethodArgumentResolver strictResolver =
95
+ new PayloadMethodArgumentResolver ( new StringMessageConverter (), testValidator (), false );
96
96
97
97
assertThat (strictResolver .supportsParameter (this .paramAnnotated )).isTrue ();
98
98
assertThat (strictResolver .supportsParameter (this .paramNotAnnotated )).isFalse ();
@@ -107,19 +107,19 @@ public void resolveRequired() throws Exception {
107
107
}
108
108
109
109
@ Test
110
- public void resolveRequiredEmpty () throws Exception {
110
+ public void resolveRequiredEmpty () {
111
111
Message <?> message = MessageBuilder .withPayload ("" ).build ();
112
112
// required but empty
113
- assertThatExceptionOfType (MethodArgumentNotValidException .class ). isThrownBy (() ->
114
- this .resolver .resolveArgument (paramAnnotated , message ));
113
+ assertThatExceptionOfType (MethodArgumentNotValidException .class )
114
+ . isThrownBy (() -> this .resolver .resolveArgument (paramAnnotated , message ));
115
115
}
116
116
117
117
@ Test
118
- public void resolveRequiredEmptyNonAnnotatedParameter () throws Exception {
118
+ public void resolveRequiredEmptyNonAnnotatedParameter () {
119
119
Message <?> message = MessageBuilder .withPayload ("" ).build ();
120
120
// required but empty
121
- assertThatExceptionOfType (MethodArgumentNotValidException .class ). isThrownBy (() ->
122
- this .resolver .resolveArgument (this .paramNotAnnotated , message ));
121
+ assertThatExceptionOfType (MethodArgumentNotValidException .class )
122
+ . isThrownBy (() -> this .resolver .resolveArgument (this .paramNotAnnotated , message ));
123
123
}
124
124
125
125
@ Test
@@ -135,20 +135,20 @@ public void resolveNotRequired() throws Exception {
135
135
}
136
136
137
137
@ Test
138
- public void resolveNonConvertibleParam () throws Exception {
138
+ public void resolveNonConvertibleParam () {
139
139
Message <?> notEmptyMessage = MessageBuilder .withPayload (123 ).build ();
140
140
141
- assertThatExceptionOfType (MessageConversionException .class ). isThrownBy (() ->
142
- this .resolver .resolveArgument (this .paramAnnotatedRequired , notEmptyMessage ))
143
- .withMessageContaining ("Cannot convert" );
141
+ assertThatExceptionOfType (MessageConversionException .class )
142
+ . isThrownBy (() -> this .resolver .resolveArgument (this .paramAnnotatedRequired , notEmptyMessage ))
143
+ .withMessageContaining ("Cannot convert" );
144
144
}
145
145
146
146
@ Test
147
- public void resolveSpelExpressionNotSupported () throws Exception {
147
+ public void resolveSpelExpressionNotSupported () {
148
148
Message <?> message = MessageBuilder .withPayload ("ABC" .getBytes ()).build ();
149
149
150
- assertThatIllegalStateException (). isThrownBy (() ->
151
- this .resolver .resolveArgument (paramWithSpelExpression , message ));
150
+ assertThatIllegalStateException ()
151
+ . isThrownBy (() -> this .resolver .resolveArgument (paramWithSpelExpression , message ));
152
152
}
153
153
154
154
@ Test
@@ -158,20 +158,20 @@ public void resolveValidation() throws Exception {
158
158
}
159
159
160
160
@ Test
161
- public void resolveFailValidation () throws Exception {
161
+ public void resolveFailValidation () {
162
162
// See testValidator()
163
163
Message <?> message = MessageBuilder .withPayload ("invalidValue" .getBytes ()).build ();
164
164
165
- assertThatExceptionOfType (MethodArgumentNotValidException .class ). isThrownBy (() ->
166
- this .resolver .resolveArgument (this .paramValidated , message ));
165
+ assertThatExceptionOfType (MethodArgumentNotValidException .class )
166
+ . isThrownBy (() -> this .resolver .resolveArgument (this .paramValidated , message ));
167
167
}
168
168
169
169
@ Test
170
- public void resolveFailValidationNoConversionNecessary () throws Exception {
170
+ public void resolveFailValidationNoConversionNecessary () {
171
171
Message <?> message = MessageBuilder .withPayload ("invalidValue" ).build ();
172
172
173
- assertThatExceptionOfType (MethodArgumentNotValidException .class ). isThrownBy (() ->
174
- this .resolver .resolveArgument (this .paramValidated , message ));
173
+ assertThatExceptionOfType (MethodArgumentNotValidException .class )
174
+ . isThrownBy (() -> this .resolver .resolveArgument (this .paramValidated , message ));
175
175
}
176
176
177
177
@ Test
@@ -180,17 +180,18 @@ public void resolveNonAnnotatedParameter() throws Exception {
180
180
assertThat (this .resolver .resolveArgument (this .paramNotAnnotated , notEmptyMessage )).isEqualTo ("ABC" );
181
181
182
182
Message <?> emptyStringMessage = MessageBuilder .withPayload ("" ).build ();
183
- assertThatExceptionOfType (MethodArgumentNotValidException .class ). isThrownBy (() ->
184
- this .resolver .resolveArgument (this .paramValidated , emptyStringMessage ));
183
+ assertThatExceptionOfType (MethodArgumentNotValidException .class )
184
+ . isThrownBy (() -> this .resolver .resolveArgument (this .paramValidated , emptyStringMessage ));
185
185
}
186
186
187
187
@ Test
188
- public void resolveNonAnnotatedParameterFailValidation () throws Exception {
188
+ public void resolveNonAnnotatedParameterFailValidation () {
189
189
// See testValidator()
190
190
Message <?> message = MessageBuilder .withPayload ("invalidValue" .getBytes ()).build ();
191
191
192
- assertThatExceptionOfType (MethodArgumentNotValidException .class ).isThrownBy (() -> assertThat (this .resolver .resolveArgument (this .paramValidatedNotAnnotated , message )).isEqualTo ("invalidValue" ))
193
- .withMessageContaining ("invalid value" );
192
+ assertThatExceptionOfType (MethodArgumentNotValidException .class )
193
+ .isThrownBy (() -> this .resolver .resolveArgument (this .paramValidatedNotAnnotated , message ))
194
+ .withMessageContaining ("invalid value" );
194
195
}
195
196
196
197
0 commit comments