@@ -108,11 +108,14 @@ class AnnotatedValueResolverTest {
108
108
"value3" ,
109
109
"value2" );
110
110
111
+ static final Set <String > queryParamMaps = ImmutableSet .of ("queryParamMap" ,
112
+ "queryParamListMap" ,
113
+ "queryParamSetMap" );
114
+
111
115
static final ResolverContext resolverContext ;
112
116
static final ServiceRequestContext context ;
113
117
static final HttpRequest request ;
114
118
static final RequestHeaders originalHeaders ;
115
- static final String QUERY_PARAM_MAP = "queryParamMap" ;
116
119
static Map <String , AttributeKey <?>> successExpectAttrKeys ;
117
120
static Map <String , AttributeKey <?>> failExpectAttrKeys ;
118
121
@@ -182,6 +185,15 @@ void ofMethods() {
182
185
// Ignore this exception because MixedBean class has not annotated method.
183
186
}
184
187
});
188
+
189
+ // Validate that invalid multi-value map parameter types trigger an exception
190
+ getAllMethods (InvalidMultiValueMapService .class ,
191
+ method -> !Modifier .isPrivate (method .getModifiers ())).forEach (
192
+ method -> assertThatThrownBy (() -> AnnotatedValueResolver .ofServiceMethod (
193
+ method , pathParams , objectResolvers , false , noopDependencyInjector , null ))
194
+ .isInstanceOf (IllegalArgumentException .class )
195
+ .hasMessageContaining ("Invalid Map value type" )
196
+ );
185
197
}
186
198
187
199
@ Test
@@ -364,7 +376,7 @@ private static void testResolver(AnnotatedValueResolver resolver) {
364
376
}
365
377
}
366
378
} else {
367
- if (QUERY_PARAM_MAP . equals (resolver .httpElementName ())) {
379
+ if (queryParamMaps . contains (resolver .httpElementName ())) {
368
380
assertThat (resolver .defaultValue ()).isNull ();
369
381
} else {
370
382
assertThat (resolver .defaultValue ()).isNotNull ();
@@ -376,7 +388,7 @@ private static void testResolver(AnnotatedValueResolver resolver) {
376
388
.isEqualTo (resolver .elementType ());
377
389
} else if (resolver .shouldWrapValueAsOptional ()) {
378
390
assertThat (value ).isEqualTo (Optional .of (resolver .defaultValue ()));
379
- } else if (QUERY_PARAM_MAP . equals (resolver .httpElementName ())) {
391
+ } else if (queryParamMaps . contains (resolver .httpElementName ())) {
380
392
assertThat (value ).isNotNull ();
381
393
assertThat (value ).isInstanceOf (Map .class );
382
394
assertThat ((Map <?, ?>) value ).size ()
@@ -459,6 +471,8 @@ void method1(@Param String var1,
459
471
@ Param @ Default List <String > emptyParam3 ,
460
472
@ Param @ Default List <Integer > emptyParam4 ,
461
473
@ Param Map <String , Object > queryParamMap ,
474
+ @ Param Map <String , List <Object >> queryParamListMap ,
475
+ @ Param Map <String , Set <Object >> queryParamSetMap ,
462
476
@ Header List <String > header1 ,
463
477
@ Header ("header1" ) Optional <List <ValueEnum >> optionalHeader1 ,
464
478
@ Header String header2 ,
@@ -519,7 +533,7 @@ void attributeTest(
519
533
Queue <String > successQueueToQueue ,
520
534
@ Attribute ("failCastListToSet" )
521
535
Set <String > failCastListToSet
522
- ) { }
536
+ ) {}
523
537
524
538
void time (@ Param @ Default ("PT20.345S" ) Duration duration ,
525
539
@ Param @ Default ("2007-12-03T10:15:30.00Z" ) Instant instant ,
@@ -534,6 +548,10 @@ void time(@Param @Default("PT20.345S") Duration duration,
534
548
@ Param @ Default ("+01:00:00" ) ZoneOffset zoneOffset ) {}
535
549
}
536
550
551
+ static class InvalidMultiValueMapService {
552
+ void invalidParamWithMapOfMap (@ Param Map <String , Map <String , String >> param ) {}
553
+ }
554
+
537
555
private static Map <String , AttributeKey <?>> injectFailCaseOfAttrKeyToServiceContextForAttributeTest () {
538
556
final ServiceRequestContext ctx = resolverContext .context ();
539
557
final Map <String , AttributeKey <?>> expectFailAttrs = new HashMap <>();
0 commit comments