use of org.immutables.criteria.personmodel.PersonCriteria in project immutables by immutables.
the class ExpressionAsStringTest method and.
@Test
void and() {
PersonCriteria other = PersonCriteria.person.and(person.age.atMost(1)).and(person.age.atLeast(2));
assertExpressional(other, "call op=AND", " call op=LESS_THAN_OR_EQUAL path=age constant=1", " call op=GREATER_THAN_OR_EQUAL path=age constant=2");
assertExpressional(other.and(person.age.is(3)), "call op=AND", " call op=LESS_THAN_OR_EQUAL path=age constant=1", " call op=GREATER_THAN_OR_EQUAL path=age constant=2", " call op=EQUAL path=age constant=3");
assertExpressional(other.and(person.age.is(3)), "call op=AND", " call op=LESS_THAN_OR_EQUAL path=age constant=1", " call op=GREATER_THAN_OR_EQUAL path=age constant=2", " call op=EQUAL path=age constant=3");
}
use of org.immutables.criteria.personmodel.PersonCriteria in project immutables by immutables.
the class ChangeStreamsTest method filter.
/**
* Watch event with filter
*/
@Test
void filter() throws InterruptedException {
PersonCriteria filter = person.age.atLeast(21);
Flowable<WatchEvent<Person>> flowable = Flowable.fromPublisher(repository.watcher(filter).watch());
TestSubscriber<WatchEvent<Person>> test = flowable.test();
repository.insert(generator.next().withId("id1").withAge(18));
test.await(200, TimeUnit.MILLISECONDS);
test.assertEmpty();
repository.insert(generator.next().withId("id2").withAge(19));
test.await(200, TimeUnit.MILLISECONDS);
test.assertEmpty();
repository.insert(generator.next().withId("id3").withAge(21));
test.awaitCount(1).assertValueCount(1);
Person person = test.values().get(0).newValue().get();
check(person.id()).is("id3");
check(person.age()).is(21);
}
use of org.immutables.criteria.personmodel.PersonCriteria in project immutables by immutables.
the class ExpressionInterpreterTest method booleans.
@Test
public void booleans() {
final PersonCriteria crit = PersonCriteria.person;
final ImmutablePerson person = example.withFullName("A");
check(evaluate(crit.nickName.isAbsent().or().nickName.isPresent(), person));
check(!evaluate(crit.nickName.isAbsent().nickName.isPresent(), person));
check(!evaluate(crit.fullName.is("A").fullName.is("B"), person));
check(evaluate(crit.fullName.is("B").or().fullName.is("A"), person));
check(!evaluate(crit.fullName.is("B").or().fullName.is("C"), person));
check(!evaluate(crit.fullName.is("A").fullName.is("C"), person));
}
use of org.immutables.criteria.personmodel.PersonCriteria in project immutables by immutables.
the class AggregationExpressionTest method aggregation.
@Test
public void aggregation() {
PersonCriteria person = PersonCriteria.person;
assertProjection(person.age.count(), "call op=COUNT path=age");
assertProjection(person.age.sum(), "call op=SUM path=age");
assertProjection(person.age.avg(), "call op=AVG path=age");
assertProjection(person.age.min(), "call op=MIN path=age");
assertProjection(person.age.max(), "call op=MAX path=age");
assertProjection(person.bestFriend.value().hobby.max(), "call op=MAX path=bestFriend.hobby");
assertProjection(person.bestFriend.value().hobby.count(), "call op=COUNT path=bestFriend.hobby");
assertProjection(person.nickName.max(), "call op=MAX path=nickName");
}
use of org.immutables.criteria.personmodel.PersonCriteria in project immutables by immutables.
the class UpdatableTest method name.
@Test
@Disabled("compile-time only")
void name() {
PersonCriteria person = PersonCriteria.person;
Updater<Person, Single<WriteResult>> updater = null;
updater.set(person.nickName, Optional.of("aaa")).set(person, // instead of replace ?
ImmutablePerson.builder().build()).set(person.fullName, "John").set(person.isActive, true).execute();
updater.replace(ImmutablePerson.builder().build()).execute();
}
Aggregations