@Test
  void projection() {
    LocalDate reference = LocalDate.of(2010, 1, 1);
    Date now1 = Date.from(reference.atStartOfDay(ZoneId.systemDefault()).toInstant());
    Date now2 = Date.from(reference.plusDays(2).atStartOfDay(ZoneId.systemDefault()).toInstant());

    repository.insert(generator.get().withId("id1").withValue(now1).withNullable(null)
            .withOptional(Optional.empty()));
    repository.insert(generator.get().withId("id2").withValue(now2).withNullable(now2).withOptional(now2));

    // projection of one attribute
    check(repository.findAll().select(criteria.value).fetch()).hasContentInAnyOrder(now1, now2);
    check(repository.findAll().select(criteria.nullable).asOptional().fetch()).hasContentInAnyOrder(Optional.empty(), Optional.of(now2));
    check(repository.findAll().select(criteria.optional).fetch()).hasContentInAnyOrder(Optional.empty(), Optional.of(now2));

    final Function<Date, String> toStringFn = date ->  date == null ? "null" : date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().toString();
    // 4 attributes using mapper
    check(repository.findAll().select(criteria.id, criteria.value, criteria.nullable, criteria.optional)
            .map((id, value, nullable, optional) -> String.format("id=%s value=%s nullable=%s optional=%s", id, toStringFn.apply(value), toStringFn.apply(nullable), toStringFn.apply(optional.orElse(null)))).fetch())
            .hasContentInAnyOrder("id=id1 value=2010-01-01 nullable=null optional=null", "id=id2 value=2010-01-03 nullable=2010-01-03 optional=2010-01-03");

  }
Testing predicates, projections, sorting etc. on booleans
criteria/common/test/org/immutables/criteria/typemodel/DateTemplate.java