use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.
the class AbstractEntityViewRepositoryTest method init.
@Override
public void init() {
super.init();
EntityManagerProducer.setEmf(emf);
// Boot the container after publishing the entity manager factory
CdiContainer container = CdiContainerLoader.getCdiContainer();
container.boot();
transactional(new Runnable() {
@Override
public void run() {
persons = cbf.create(em, Person.class).orderByAsc("id").getResultList().toArray(new Person[0]);
}
});
}
use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.
the class FullEntityViewRepositoryTest method testFindByLikePaginated.
@Test
public void testFindByLikePaginated() {
Person example = new Person();
example.setName("John %");
// we do not test DeltaSpike's findByLike(E, int, int, SingularAttribute<E,?>...) method here because its results are non-deterministic
List<PersonView> page2 = personViewRepository.findByLike(example, 1, 1, Person_.name);
assertEquals(1, page2.size());
assertEquals(persons[4].getId(), page2.get(0).getId());
List<PersonView> page1 = personViewRepository.findByLike(example, 0, 1, Person_.name);
assertEquals(1, page1.size());
assertEquals(persons[1].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 testFindByLike.
@Test
public void testFindByLike() {
List<PersonView> expected = Arrays.asList(fetch(PersonView.class, persons[1].getId()), fetch(PersonView.class, persons[4].getId()));
Person example = new Person();
example.setName("John %");
// we do not test DeltaSpike's findByLike(E, SingularAttribute<E,?>...) method here because its results are non-deterministic
assertEquals(expected, personViewRepository.findByLike(example, Person_.name));
}
use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.
the class FullEntityViewRepositoryTest method testFindSliceKeysetEntity.
@Test
public void testFindSliceKeysetEntity() {
Slice<Person> actual = personRepository.findByIdIsNotNull(new KeysetPageRequest(null, new PageRequest(0, 1, Sort.Direction.ASC, "id")));
assertEquals(1, actual.getSize());
assertEquals("Mother", actual.getContent().get(0).getName());
actual = personRepository.findByIdIsNotNull(actual.nextPageable());
assertEquals(1, actual.getSize());
assertEquals("John Doe", actual.getContent().get(0).getName());
}
use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.
the class RestrictedPersonViewRepositoryTest method testInvalid.
@Test
public void testInvalid() {
List result = invalidRestrictedPersonViewRepository.findAll();
assertTrue(result.get(0) instanceof Person);
}
Aggregations