private RepositoryModel.Facet findFacet(RepositoryModel repository, Class<? extends Facet> type) {
    check(repository.facets()).notEmpty();
    TypeElement toFind = rule.elements().getTypeElement(type.getCanonicalName());
    for (RepositoryModel.Facet facet: repository.facets()) {
      if (rule.types().asElement(facet.interfaceType()).equals(toFind)) {
        return facet;
      }
    }

    throw new IllegalArgumentException("Facet not found: " + type.getName());
  }
Find expected facet in repository model
criteria/common/test/org/immutables/criteria/processor/RepositoryTest.java