19
19
import java .lang .reflect .Method ;
20
20
import java .util .List ;
21
21
import java .util .Locale ;
22
+ import java .util .Set ;
22
23
import java .util .function .Consumer ;
23
24
24
25
import jakarta .validation .Valid ;
@@ -201,9 +202,7 @@ void validateValueListArgument() {
201
202
Method method = getMethod (target , "addHobbies" );
202
203
203
204
testArgs (target , method , new Object [] {List .of (" " )}, ex -> {
204
-
205
205
assertThat (ex .getAllValidationResults ()).hasSize (1 );
206
-
207
206
assertValueResult (ex .getValueResults ().get (0 ), 0 , " " , List .of ("""
208
207
org.springframework.context.support.DefaultMessageSourceResolvable: \
209
208
codes [NotBlank.myService#addHobbies.hobbies,NotBlank.hobbies,NotBlank.java.util.List,NotBlank]; \
@@ -213,6 +212,22 @@ void validateValueListArgument() {
213
212
});
214
213
}
215
214
215
+ @ Test // gh-33150
216
+ void validateValueSetArgument () {
217
+ MyService target = new MyService ();
218
+ Method method = getMethod (target , "addUniqueHobbies" );
219
+
220
+ testArgs (target , method , new Object [] {Set .of ("test" , " " )}, ex -> {
221
+ assertThat (ex .getAllValidationResults ()).hasSize (1 );
222
+ assertValueResult (ex .getValueResults ().get (0 ), 0 , Set .of ("test" , " " ), List .of ("""
223
+ org.springframework.context.support.DefaultMessageSourceResolvable: \
224
+ codes [NotBlank.myService#addUniqueHobbies.hobbies,NotBlank.hobbies,NotBlank.java.util.Set,NotBlank]; \
225
+ arguments [org.springframework.context.support.DefaultMessageSourceResolvable: \
226
+ codes [myService#addUniqueHobbies.hobbies,hobbies]; \
227
+ arguments []; default message [hobbies]]; default message [must not be blank]""" ));
228
+ });
229
+ }
230
+
216
231
private void testArgs (Object target , Method method , Object [] args , Consumer <MethodValidationResult > consumer ) {
217
232
consumer .accept (this .validationAdapter .validateArguments (target , method , null , args , new Class <?>[0 ]));
218
233
}
@@ -271,6 +286,8 @@ public void addPeople(@Valid List<Person> people) {
271
286
public void addHobbies (List <@ NotBlank String > hobbies ) {
272
287
}
273
288
289
+ public void addUniqueHobbies (Set <@ NotBlank String > hobbies ) {
290
+ }
274
291
}
275
292
276
293
0 commit comments