@Test
  protected void optional() {
    LocalDate date = LocalDate.now();
    repository.insert(generator.get().withId("id1").withOptional(Optional.empty()));
    repository.insert(generator.get().withId("id2").withOptional(Optional.of(date)));
    ids(holder.optional.isPresent()).hasContentInAnyOrder("id2");
    ids(holder.optional.isAbsent()).hasContentInAnyOrder("id1");
    ids(holder.optional.is(date)).hasContentInAnyOrder("id2");
    ids(holder.optional.atLeast(date)).hasContentInAnyOrder("id2");
    ids(holder.optional.atMost(date)).hasContentInAnyOrder("id2");
    ids(holder.optional.greaterThan(date)).isEmpty();
    ids(holder.optional.lessThan(date)).isEmpty();

    // using OptionalValue matcher API
    ids(holder.optional.is(Optional.empty())).isOf("id1");
    ids(holder.optional.is(Optional.of(date))).isOf("id2");
    ids(holder.optional.isNot(Optional.empty())).isOf("id2");
  }
Testing predicates, projections, sorting etc. on booleans
criteria/common/test/org/immutables/criteria/typemodel/LocalDateTemplate.java