Search in sources :

Example 6 with Person

use of org.apache.ignite.springdata.misc.Person in project ignite by apache.

the class IgniteSpringDataQueriesSelfTest method testSliceOfCacheEntries.

/** */
public void testSliceOfCacheEntries() {
    Slice<Cache.Entry<Integer, Person>> slice = repo2.findBySecondNameIsNot("lastName18", new PageRequest(3, 4));
    assertEquals(4, slice.getSize());
    for (Cache.Entry<Integer, Person> entry : slice) assertFalse("lastName18".equals(entry.getValue().getSecondName()));
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Person(org.apache.ignite.springdata.misc.Person) Cache(javax.cache.Cache)

Example 7 with Person

use of org.apache.ignite.springdata.misc.Person in project ignite by apache.

the class IgniteSpringDataQueriesSelfTest method testTopPart.

/** */
public void testTopPart() {
    Iterable<Person> top = repo.findTopByFirstNameContaining("person4");
    Iterator<Person> iter = top.iterator();
    Person person = iter.next();
    assertFalse(iter.hasNext());
    assertTrue(person.getFirstName().startsWith("person4"));
}
Also used : Person(org.apache.ignite.springdata.misc.Person)

Example 8 with Person

use of org.apache.ignite.springdata.misc.Person in project ignite by apache.

the class IgniteSpringDataQueriesSelfTest method beforeTestsStarted.

@Override
protected void beforeTestsStarted() throws Exception {
    super.beforeTestsStarted();
    ctx = new AnnotationConfigApplicationContext();
    ctx.register(ApplicationConfiguration.class);
    ctx.refresh();
    repo = ctx.getBean(PersonRepository.class);
    repo2 = ctx.getBean(PersonSecondRepository.class);
    for (int i = 0; i < CACHE_SIZE; i++) repo.save(i, new Person("person" + Integer.toHexString(i), "lastName" + Integer.toHexString((i + 16) % 256)));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PersonSecondRepository(org.apache.ignite.springdata.misc.PersonSecondRepository) PersonRepository(org.apache.ignite.springdata.misc.PersonRepository) Person(org.apache.ignite.springdata.misc.Person)

Example 9 with Person

use of org.apache.ignite.springdata.misc.Person in project ignite by apache.

the class IgniteSpringDataQueriesSelfTest method testQueryWithSort.

/** */
public void testQueryWithSort() {
    List<Person> persons = repo.queryWithSort("^[a-z]+$", new Sort(Sort.Direction.DESC, "secondName"));
    Person previous = persons.get(0);
    for (Person person : persons) {
        assertTrue(person.getSecondName().compareTo(previous.getSecondName()) <= 0);
        assertTrue(person.getFirstName().matches("^[a-z]+$"));
        previous = person;
    }
}
Also used : Sort(org.springframework.data.domain.Sort) Person(org.apache.ignite.springdata.misc.Person)

Example 10 with Person

use of org.apache.ignite.springdata.misc.Person in project ignite by apache.

the class IgniteSpringDataQueriesSelfTest method testFindOneValue.

/** */
public void testFindOneValue() {
    Person person = repo.findTopBySecondNameStartingWith("lastName18");
    assertNotNull(person);
    assertTrue(person.getSecondName().startsWith("lastName18"));
}
Also used : Person(org.apache.ignite.springdata.misc.Person)

Aggregations

Person (org.apache.ignite.springdata.misc.Person)13 PageRequest (org.springframework.data.domain.PageRequest)3 HashSet (java.util.HashSet)1 Cache (javax.cache.Cache)1 PersonRepository (org.apache.ignite.springdata.misc.PersonRepository)1 PersonSecondRepository (org.apache.ignite.springdata.misc.PersonSecondRepository)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 Sort (org.springframework.data.domain.Sort)1