-
Notifications
You must be signed in to change notification settings - Fork 926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for HTTP GET map parameters #6072
base: main
Are you sure you want to change the base?
Changes from 4 commits
169c2fc
e152414
caee7ef
5f6abad
ffe3bb9
f3ba5a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,7 @@ class AnnotatedValueResolverTest { | |
static final ServiceRequestContext context; | ||
static final HttpRequest request; | ||
static final RequestHeaders originalHeaders; | ||
static final String QUERY_PARAM_MAP = "queryParamMap"; | ||
static Map<String, AttributeKey<?>> successExpectAttrKeys; | ||
static Map<String, AttributeKey<?>> failExpectAttrKeys; | ||
|
||
|
@@ -358,19 +359,30 @@ private static void testResolver(AnnotatedValueResolver resolver) { | |
} else { | ||
if (String.class.isAssignableFrom(resolver.elementType())) { | ||
assertThat(value).isEqualTo(""); | ||
} else if (QUERY_PARAM_MAP.equals(resolver.httpElementName())) { | ||
assertThat(value).isNotNull(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this line of code is not invoked. Would you explain why you've added this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @minwoox Thank you for pointing this out! 🙇 |
||
} else { | ||
assertThat(value).isNull(); | ||
} | ||
} | ||
} else { | ||
assertThat(resolver.defaultValue()).isNotNull(); | ||
if (QUERY_PARAM_MAP.equals(resolver.httpElementName())) { | ||
assertThat(resolver.defaultValue()).isNull(); | ||
} else { | ||
assertThat(resolver.defaultValue()).isNotNull(); | ||
} | ||
if (resolver.hasContainer() && List.class.isAssignableFrom(resolver.containerType())) { | ||
assertThat((List<Object>) value).hasSize(1) | ||
.containsOnly(resolver.defaultValue()); | ||
assertThat(((List<Object>) value).get(0).getClass()) | ||
.isEqualTo(resolver.elementType()); | ||
} else if (resolver.shouldWrapValueAsOptional()) { | ||
assertThat(value).isEqualTo(Optional.of(resolver.defaultValue())); | ||
} else if (QUERY_PARAM_MAP.equals(resolver.httpElementName())) { | ||
assertThat(value).isNotNull(); | ||
assertThat(value).isInstanceOf(Map.class); | ||
assertThat((Map<?, ?>) value).size() | ||
.isEqualTo(existingHttpParameters.size() + existingWithoutValueParameters.size()); | ||
} else { | ||
assertThat(value).isEqualTo(resolver.defaultValue()); | ||
} | ||
|
@@ -447,6 +459,7 @@ void method1(@Param String var1, | |
@Param @Default Integer emptyParam2, | ||
@Param @Default List<String> emptyParam3, | ||
@Param @Default List<Integer> emptyParam4, | ||
@Param Map<String, Object> queryParamMap, | ||
@Header List<String> header1, | ||
@Header("header1") Optional<List<ValueEnum>> optionalHeader1, | ||
@Header String header2, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about raising an exception if the value is specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@minwoox Thank you for the suggestion! 🙇
I've updated the code to raise an exception when a value is specified for a Map parameter and added the test cases. Please take a look when you have time.