DATACMNS-1455 - HateoasPageableHandlerMethodArgumentResolver handles Pageable.unpaged() coprrectly.
Pageable.unpaged() is now effectively handled like a null value given in the 1.x branch.
This commit is contained in:
@@ -28,6 +28,7 @@ import org.springframework.hateoas.TemplateVariable.VariableType;
|
||||
import org.springframework.hateoas.TemplateVariables;
|
||||
import org.springframework.hateoas.mvc.UriComponentsContributor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
@@ -104,12 +105,18 @@ public class HateoasPageableHandlerMethodArgumentResolver extends PageableHandle
|
||||
@Override
|
||||
public void enhance(UriComponentsBuilder builder, @Nullable MethodParameter parameter, Object value) {
|
||||
|
||||
Assert.notNull(builder, "UriComponentsBuilder must not be null!");
|
||||
|
||||
if (!(value instanceof Pageable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Pageable pageable = (Pageable) value;
|
||||
|
||||
if (pageable.isUnpaged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String pagePropertyName = getParameterNameToUse(getPageParameterName(), parameter);
|
||||
String sizePropertyName = getParameterNameToUse(getSizeParameterName(), parameter);
|
||||
|
||||
|
||||
@@ -109,6 +109,16 @@ public class HateoasPageableHandlerMethodArgumentResolverUnitTests
|
||||
assertThat(params.getFirst(resolver.getPageParameterName())).isEqualTo("1");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1455
|
||||
public void enhancesUnpaged() {
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/");
|
||||
|
||||
getResolver().enhance(builder, null, Pageable.unpaged());
|
||||
|
||||
assertThat(builder).isEqualTo(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HateoasPageableHandlerMethodArgumentResolver getResolver() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user