DATACMNS-358 - Test case for 1-index pages in PagedResourcesAssembler.

Added a test case to show that PagedResourcesAssembler correctly renders 1-indexed, empty pages after upgrading to Spring HATEOAS 0.8.0.BUILD-SNAPSHOT.
This commit is contained in:
Oliver Gierke
2013-08-26 18:30:34 +02:00
parent 1976878bd5
commit 77199cbec4
2 changed files with 17 additions and 1 deletions

View File

@@ -19,7 +19,7 @@
<properties>
<jackson>1.9.7</jackson>
<jackson2>2.2.2</jackson2>
<springhateoas>0.6.0.RELEASE</springhateoas>
<springhateoas>0.8.0.BUILD-SNAPSHOT</springhateoas>
<dist.key>DATACMNS</dist.key>
</properties>

View File

@@ -19,6 +19,7 @@ import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
@@ -100,6 +101,21 @@ public class PagedResourcesAssemblerUnitTests {
assertThat(resources.getLink(Link.REL_NEXT).getHref(), startsWith(link.getHref()));
}
/**
* @see DATACMNS-358
*/
@Test
public void createsPagedResourcesForOneIndexedArgumentResolver() {
resolver.setOneIndexedParameters(true);
PagedResourcesAssembler<Person> assembler = new PagedResourcesAssembler<Person>(resolver, null);
PageRequest request = new PageRequest(0, 1);
Page<Person> page = new PageImpl<Person>(Collections.<Person> emptyList(), request, 0);
assembler.toResource(page);
}
private static Page<Person> createPage(int index) {
PageRequest request = new PageRequest(index, 1);