### Question:
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } AtLeastOneFieldPresenceConstraint(String... fieldNames); @Override boolean evaluate(Schema schema, JsonNode node); @Override String describe();  }### Answer:
@Test public void passesWhenOneRequiredFieldIsPresent() throws IOException { AtLeastOneFieldPresenceConstraint constraint = new AtLeastOneFieldPresenceConstraint("http", "https"); boolean result = constraint.evaluate( schema( field("x", integer()), field("http", integer()), field("https", integer()), atLeastOne("http", "https")), jsonNode( " http: 8080\n" )); assertThat(result, is(true)); }
@Test public void allowsSeveralFieldsToBePresent() throws IOException { AtLeastOneFieldPresenceConstraint constraint = new AtLeastOneFieldPresenceConstraint("http", "https"); boolean result = constraint.evaluate( schema( field("x", integer()), field("http", integer()), field("https", integer()), atLeastOne("http", "https")), jsonNode( " https: 8443\n" + " http: 8080\n" )); assertThat(result, is(true)); }
@Test public void throwsExceptionWhenNoneRequiredFieldsArePresent() throws IOException { AtLeastOneFieldPresenceConstraint constraint = new AtLeastOneFieldPresenceConstraint("http", "https"); boolean result = constraint.evaluate( schema( field("x", integer()), field("http", integer()), field("https", integer()), atLeastOne("http", "https")), jsonNode( " x: 43\n" )); assertThat(result, is(false)); }