use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaQuerySpecEndToEndTest method testDelete.
@Test
public void testDelete() {
TestEntity test = new TestEntity();
test.setId(1L);
test.setStringValue("test");
testRepo.create(test);
testRepo.delete(1L);
List<TestEntity> list = testRepo.findAll(new QuerySpec(TestEntity.class));
Assert.assertEquals(0, list.size());
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaQuerySpecEndToEndTest method addTest.
private TestEntity addTest() {
TestEntity test = new TestEntity();
test.setId(2L);
test.setStringValue("test");
testRepo.create(test);
return test;
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaQuerySpecEndToEndTest method testIncludeEmptyRelations.
@Test
public void testIncludeEmptyRelations() throws InstantiationException, IllegalAccessException {
addTest();
QuerySpec querySpec = new QuerySpec(TestEntity.class);
querySpec.includeRelation(Arrays.asList(TestEntity.ATTR_oneRelatedValue));
querySpec.includeRelation(Arrays.asList(TestEntity.ATTR_manyRelatedValues));
List<TestEntity> list = testRepo.findAll(querySpec);
Assert.assertEquals(1, list.size());
for (TestEntity test : list) {
Assert.assertNull(test.getOneRelatedValue());
Assert.assertEquals(0, test.getManyRelatedValues().size());
}
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaPartialEntityExposureTest method testCrud.
@Test
public void testCrud() {
TestEntity test = new TestEntity();
test.setId(2L);
test.setStringValue("test");
testRepo.save(test);
List<TestEntity> tests = testRepo.findAll(new QueryParams());
Assert.assertEquals(1, tests.size());
test = tests.get(0);
Assert.assertEquals(2L, test.getId().longValue());
Assert.assertNull(test.getOneRelatedValue());
Assert.assertNull(test.getEagerRelatedValue());
Assert.assertTrue(test.getManyRelatedValues().isEmpty());
testRepo.delete(test.getId());
tests = testRepo.findAll(new QueryParams());
Assert.assertEquals(0, tests.size());
}
use of io.crnk.jpa.model.TestEntity in project crnk-framework by crnk-project.
the class JpaRepositoryDecoratorTest method addTestWithOneRelation.
private TestEntity addTestWithOneRelation() {
ResourceRepositoryV2<RelatedEntity, Long> relatedRepo = client.getQuerySpecRepository(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");
testRepo.create(test);
RelationshipRepositoryV2<TestEntity, Long, RelatedEntity, Long> relRepo = client.getQuerySpecRepository(TestEntity.class, RelatedEntity.class);
relRepo.setRelation(test, related.getId(), TestEntity.ATTR_oneRelatedValue);
return test;
}
Aggregations