Search in sources :

Example 1 with Person

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]);
        }
    });
}
Also used : Person(com.blazebit.persistence.deltaspike.data.testsuite.entity.Person) CdiContainer(org.apache.deltaspike.cdise.api.CdiContainer)

Example 2 with Person

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());
}
Also used : PersonView(com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView) Person(com.blazebit.persistence.deltaspike.data.testsuite.entity.Person) Test(org.junit.Test)

Example 3 with Person

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));
}
Also used : PersonView(com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView) Person(com.blazebit.persistence.deltaspike.data.testsuite.entity.Person) Test(org.junit.Test)

Example 4 with Person

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());
}
Also used : KeysetPageRequest(com.blazebit.persistence.deltaspike.data.KeysetPageRequest) PageRequest(com.blazebit.persistence.deltaspike.data.PageRequest) KeysetPageRequest(com.blazebit.persistence.deltaspike.data.KeysetPageRequest) Person(com.blazebit.persistence.deltaspike.data.testsuite.entity.Person) Test(org.junit.Test)

Example 5 with Person

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);
}
Also used : List(java.util.List) Person(com.blazebit.persistence.deltaspike.data.testsuite.entity.Person) Test(org.junit.Test)

Aggregations

Person (com.blazebit.persistence.deltaspike.data.testsuite.entity.Person)13 Test (org.junit.Test)11 PersonView (com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView)5 KeysetPageRequest (com.blazebit.persistence.deltaspike.data.KeysetPageRequest)4 PageRequest (com.blazebit.persistence.deltaspike.data.PageRequest)4 KeysetPageable (com.blazebit.persistence.deltaspike.data.KeysetPageable)1 List (java.util.List)1 CdiContainer (org.apache.deltaspike.cdise.api.CdiContainer)1