use of io.crnk.core.resource.links.PagedLinksInformation in project crnk-framework by crnk-project.
the class HasNextBasedPagedLinksInformationTest method testNoPaging.
@Test
public void testNoPaging() throws InstantiationException, IllegalAccessException {
QuerySpecAdapter querySpec = new QuerySpecAdapter(querySpec(), resourceRegistry);
JsonApiResponse results = adapter.findAll(querySpec);
HasMoreResourcesMetaInformation metaInformation = (HasMoreResourcesMetaInformation) results.getMetaInformation();
Assert.assertNull(metaInformation.getHasMoreResources());
PagedLinksInformation linksInformation = (PagedLinksInformation) results.getLinksInformation();
Assert.assertNull(linksInformation);
}
use of io.crnk.core.resource.links.PagedLinksInformation in project crnk-framework by crnk-project.
the class TotalBasedPagedLinksInformationTest method testPaging.
@Test
public void testPaging() throws InstantiationException, IllegalAccessException {
QuerySpecAdapter querySpec = new QuerySpecAdapter(querySpec(2L, 2L), resourceRegistry);
PagedLinksInformation linksInformation = (PagedLinksInformation) adapter.findAll(querySpec).getLinksInformation();
Assert.assertEquals("http://127.0.0.1/tasks?page[limit]=2", linksInformation.getFirst());
Assert.assertEquals("http://127.0.0.1/tasks?page[limit]=2&page[offset]=4", linksInformation.getLast());
Assert.assertEquals("http://127.0.0.1/tasks?page[limit]=2", linksInformation.getPrev());
Assert.assertEquals("http://127.0.0.1/tasks?page[limit]=2&page[offset]=4", linksInformation.getNext());
}
use of io.crnk.core.resource.links.PagedLinksInformation in project crnk-framework by crnk-project.
the class TotalBasedPagedLinksInformationTest method testPagingNoContents.
@Test
public void testPagingNoContents() throws InstantiationException, IllegalAccessException {
TotalResourceCountTestRepository.clear();
QuerySpecAdapter querySpec = new QuerySpecAdapter(querySpec(0L, 2L), resourceRegistry);
PagedLinksInformation linksInformation = (PagedLinksInformation) adapter.findAll(querySpec).getLinksInformation();
Assert.assertNull(linksInformation.getFirst());
Assert.assertNull(linksInformation.getLast());
Assert.assertNull(linksInformation.getPrev());
Assert.assertNull(linksInformation.getNext());
}
use of io.crnk.core.resource.links.PagedLinksInformation in project crnk-framework by crnk-project.
the class HasNextBasedPagedLinksInformationTest method testPagingLast.
@Test
public void testPagingLast() throws InstantiationException, IllegalAccessException {
QuerySpecAdapter querySpec = new QuerySpecAdapter(querySpec(4L, 4L), resourceRegistry);
JsonApiResponse results = adapter.findAll(querySpec);
HasMoreResourcesMetaInformation metaInformation = (HasMoreResourcesMetaInformation) results.getMetaInformation();
Assert.assertFalse(metaInformation.getHasMoreResources());
PagedLinksInformation linksInformation = (PagedLinksInformation) results.getLinksInformation();
Assert.assertEquals("http://127.0.0.1/tasks?page[limit]=4", linksInformation.getFirst());
Assert.assertNull(linksInformation.getLast());
Assert.assertEquals("http://127.0.0.1/tasks?page[limit]=4", linksInformation.getFirst());
Assert.assertNull(linksInformation.getNext());
}
use of io.crnk.core.resource.links.PagedLinksInformation in project crnk-framework by crnk-project.
the class HasNextBasedPagedLinksInformationTest method testPagingFirst.
@Test
public void testPagingFirst() throws InstantiationException, IllegalAccessException {
QuerySpecAdapter querySpec = new QuerySpecAdapter(querySpec(0L, 3L), resourceRegistry);
JsonApiResponse results = adapter.findAll(querySpec);
HasMoreResourcesMetaInformation metaInformation = (HasMoreResourcesMetaInformation) results.getMetaInformation();
Assert.assertTrue(metaInformation.getHasMoreResources());
PagedLinksInformation linksInformation = (PagedLinksInformation) results.getLinksInformation();
Assert.assertEquals("http://127.0.0.1/tasks?page[limit]=3", linksInformation.getFirst());
Assert.assertNull(linksInformation.getLast());
Assert.assertNull(linksInformation.getPrev());
Assert.assertEquals("http://127.0.0.1/tasks?page[limit]=3&page[offset]=3", linksInformation.getNext());
}
Aggregations