public static void validate(FilterPredicate predicate, MessageType schema) {
    Objects.requireNonNull(predicate, "predicate cannot be null");
    Objects.requireNonNull(schema, "schema cannot be null");
    predicate.accept(new SchemaCompatibilityValidator(schema));
  }
@Test
  public void testFindsInvalidTypes() {
    try {
      validate(complexWrongType, schema);
      fail("this should throw");
    } catch (IllegalArgumentException e) {
      assertEquals(
          "FilterPredicate column: x.bar's declared type (java.lang.Long) does not match the schema found in file metadata. "
              + "Column x.bar is of type: INT32\n"
              + "Valid types for this column are: [class java.lang.Integer]",
          e.getMessage());
    }
  }