DATACMNS-519 - PagedResourcesAssembler now keeps template variables of base link.

Significant overhaul of the link creation in PagedResourcesAssembler.
This commit is contained in:
Oliver Gierke
2014-06-11 10:11:39 +02:00
parent 1697c77f31
commit 28b3221bcf
3 changed files with 61 additions and 25 deletions

View File

@@ -168,6 +168,21 @@ public class PagedResourcesAssemblerUnitTests {
assertThat(assembler.appendPaginationParameterTemplates(link), is(new Link("/foo?page=0{&size,sort}")));
}
/**
* @see DATACMNS-519
*/
@Test
public void keepsExistingTemplateVariablesFromBaseLink() {
PagedResourcesAssembler<Person> assembler = new PagedResourcesAssembler<Person>(resolver, null);
Link link = new Link("/foo?page=0{&projection}");
Link result = assembler.appendPaginationParameterTemplates(link);
assertThat(result.getVariableNames(), hasSize(3));
assertThat(result.getVariableNames(), hasItems("projection", "size", "sort"));
}
private static Page<Person> createPage(int index) {
AbstractPageRequest request = new PageRequest(index, 1);