use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.
the class AbstractEntityViewRepositoryTest method createTestData.
private void createTestData() {
Person[] persons = new Person[] { new Person(1L, "Mother", 0), new Person(2L, "John Doe", 2), new Person(3L, "James Harley", 4), new Person(4L, "Berry Cooper", 5), new Person(5L, "John Smith", 4, "King Street"), new Person(6L, "Harry Norman", 1, "Rich Street"), new Person(7L, "Harry Norman", 3, "King Street") };
persons[1].setParent(persons[0]);
persons[2].setParent(persons[0]);
persons[3].setParent(persons[1]);
persons[4].setParent(persons[2]);
persons[5].setParent(persons[2]);
persons[6].setParent(persons[2]);
for (Person person : persons) {
em.persist(person);
}
}
use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.
the class ExtendedEntityViewRepositoryTest method testFindAnyByNameIsNullOrderByIdAsc.
@Test
public void testFindAnyByNameIsNullOrderByIdAsc() {
assertNull(personViewRepository.findAnyByNameIsNullOrderByIdAsc());
final Person newPerson = new Person(persons[persons.length - 1].getId() + 1, null, 0);
transactional(new Runnable() {
@Override
public void run() {
em.persist(newPerson);
}
});
PersonView result = personViewRepository.findAnyByNameIsNullOrderByIdAsc();
assertEquals(newPerson.getId(), result.getId());
}
use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.
the class ExtendedEntityViewRepositoryTest method testFindByQuery.
@Test
public void testFindByQuery() {
Person result1 = personViewRepository.getJohnDoe();
assertEquals(persons[1].getId(), result1.getId());
}
use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.
the class FullEntityViewRepositoryTest method testFindByPaginated.
@Test
public void testFindByPaginated() {
Person example = new Person();
example.setPosition(4);
// we do not test DeltaSpike's findBy(E, int, int, SingularAttribute<E,?>...) method here because its results are non-deterministic
List<PersonView> page2 = personViewRepository.findBy(example, 1, 1, Person_.position);
assertEquals(1, page2.size());
assertEquals(persons[4].getId(), page2.get(0).getId());
List<PersonView> page1 = personViewRepository.findBy(example, 0, 1, Person_.position);
assertEquals(1, page1.size());
assertEquals(persons[2].getId(), page1.get(0).getId());
}
use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.
the class FullEntityViewRepositoryTest method testFindByNamePaginatedEntity.
@Test
public void testFindByNamePaginatedEntity() {
// we do not test DeltaSpike's findAll(int, int) method here because its results are non-deterministic
List<Person> actual = personRepository.findByNameLike("John %", new PageRequest(0, 1, Sort.Direction.ASC, "id"));
assertTrue(actual instanceof PagedList<?>);
assertEquals(1, actual.size());
assertEquals("John Doe", actual.get(0).getName());
actual = personRepository.findByNameLike("John %", new PageRequest(1, 1, Sort.Direction.ASC, "id"));
assertEquals(1, actual.size());
assertEquals("John Smith", actual.get(0).getName());
}
Aggregations