Search in sources :

Example 21 with TestEntity

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));
    }
}
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 22 with TestEntity

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

Example 23 with TestEntity

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

Example 24 with TestEntity

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

Example 25 with TestEntity

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());
}
Also used : TestEntity(io.crnk.jpa.model.TestEntity) PagedMetaInformation(io.crnk.core.resource.meta.PagedMetaInformation) Test(org.junit.Test) AbstractJpaTest(io.crnk.jpa.query.AbstractJpaTest)

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