QueryUtils { public static String buildPredicate(String... properties) { checkArgument(properties.length > 0, "At least one property is required"); StringBuilder builder = new StringBuilder(128); for (String property : properties) { if (builder.length() > 0) { builder.append(" AND "); } builder.append(property).append(" = ?"); } return builder.toString(); } private  QueryUtils(); static String buildPredicate(String... properties); static String buildIn(final Set<?> values);  }
@Test(expected = NullPointerException.class) public void testBuildPredicate_NullArray() { QueryUtils.buildPredicate((String[]) null); }
@Test(expected = IllegalArgumentException.class) public void testBuildPredicate_EmptyArray() { QueryUtils.buildPredicate(new String[0]); }
@Test public void testBuildPredicate_SingleProperty() { assertThat(QueryUtils.buildPredicate("foo"), is("foo = ?")); }
@Test public void testBuildPredicate_MultipleProperties() { assertThat(QueryUtils.buildPredicate("foo", "bar", "baz"), is("foo = ? AND bar = ? AND baz = ?")); }