Skip to content

Commit

Permalink
2531 HateoasSortHandlerMethodArgumentResolver should append * to the …
Browse files Browse the repository at this point in the history
…'sort' parameter template variable

Fixing tests
  • Loading branch information
Julien Béti authored and reda-alaoui committed Sep 28, 2023
1 parent 4100df6 commit fc4f42f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
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

0 comments on commit fc4f42f

Please sign in to comment.