use of org.apache.deltaspike.data.test.domain.Simple in project deltaspike by apache.
the class EntityManagerDelegateHandlerTest method should_delete_detached_entity.
@Test
public void should_delete_detached_entity() {
// given
Simple simple = testData.createSimple("should_merge_entity");
Long id = simple.getId();
// when
repository.detach(simple);
repository.remove(repository.merge(simple));
// then
assertNotNull(id);
Simple search = repository.findBy(id);
assertNull(search);
}
use of org.apache.deltaspike.data.test.domain.Simple in project deltaspike by apache.
the class EntityRepositoryHandlerTest method should_remove.
@Test
public void should_remove() {
// given
Simple simple = testData.createSimple("testRemove");
// when
repo.remove(simple);
repo.flush();
Simple lookup = getEntityManager().find(Simple.class, simple.getId());
// then
assertNull(lookup);
}
use of org.apache.deltaspike.data.test.domain.Simple in project deltaspike by apache.
the class EntityRepositoryHandlerTest method should_find_by_example_with_no_attributes.
@Test
@SuppressWarnings("unchecked")
public void should_find_by_example_with_no_attributes() throws Exception {
// given
Simple simple = testData.createSimple("testFindByExample");
SingularAttribute<Simple, ?>[] attributes = new SingularAttribute[] {};
// when
List<Simple> find = repo.findBy(simple, attributes);
// then
assertNotNull(find);
assertFalse(find.isEmpty());
assertEquals(simple.getName(), find.get(0).getName());
}
use of org.apache.deltaspike.data.test.domain.Simple in project deltaspike by apache.
the class EntityRepositoryHandlerTest method should_count_by_like.
@Test
@SuppressWarnings("unchecked")
public void should_count_by_like() {
// given
testData.createSimple("testFindAll1");
testData.createSimple("testFindAll2");
Simple example = new Simple("test");
// when
Long count = repo.countLike(example, Simple_.name);
// then
assertEquals(Long.valueOf(2), count);
}
use of org.apache.deltaspike.data.test.domain.Simple in project deltaspike by apache.
the class CriteriaTest method should_create_select_criteria_with_any_result.
@Test
public void should_create_select_criteria_with_any_result() {
// given
final String name = "should_create_select_criteria_with_any_result";
createSimple(name, 10);
createSimple(name, 10);
// when
Simple result1 = repo.queryAny(name);
Simple result2 = repo.queryAny(name + "_doesnt exist");
// then
assertNotNull(result1);
assertEquals(name, result1.getName());
assertNull(result2);
}
Aggregations