use of io.crnk.jpa.model.TestIdEmbeddable in project crnk-framework by crnk-project.
the class JpaQuerySpecEndToEndTest method testEmbeddableIds.
@Test
public void testEmbeddableIds() throws InstantiationException, IllegalAccessException {
ResourceRepositoryV2<TestEmbeddedIdEntity, Serializable> rep = client.getQuerySpecRepository(TestEmbeddedIdEntity.class);
// add
TestEmbeddedIdEntity entity = new TestEmbeddedIdEntity();
entity.setId(new TestIdEmbeddable(13, "test"));
entity.setLongValue(100L);
rep.create(entity);
List<TestEmbeddedIdEntity> list = rep.findAll(new QuerySpec(TestEntity.class));
Assert.assertEquals(1, list.size());
TestEmbeddedIdEntity savedEntity = list.get(0);
Assert.assertNotNull(savedEntity);
Assert.assertEquals(100L, savedEntity.getLongValue());
Assert.assertEquals(13, savedEntity.getId().getEmbIntValue().intValue());
Assert.assertEquals("test", savedEntity.getId().getEmbStringValue());
// update
savedEntity.setLongValue(101L);
rep.save(savedEntity);
list = rep.findAll(new QuerySpec(TestEntity.class));
Assert.assertEquals(1, list.size());
savedEntity = list.get(0);
Assert.assertEquals(101L, savedEntity.getLongValue());
// delete
rep.delete(entity.getId());
list = rep.findAll(new QuerySpec(TestEntity.class));
Assert.assertEquals(0, list.size());
}
use of io.crnk.jpa.model.TestIdEmbeddable in project crnk-framework by crnk-project.
the class JpaQueryParamsEndToEndTest method testEmbeddableIds.
@Test
public void testEmbeddableIds() throws InstantiationException, IllegalAccessException {
ResourceRepositoryStub<TestEmbeddedIdEntity, Serializable> rep = client.getQueryParamsRepository(TestEmbeddedIdEntity.class);
// add
TestEmbeddedIdEntity entity = new TestEmbeddedIdEntity();
entity.setId(new TestIdEmbeddable(13, "test"));
entity.setLongValue(100L);
rep.create(entity);
List<TestEmbeddedIdEntity> list = rep.findAll(new QueryParams());
Assert.assertEquals(1, list.size());
TestEmbeddedIdEntity savedEntity = list.get(0);
Assert.assertNotNull(savedEntity);
Assert.assertEquals(100L, savedEntity.getLongValue());
Assert.assertEquals(13, savedEntity.getId().getEmbIntValue().intValue());
Assert.assertEquals("test", savedEntity.getId().getEmbStringValue());
// update
savedEntity.setLongValue(101L);
rep.save(savedEntity);
list = rep.findAll(new QueryParams());
Assert.assertEquals(1, list.size());
savedEntity = list.get(0);
Assert.assertEquals(101L, savedEntity.getLongValue());
// delete
rep.delete(entity.getId());
list = rep.findAll(new QueryParams());
Assert.assertEquals(0, list.size());
}
Aggregations