use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaQueryParamsEndToEndTest method testSaveOneRelation.
@Test
public void testSaveOneRelation() {
TestEntity test = addTestWithOneRelation();
TestEntity savedTest = testRepo.findOne(2L, includeOneRelatedValueParams());
Assert.assertEquals(test.getId(), savedTest.getId());
Assert.assertEquals(test.getStringValue(), savedTest.getStringValue());
Assert.assertNotNull(savedTest.getOneRelatedValue());
Assert.assertEquals(1L, savedTest.getOneRelatedValue().getId().longValue());
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaQueryParamsEndToEndTest method testIncludeNoRelations.
@Test
public void testIncludeNoRelations() throws InstantiationException, IllegalAccessException {
addTestWithOneRelation();
List<TestEntity> list = testRepo.findAll(new QueryParams());
Assert.assertEquals(1, list.size());
for (TestEntity test : list) {
// in the future we may get proxies here
Assert.assertNull(test.getOneRelatedValue());
}
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaQueryParamsEndToEndTest method addTestWithOneRelation.
private TestEntity addTestWithOneRelation() {
ResourceRepositoryStub<RelatedEntity, Long> relatedRepo = client.getQueryParamsRepository(RelatedEntity.class);
RelatedEntity related = new RelatedEntity();
related.setId(1L);
related.setStringValue("project");
relatedRepo.create(related);
TestEntity test = new TestEntity();
test.setId(2L);
test.setStringValue("test");
test.setOneRelatedValue(related);
testRepo.create(test);
return test;
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaQueryParamsEndToEndTest method testSaveAndFind.
@Test
public void testSaveAndFind() {
TestEntity task = new TestEntity();
task.setId(1L);
task.setStringValue("test");
testRepo.create(task);
// check retrievable with findAll
List<TestEntity> list = testRepo.findAll(new QueryParams());
Assert.assertEquals(1, list.size());
TestEntity savedTask = list.get(0);
Assert.assertEquals(task.getId(), savedTask.getId());
Assert.assertEquals(task.getStringValue(), savedTask.getStringValue());
// check retrievable with findAll(ids)
list = testRepo.findAll(Arrays.asList(1L), new QueryParams());
Assert.assertEquals(1, list.size());
savedTask = list.get(0);
Assert.assertEquals(task.getId(), savedTask.getId());
Assert.assertEquals(task.getStringValue(), savedTask.getStringValue());
// check retrievable with findOne
savedTask = testRepo.findOne(1L, new QueryParams());
Assert.assertEquals(task.getId(), savedTask.getId());
Assert.assertEquals(task.getStringValue(), savedTask.getStringValue());
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaQueryParamsEndToEndTest method testFindEmpty.
@Test
public void testFindEmpty() {
List<TestEntity> list = testRepo.findAll(new QueryParams());
Assert.assertTrue(list.isEmpty());
}
Aggregations