use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class BasicQueryTestBase method testTotalOrderNoSorting.
@Test
public void testTotalOrderNoSorting() {
testPaging(false);
JpaQueryExecutor<TestEntity> exec = builder().buildExecutor();
for (int i = 0; i < 5; i++) {
exec.setWindow(i, 1);
TestEntity entity = exec.getUniqueResult(false);
assertEquals(i, entity.getId().intValue());
}
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class BasicQueryTestBase method testWithGraphControlWithJoin.
@Test
public void testWithGraphControlWithJoin() {
JpaQueryExecutor<TestEntity> exec = builder().addFilter(TestEntity.ATTR_oneRelatedValue, FilterOperator.NEQ, null).buildExecutor().fetch(Arrays.asList(TestEntity.ATTR_oneRelatedValue));
for (TestEntity test : exec.getResultList()) {
assertTrue(Hibernate.isInitialized(test));
assertTrue(Hibernate.isInitialized(test.getOneRelatedValue()));
}
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class BasicQueryTestBase method testWithGraphControlWithoutJoin.
@Test
public void testWithGraphControlWithoutJoin() {
JpaQueryExecutor<TestEntity> exec = builder().buildExecutor().fetch(Arrays.asList(TestEntity.ATTR_oneRelatedValue));
for (TestEntity test : exec.getResultList()) {
assertTrue(Hibernate.isInitialized(test));
RelatedEntity relatedValue = test.getOneRelatedValue();
if (relatedValue != null) {
assertTrue(Hibernate.isInitialized(relatedValue));
}
}
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class BasicQueryTestBase method testTotalOrderNoTotalSorting.
@Test
public void testTotalOrderNoTotalSorting() {
JpaQueryExecutor<TestEntity> exec = builder().addSortBy(TestEntity.ATTR_embValue_nestedValue_boolValue, Direction.ASC).buildExecutor();
for (int i = 0; i < 5; i++) {
exec.setWindow(i, 1);
TestEntity entity = exec.getUniqueResult(false);
if (i == 4) {
assertTrue(entity.getEmbValue().getNestedValue().getEmbBoolValue());
assertEquals(0, entity.getId().intValue());
} else {
assertFalse(entity.getEmbValue().getNestedValue().getEmbBoolValue());
assertEquals(1 + i, entity.getId().intValue());
}
}
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaRelationshipRepositoryTestBase method setup.
@Override
@Before
public void setup() {
super.setup();
ResourceField resourceField = this.resourceRegistry.getEntry(TestEntity.class).getResourceInformation().findFieldByUnderlyingName("oneRelatedValue");
ResourceField relatedField = this.resourceRegistry.getEntry(RelatedEntity.class).getResourceInformation().findFieldByUnderlyingName("testEntity");
repo = new JpaRelationshipRepository<TestEntity, Long, RelatedEntity, Long>(module, resourceField, JpaRepositoryConfig.create(RelatedEntity.class));
relatedRepo = new JpaRelationshipRepository<RelatedEntity, Long, TestEntity, Long>(module, relatedField, JpaRepositoryConfig.create(TestEntity.class));
}
Aggregations