Search in sources :

Example 1 with Person

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

the class IgniteSpringDataCrudSelfTest method testDelete.

/**
     *
     */
public void testDelete() {
    assertEquals(CACHE_SIZE, repo.count());
    repo.delete(0);
    assertEquals(CACHE_SIZE - 1, repo.count());
    assertNull(repo.findOne(0));
    try {
        repo.delete(new Person("", ""));
        fail("Managed to delete a Person without id");
    } catch (UnsupportedOperationException e) {
    //expected
    }
}
Also used : Person(org.apache.ignite.springdata.misc.Person)

Example 2 with Person

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

the class IgniteSpringDataQueriesSelfTest method testQueryWithPaging.

/** */
public void testQueryWithPaging() {
    List<Person> persons = repo.queryWithPageable("^[a-z]+$", new PageRequest(1, 7, Sort.Direction.DESC, "secondName"));
    assertEquals(7, persons.size());
    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 : PageRequest(org.springframework.data.domain.PageRequest) Person(org.apache.ignite.springdata.misc.Person)

Example 3 with Person

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

the class IgniteSpringDataQueriesSelfTest method testEqualsPart.

/** */
public void testEqualsPart() {
    List<Person> persons = repo.findByFirstName("person4e");
    assertFalse(persons.isEmpty());
    for (Person person : persons) assertEquals("person4e", person.getFirstName());
}
Also used : Person(org.apache.ignite.springdata.misc.Person)

Example 4 with Person

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

the class IgniteSpringDataQueriesSelfTest method testPageable.

/** */
public void testPageable() {
    PageRequest pageable = new PageRequest(1, 5, Sort.Direction.DESC, "firstName");
    HashSet<String> firstNames = new HashSet<>();
    List<Person> pageable1 = repo.findByFirstNameRegex("^[a-z]+$", pageable);
    assertEquals(5, pageable1.size());
    for (Person person : pageable1) {
        firstNames.add(person.getFirstName());
        assertTrue(person.getFirstName().matches("^[a-z]+$"));
    }
    List<Person> pageable2 = repo.findByFirstNameRegex("^[a-z]+$", pageable.next());
    assertEquals(5, pageable2.size());
    for (Person person : pageable2) {
        firstNames.add(person.getFirstName());
        assertTrue(person.getFirstName().matches("^[a-z]+$"));
    }
    assertEquals(10, firstNames.size());
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Person(org.apache.ignite.springdata.misc.Person) HashSet(java.util.HashSet)

Example 5 with Person

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

the class IgniteSpringDataCrudSelfTest method testPutGet.

/**
     *
     */
public void testPutGet() {
    Person person = new Person("some_name", "some_surname");
    int id = CACHE_SIZE + 1;
    assertEquals(person, repo.save(id, person));
    assertTrue(repo.exists(id));
    assertEquals(person, repo.findOne(id));
    try {
        repo.save(person);
        fail("Managed to save a Person without ID");
    } catch (UnsupportedOperationException e) {
    //excepted
    }
}
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