use of io.crnk.core.resource.meta.HasMoreResourcesMetaInformation in project crnk-framework by crnk-project.
the class InMemoryEvaluatorTest method testNextPageMetaInformationIsTrue.
@Test
public void testNextPageMetaInformationIsTrue() {
QuerySpec spec = new QuerySpec(Task.class);
DefaultResourceList<Task> results = new DefaultResourceList<>();
results.setMeta(new DefaultHasMoreResourcesMetaInformation());
spec.setLimit(2L);
spec.apply(tasks, results);
Assert.assertEquals(2, results.size());
HasMoreResourcesMetaInformation meta = results.getMeta(HasMoreResourcesMetaInformation.class);
Assert.assertTrue(meta.getHasMoreResources());
}
use of io.crnk.core.resource.meta.HasMoreResourcesMetaInformation in project crnk-framework by crnk-project.
the class InMemoryEvaluatorTest method testNextPageMetaInformationIsFalse.
@Test
public void testNextPageMetaInformationIsFalse() {
QuerySpec spec = new QuerySpec(Task.class);
DefaultResourceList<Task> results = new DefaultResourceList<>();
results.setMeta(new DefaultHasMoreResourcesMetaInformation());
spec.setLimit(5L);
spec.apply(tasks, results);
HasMoreResourcesMetaInformation meta = results.getMeta(HasMoreResourcesMetaInformation.class);
Assert.assertEquals(5, results.size());
Assert.assertFalse(meta.getHasMoreResources());
}
use of io.crnk.core.resource.meta.HasMoreResourcesMetaInformation in project crnk-framework by crnk-project.
the class HasNextBasedPagedLinksInformationTest method testPaging.
@Test
public void testPaging() throws InstantiationException, IllegalAccessException {
QuerySpecAdapter querySpec = new QuerySpecAdapter(querySpec(2L, 2L), 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]=2", linksInformation.getFirst());
Assert.assertNull(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.meta.HasMoreResourcesMetaInformation in project crnk-framework by crnk-project.
the class HasNextBasedPagedLinksInformationTest method testPagingNoContents.
@Test
public void testPagingNoContents() throws InstantiationException, IllegalAccessException {
HasNextPageTestRepository.clear();
QuerySpecAdapter querySpec = new QuerySpecAdapter(querySpec(0L, 2L), resourceRegistry);
JsonApiResponse results = adapter.findAll(querySpec);
HasMoreResourcesMetaInformation metaInformation = (HasMoreResourcesMetaInformation) results.getMetaInformation();
Assert.assertFalse(metaInformation.getHasMoreResources());
PagedLinksInformation linksInformation = (PagedLinksInformation) results.getLinksInformation();
Assert.assertNull(linksInformation.getFirst());
Assert.assertNull(linksInformation.getLast());
Assert.assertNull(linksInformation.getPrev());
Assert.assertNull(linksInformation.getNext());
}
use of io.crnk.core.resource.meta.HasMoreResourcesMetaInformation 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);
}
Aggregations