Search in sources :

Example 1 with SequenceEntity

use of io.crnk.jpa.model.SequenceEntity in project crnk-framework by crnk-project.

the class JpaEntityRepositoryTestBase method testSequencePrimaryKey.

@Test
public void testSequencePrimaryKey() throws InstantiationException, IllegalAccessException {
    JpaEntityRepository<SequenceEntity, Long> sequenceRepo = new JpaEntityRepository<>(module, JpaRepositoryConfig.create(SequenceEntity.class));
    QuerySpec querySpec = new QuerySpec(SequenceEntity.class);
    List<SequenceEntity> list = sequenceRepo.findAll(querySpec);
    Assert.assertEquals(0, list.size());
    SequenceEntity entity = new SequenceEntity();
    entity.setStringValue("someValue");
    entity = sequenceRepo.create(entity);
    Assert.assertNotNull(entity.getId());
    Assert.assertNotEquals(0L, entity.getId().longValue());
    entity.setStringValue("someUpdatedValue");
    entity = sequenceRepo.save(entity);
    Assert.assertEquals("someUpdatedValue", entity.getStringValue());
}
Also used : SequenceEntity(io.crnk.jpa.model.SequenceEntity) JpaEntityRepository(io.crnk.jpa.JpaEntityRepository) Test(org.junit.Test) AbstractJpaTest(io.crnk.jpa.query.AbstractJpaTest)

Aggregations

JpaEntityRepository (io.crnk.jpa.JpaEntityRepository)1 SequenceEntity (io.crnk.jpa.model.SequenceEntity)1 AbstractJpaTest (io.crnk.jpa.query.AbstractJpaTest)1 Test (org.junit.Test)1