Skip to content
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

2531 HateoasSortHandlerMethodArgumentResolver should append * to the … #1

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ public TemplateVariables getSortTemplateVariables(MethodParameter parameter, Uri
return TemplateVariables.NONE;
}

String description = String.format("pagination.%s.description", sortParameter);
String sortParameterExplode = sortParameter + '*';

String description = String.format("pagination.%s.description", sortParameterExplode);
TemplateVariable.VariableType type = append ? REQUEST_PARAM_CONTINUED : REQUEST_PARAM;
return new TemplateVariables(new TemplateVariable(sortParameter, type, description));
return new TemplateVariables(new TemplateVariable(sortParameterExplode, type, description));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ void preventsPageSizeFromExceedingMayValueIfConfiguredOnWrite() throws Exception
@Test // DATACMNS-418
void appendsTemplateVariablesCorrectly() {

assertTemplateEnrichment("/foo", "{?page,size,sort}");
assertTemplateEnrichment("/foo?bar=1", "{&page,size,sort}");
assertTemplateEnrichment("/foo?page=1", "{&size,sort}");
assertTemplateEnrichment("/foo?page=1&size=10", "{&sort}");
assertTemplateEnrichment("/foo", "{?page,size,sort*}");
assertTemplateEnrichment("/foo?bar=1", "{&page,size,sort*}");
assertTemplateEnrichment("/foo?page=1", "{&size,sort*}");
assertTemplateEnrichment("/foo?page=1&size=10", "{&sort*}");
assertTemplateEnrichment("/foo?page=1&sort=foo,asc", "{&size}");
assertTemplateEnrichment("/foo?page=1&size=10&sort=foo,asc", "");
}
Expand All @@ -90,7 +90,7 @@ void returnsCustomizedTemplateVariables() {
resolver.setPageParameterName("foo");
var variables = resolver.getPaginationTemplateVariables(null, uriComponents).toString();

assertThat(variables).isEqualTo("{?foo,size,sort}");
assertThat(variables).isEqualTo("{?foo,size,sort*}");
}

@Test // DATACMNS-563
Expand Down Expand Up @@ -128,7 +128,7 @@ void enhanceTemplateVariables() {
resolver.setPageParameterName("foo");
String variables = resolver.enhance(TemplateVariables.NONE, uriComponents, null).toString();

assertThat(variables).isEqualTo("{?foo,size,sort}");
assertThat(variables).isEqualTo("{?foo,size,sort*}");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void returnCorrectTemplateVariables() {
var uriComponents = UriComponentsBuilder.fromPath("/").build();

var resolver = new HateoasSortHandlerMethodArgumentResolver();
assertThat(resolver.getSortTemplateVariables(null, uriComponents).toString()).isEqualTo("{?sort}");
assertThat(resolver.getSortTemplateVariables(null, uriComponents).toString()).isEqualTo("{?sort*}");
}

@Test // DATACMNS-1752
Expand All @@ -65,7 +65,7 @@ void enhanceTemplateVariables(){
UriComponents uriComponents = UriComponentsBuilder.fromPath("/").build();

HateoasSortHandlerMethodArgumentResolver resolver = new HateoasSortHandlerMethodArgumentResolver();
assertThat(resolver.enhance(TemplateVariables.NONE, uriComponents, null).toString()).isEqualTo("{?sort}");
assertThat(resolver.enhance(TemplateVariables.NONE, uriComponents, null).toString()).isEqualTo("{?sort*}");
}

private void assertUriStringFor(Sort sort, String expected) throws Exception {
Expand Down