use of org.immutables.criteria.personmodel.ImmutablePerson in project immutables by immutables.
the class ExpressionInterpreterTest method reflection.
@Test
public void reflection() {
final PersonCriteria crit = PersonCriteria.person;
final ImmutablePerson person = example.withFullName("John");
check(!evaluate(crit.age.is(11), person));
check(evaluate(crit.age.isNot(11), person));
check(evaluate(crit.age.is(11), person.withAge(11)));
check(evaluate(crit.age.is(22).fullName.is("John"), person));
check(!evaluate(crit.age.is(22).fullName.is("Mary"), person));
check(!evaluate(crit.age.in(1, 2, 3), person));
check(evaluate(crit.age.notIn(1, 2, 3), person));
check(evaluate(crit.age.in(22, 23, 24), person));
check(!evaluate(crit.age.notIn(22, 23, 24), person));
check(!evaluate(crit.isActive.isTrue(), person));
check(evaluate(crit.isActive.isFalse(), person));
check(evaluate(crit.isActive.isTrue().or().isActive.isFalse(), person));
check(evaluate(crit.isActive.isFalse().or().isActive.isTrue().nickName.isAbsent(), person));
check(!evaluate(crit.age.atLeast(23), person));
check(evaluate(crit.age.atMost(22), person));
check(!evaluate(crit.age.lessThan(22), person));
check(!evaluate(crit.age.greaterThan(22), person));
check(!evaluate(crit.age.atLeast(23), person));
// optionals
check(evaluate(crit.nickName.isPresent(), person));
check(!evaluate(crit.nickName.isAbsent(), person));
check(!evaluate(crit.nickName.isPresent(), person.withNickName(Optional.empty())));
check(evaluate(crit.nickName.isAbsent(), person.withNickName(Optional.empty())));
// == value().$expr
check(!evaluate(crit.nickName.isNot("Smith"), person.withNickName("Smith")));
check(evaluate(crit.nickName.in("Smith", "Nobody"), person.withNickName("Smith")));
check(!evaluate(crit.nickName.in("Nobody", "Sky"), person.withNickName("Smith")));
check(evaluate(crit.nickName.notIn("Nobody", "Sky"), person.withNickName("Smith")));
// == value($expr)
check(evaluate(crit.nickName.with(v -> v.is("Smith")), person.withNickName("Smith")));
check(!evaluate(crit.nickName.with(v -> v.isNot("Smith")), person.withNickName("Smith")));
check(evaluate(crit.nickName.with(v -> v.in("Smith", "Nobody")), person.withNickName("Smith")));
check(!evaluate(crit.nickName.with(v -> v.in("Nobody", "Sky")), person.withNickName("Smith")));
check(evaluate(crit.nickName.with(v -> v.notIn("Nobody", "Sky")), person.withNickName("Smith")));
}
Aggregations