Search in sources :

Example 11 with Person

use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.

the class FullEntityViewRepositoryTest method testFindSliceEntity.

@Test
public void testFindSliceEntity() {
    Slice<Person> actual = personRepository.findByIdIsNotNull(new PageRequest(0, 1, Sort.Direction.ASC, "id"));
    assertEquals(1, actual.getSize());
    assertEquals("Mother", actual.getContent().get(0).getName());
    actual = personRepository.findByIdIsNotNull(new PageRequest(1, 1, Sort.Direction.ASC, "id"));
    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) Person(com.blazebit.persistence.deltaspike.data.testsuite.entity.Person) Test(org.junit.Test)

Example 12 with Person

use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.

the class FullEntityViewRepositoryTest method testFindBy.

@Test
public void testFindBy() {
    List<PersonView> expected = Arrays.asList(fetch(PersonView.class, persons[2].getId()), fetch(PersonView.class, persons[4].getId()));
    Person example = new Person();
    example.setPosition(4);
    // we do not test DeltaSpike's findBy(E, SingularAttribute<E,?>...) method here because its results are non-deterministic
    assertEquals(expected, personViewRepository.findBy(example, Person_.position));
}
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 13 with Person

use of com.blazebit.persistence.deltaspike.data.testsuite.entity.Person in project blaze-persistence by Blazebit.

the class FullEntityViewRepositoryTest method testFindByNameKeysetPaginatedEntity.

@Test
public void testFindByNameKeysetPaginatedEntity() {
    // we do not test DeltaSpike's findAll(int, int) method here because its results are non-deterministic
    Page<Person> actual = personRepository.findByNameLike("John %", new KeysetPageRequest(null, new PageRequest(0, 1, Sort.Direction.ASC, "id")));
    assertTrue(actual instanceof KeysetAwarePage<?>);
    assertEquals(1, actual.getNumberOfElements());
    assertEquals("John Doe", actual.getContent().get(0).getName());
    actual = personRepository.findByNameLike("John %", (KeysetPageable) actual.nextPageable());
    assertEquals(1, actual.getNumberOfElements());
    assertEquals("John Smith", 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) KeysetPageable(com.blazebit.persistence.deltaspike.data.KeysetPageable) 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