Search in sources :

Example 11 with PersonView

use of com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView in project blaze-persistence by Blazebit.

the class FullEntityViewRepositoryTest method testFindSlice.

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

Example 12 with PersonView

use of com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView 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 PersonView

use of com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView in project blaze-persistence by Blazebit.

the class FullEntityViewRepositoryTest method testFindAllWithKeysetExtraction.

@Test
public void testFindAllWithKeysetExtraction() {
    Pageable pageable = new KeysetPageRequest(null, new Sort("id"), 0, 5, true, true);
    Page<PersonView> page = personViewRepository.findAll(pageable);
    KeysetAwarePage<PersonView> keysetAwarePage = (KeysetAwarePage<PersonView>) page;
    assertEquals(5, keysetAwarePage.getKeysetPage().getKeysets().size());
}
Also used : KeysetAwarePage(com.blazebit.persistence.deltaspike.data.KeysetAwarePage) Pageable(com.blazebit.persistence.deltaspike.data.Pageable) KeysetPageable(com.blazebit.persistence.deltaspike.data.KeysetPageable) KeysetPageRequest(com.blazebit.persistence.deltaspike.data.KeysetPageRequest) Sort(com.blazebit.persistence.deltaspike.data.Sort) PersonView(com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView) Test(org.junit.Test)

Aggregations

PersonView (com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView)13 Test (org.junit.Test)13 KeysetPageRequest (com.blazebit.persistence.deltaspike.data.KeysetPageRequest)5 Person (com.blazebit.persistence.deltaspike.data.testsuite.entity.Person)5 PageRequest (com.blazebit.persistence.deltaspike.data.PageRequest)4 KeysetPageable (com.blazebit.persistence.deltaspike.data.KeysetPageable)2 Category (org.junit.experimental.categories.Category)2 KeysetAwarePage (com.blazebit.persistence.deltaspike.data.KeysetAwarePage)1 Pageable (com.blazebit.persistence.deltaspike.data.Pageable)1 Sort (com.blazebit.persistence.deltaspike.data.Sort)1