use of org.immutables.criteria.personmodel.PersonGenerator in project immutables by immutables.
the class GeodePersonTest method deleteByQuery.
@Test
void deleteByQuery() {
PersonGenerator generator = new PersonGenerator();
repository().insert(generator.next().withId("id1").withFullName("A").withAge(10));
repository().insert(generator.next().withId("id2").withFullName("B").withAge(20));
repository().insert(generator.next().withId("id3").withFullName("C").withAge(30));
repository().delete(person.age.atMost(9).fullName.is("A"));
check(repository().findAll()).toList(Person::id).hasContentInAnyOrder("id1", "id2", "id3");
// delete id1
repository().delete(person.age.atMost(10).fullName.is("A"));
check(repository().findAll()).toList(Person::id).hasContentInAnyOrder("id2", "id3");
// delete id2
repository().delete(person.age.between(19, 21));
check(repository().findAll()).toList(Person::id).hasContentInAnyOrder("id3");
// delete id3
repository().delete(person.fullName.is("C"));
check(repository().findAll()).toList(Person::id).isEmpty();
}
use of org.immutables.criteria.personmodel.PersonGenerator in project immutables by immutables.
the class ElasticPersonTest method regex_forElastic.
/**
* Elastic has special <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/regexp-syntax.html">regex syntax</a>
* and not all java patterns are supported. Testing separately here
*/
@Test
public void regex_forElastic() {
final PersonGenerator generator = new PersonGenerator();
insert(generator.next().withFullName("John"));
check(repository().find(person.fullName.matches(Pattern.compile("John")))).hasSize(1);
check(repository().find(person.fullName.matches(Pattern.compile("J.*n")))).hasSize(1);
check(repository().find(person.fullName.not(s -> s.matches(Pattern.compile("J.*n"))))).empty();
check(repository().find(person.fullName.matches(Pattern.compile("J..n")))).hasSize(1);
check(repository().find(person.fullName.matches(Pattern.compile("J...")))).hasSize(1);
check(repository().find(person.fullName.matches(Pattern.compile("...n")))).hasSize(1);
check(repository().find(person.fullName.matches(Pattern.compile(".*")))).hasSize(1);
insert(generator.next().withFullName("Mary"));
check(repository().find(person.fullName.matches(Pattern.compile("J.*n")))).hasSize(1);
check(repository().find(person.fullName.matches(Pattern.compile("M.*ry")))).hasSize(1);
check(repository().find(person.fullName.matches(Pattern.compile(".*")))).hasSize(2);
}
Aggregations