Search in sources :

Example 46 with TestEntity

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());
    }
}
Also used : CollectionAttributesTestEntity(io.crnk.jpa.model.CollectionAttributesTestEntity) UuidTestEntity(io.crnk.jpa.model.UuidTestEntity) TestEntity(io.crnk.jpa.model.TestEntity) Test(org.junit.Test)

Example 47 with TestEntity

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()));
    }
}
Also used : CollectionAttributesTestEntity(io.crnk.jpa.model.CollectionAttributesTestEntity) UuidTestEntity(io.crnk.jpa.model.UuidTestEntity) TestEntity(io.crnk.jpa.model.TestEntity) Test(org.junit.Test)

Example 48 with TestEntity

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));
        }
    }
}
Also used : CollectionAttributesTestEntity(io.crnk.jpa.model.CollectionAttributesTestEntity) UuidTestEntity(io.crnk.jpa.model.UuidTestEntity) TestEntity(io.crnk.jpa.model.TestEntity) RelatedEntity(io.crnk.jpa.model.RelatedEntity) Test(org.junit.Test)

Example 49 with TestEntity

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());
        }
    }
}
Also used : CollectionAttributesTestEntity(io.crnk.jpa.model.CollectionAttributesTestEntity) UuidTestEntity(io.crnk.jpa.model.UuidTestEntity) TestEntity(io.crnk.jpa.model.TestEntity) Test(org.junit.Test)

Example 50 with TestEntity

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));
}
Also used : TestEntity(io.crnk.jpa.model.TestEntity) ResourceField(io.crnk.core.engine.information.resource.ResourceField) RelatedEntity(io.crnk.jpa.model.RelatedEntity) Before(org.junit.Before)

Aggregations

TestEntity (io.crnk.jpa.model.TestEntity)61 Test (org.junit.Test)50 AbstractJpaJerseyTest (io.crnk.jpa.AbstractJpaJerseyTest)28 QuerySpec (io.crnk.core.queryspec.QuerySpec)25 RelatedEntity (io.crnk.jpa.model.RelatedEntity)24 AbstractJpaTest (io.crnk.jpa.query.AbstractJpaTest)16 OtherRelatedEntity (io.crnk.jpa.model.OtherRelatedEntity)12 QueryParams (io.crnk.legacy.queryParams.QueryParams)6 CollectionAttributesTestEntity (io.crnk.jpa.model.CollectionAttributesTestEntity)5 UuidTestEntity (io.crnk.jpa.model.UuidTestEntity)5 Serializable (java.io.Serializable)5 JsonLinksInformation (io.crnk.client.response.JsonLinksInformation)4 JsonMetaInformation (io.crnk.client.response.JsonMetaInformation)4 PagedMetaInformation (io.crnk.core.resource.meta.PagedMetaInformation)4 TestDTO (io.crnk.jpa.model.dto.TestDTO)2 ObjectProxy (io.crnk.client.internal.proxy.ObjectProxy)1 ResourceField (io.crnk.core.engine.information.resource.ResourceField)1 FilterSpec (io.crnk.core.queryspec.FilterSpec)1 JpaEntityRepository (io.crnk.jpa.JpaEntityRepository)1 JpaRepositoryFilterBase (io.crnk.jpa.JpaRepositoryFilterBase)1