use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class BasicQueryTestBase method testWithoutGraphControl.
@Test
public void testWithoutGraphControl() {
JpaQueryExecutor<TestEntity> exec = builder().addFilter(TestEntity.ATTR_oneRelatedValue, FilterOperator.NEQ, null).buildExecutor();
for (TestEntity test : exec.getResultList()) {
RelatedEntity relatedValue = test.getOneRelatedValue();
assertTrue(Hibernate.isInitialized(test));
assertFalse(Hibernate.isInitialized(relatedValue));
}
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class TestDTOMapper method unmap.
@Override
public TestEntity unmap(TestDTO dto) {
TestEntity entity = em.find(TestEntity.class, dto.getId());
if (entity == null) {
entity = new TestEntity();
entity.setId(dto.getId());
}
entity.setStringValue(dto.getStringValue());
// with the computed attribute. Usually they do not.
return entity;
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaEntityRepositoryTestBase method testFindOne.
@Test
public void testFindOne() throws InstantiationException, IllegalAccessException {
QuerySpec querySpec = new QuerySpec(TestEntity.class);
TestEntity entity = repo.findOne(1L, querySpec);
Assert.assertEquals("test1", entity.getStringValue());
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaEntityRepositoryTestBase method testFilterBooleanFalse.
@Test
public void testFilterBooleanFalse() throws InstantiationException, IllegalAccessException {
QuerySpec querySpec = new QuerySpec(TestEntity.class);
querySpec.addFilter(new FilterSpec(Arrays.asList("embValue", "nestedValue", "embBoolValue"), FilterOperator.EQ, false));
List<TestEntity> list = repo.findAll(querySpec);
Assert.assertEquals(numTestEntities - 1, list.size());
for (TestEntity entity : list) {
Assert.assertFalse(entity.getEmbValue().getNestedValue().getEmbBoolValue());
}
}
use of io.crnk.jpa.model.TestEntity 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());
}
Aggregations