use of io.crnk.core.resource.meta.PagedMetaInformation in project crnk-framework by crnk-project.
the class JpaRelationshipRepositoryTestBase method testFindNulledOneTargetWithLimit.
/**
* Note that implementation behaves slightly differently with a LIMIT in place. Does only work for single requests.
*/
@Test
public void testFindNulledOneTargetWithLimit() throws InstantiationException, IllegalAccessException {
long nulledEntityId = numTestEntities - 1;
QuerySpec querySpec = new QuerySpec(RelatedEntity.class);
querySpec.setLimit(5L);
RelatedEntity relatedEntity = repo.findOneTarget(nulledEntityId, TestEntity.ATTR_oneRelatedValue, querySpec);
Assert.assertNull(relatedEntity);
ResourceList<RelatedEntity> list = repo.findManyTargets(nulledEntityId, TestEntity.ATTR_oneRelatedValue, querySpec);
Assert.assertEquals(0, list.size());
PagedMetaInformation pagedMeta = list.getMeta(PagedMetaInformation.class);
Assert.assertNotNull(pagedMeta.getTotalResourceCount());
Assert.assertEquals(Long.valueOf(0L), pagedMeta.getTotalResourceCount());
}
use of io.crnk.core.resource.meta.PagedMetaInformation in project crnk-framework by crnk-project.
the class JpaEntityRepositoryTestBase method testPagingLast.
@Test
public void testPagingLast() throws InstantiationException, IllegalAccessException {
QuerySpec querySpec = new QuerySpec(TestEntity.class);
querySpec.setOffset(4L);
querySpec.setLimit(4L);
ResourceList<TestEntity> list = repo.findAll(querySpec);
Assert.assertEquals(1, list.size());
Assert.assertEquals(4, list.get(0).getId().intValue());
PagedMetaInformation metaInformation = list.getMeta(PagedMetaInformation.class);
Assert.assertEquals(5, metaInformation.getTotalResourceCount().longValue());
}
use of io.crnk.core.resource.meta.PagedMetaInformation in project crnk-framework by crnk-project.
the class JpaRelationshipRepositoryTestBase method testGetManyRelationWithPaging.
@Test
public void testGetManyRelationWithPaging() throws InstantiationException, IllegalAccessException {
TestEntity test = setupManyRelation(Arrays.asList(100L, 101L, 102L, 103L, 104L));
QuerySpec querySpec = new QuerySpec(TestEntity.class);
querySpec.setOffset(2L);
querySpec.setLimit(2L);
ResourceList<RelatedEntity> list = repo.findManyTargets(test.getId(), TestEntity.ATTR_manyRelatedValues, querySpec);
Assert.assertEquals(2, list.size());
Assert.assertEquals(102, list.get(0).getId().intValue());
Assert.assertEquals(103, list.get(1).getId().intValue());
PagedMetaInformation metaInformation = list.getMeta(PagedMetaInformation.class);
Assert.assertEquals(5, metaInformation.getTotalResourceCount().longValue());
}
use of io.crnk.core.resource.meta.PagedMetaInformation in project crnk-framework by crnk-project.
the class JpaEntityRepositoryTestBase method testPaging.
@Test
public void testPaging() throws InstantiationException, IllegalAccessException {
QuerySpec querySpec = new QuerySpec(TestEntity.class);
querySpec.setOffset(2L);
querySpec.setLimit(2L);
ResourceList<TestEntity> list = repo.findAll(querySpec);
Assert.assertEquals(2, list.size());
Assert.assertEquals(2, list.get(0).getId().intValue());
Assert.assertEquals(3, list.get(1).getId().intValue());
PagedMetaInformation metaInformation = list.getMeta(PagedMetaInformation.class);
Assert.assertEquals(5, metaInformation.getTotalResourceCount().longValue());
}
use of io.crnk.core.resource.meta.PagedMetaInformation in project crnk-framework by crnk-project.
the class JpaEntityRepositoryTestBase method testPagingFirst.
@Test
public void testPagingFirst() throws InstantiationException, IllegalAccessException {
QuerySpec querySpec = new QuerySpec(TestEntity.class);
querySpec.setOffset(0L);
querySpec.setLimit(3L);
ResourceList<TestEntity> list = repo.findAll(querySpec);
Assert.assertEquals(3, list.size());
Assert.assertEquals(0, list.get(0).getId().intValue());
Assert.assertEquals(1, list.get(1).getId().intValue());
Assert.assertEquals(2, list.get(2).getId().intValue());
PagedMetaInformation metaInformation = list.getMeta(PagedMetaInformation.class);
Assert.assertEquals(5, metaInformation.getTotalResourceCount().longValue());
}
Aggregations