use of io.crnk.jpa.JpaEntityRepository 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());
}
use of io.crnk.jpa.JpaEntityRepository in project crnk-framework by crnk-project.
the class JpaEntityRepositoryTestBase method testFieldOnlyEntity.
@Test
// currently not supported
@Ignore
public void testFieldOnlyEntity() throws InstantiationException, IllegalAccessException {
QuerySpec querySpec = new QuerySpec(FieldOnlyEntity.class);
JpaEntityRepository<FieldOnlyEntity, Long> fieldRepo = new JpaEntityRepository<>(module, JpaRepositoryConfig.create(FieldOnlyEntity.class));
List<FieldOnlyEntity> list = fieldRepo.findAll(querySpec);
Assert.assertEquals(0, list.size());
FieldOnlyEntity entity = new FieldOnlyEntity();
entity.id = 13L;
entity.longValue = 14L;
fieldRepo.create(entity);
FieldOnlyEntity savedEntity = fieldRepo.findOne(13L, querySpec);
Assert.assertNotNull(savedEntity);
Assert.assertEquals(14L, savedEntity.longValue);
fieldRepo.delete(13L);
list = fieldRepo.findAll(querySpec);
Assert.assertEquals(0, list.size());
}
use of io.crnk.jpa.JpaEntityRepository in project crnk-framework by crnk-project.
the class QuerydslRepositoryFilterTest method translationInterceptor.
@SuppressWarnings("unchecked")
@Test
public void translationInterceptor() {
JpaEntityRepository<TestEntity, Long> repo = new JpaEntityRepository<>(module, JpaRepositoryConfig.create(TestEntity.class));
QuerydslRepositoryFilterBase filter = Mockito.spy(new QuerydslRepositoryFilterBase());
module.addFilter(filter);
QuerySpec querySpec = new QuerySpec(TestEntity.class);
repo.findAll(querySpec);
Mockito.verify(filter, Mockito.times(1)).filterQueryTranslation(Mockito.eq(repo), Mockito.eq(querySpec), Mockito.any(QuerydslTranslationContext.class));
}
Aggregations