Search in sources :

Example 1 with PersonView

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

the class ExtendedEntityViewRepositoryTest method testFindAnyByName.

@Test
public void testFindAnyByName() {
    String name = "John Smith";
    PersonView result1 = personViewRepository.findAnyByName(name);
    PersonView result2 = simplePersonViewRepository.findAnyByName(name);
    assertEquals(persons[4].getId(), result1.getId());
    assertEquals(result1, result2);
}
Also used : PersonView(com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView) Test(org.junit.Test)

Example 2 with PersonView

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

the class ExtendedEntityViewRepositoryTest method testFindFirstByNameLikeOrderByIdAsc.

@Test
public void testFindFirstByNameLikeOrderByIdAsc() {
    PersonView result1 = personViewRepository.findFirst1ByNameLikeOrderByIdAsc("John%");
    PersonView result2 = personViewRepository.findTop1ByNameLikeOrderByIdAsc("John%");
    assertEquals(persons[1].getId(), result1.getId());
    assertEquals(persons[1].getId(), result2.getId());
}
Also used : PersonView(com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView) Test(org.junit.Test)

Example 3 with PersonView

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

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

the class FullEntityViewRepositoryTest method testFindSliceKeyset.

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

Example 5 with PersonView

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

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