### Question:
Constraints { @SuppressWarnings("unchecked") public Constraints with(String name, Object... values) { SchemaUtil.checkTypeConsistency(schema, strategy, name, values); if (values.length > 0) { checkContained(name, values); In added = Predicates.in(values); if (values.length == 1) { return new Constraints(this, name, added, values[0]); } else { return new Constraints(this, name, added); } } else { if (!constraints.containsKey(name)) { return new Constraints(this, name, Predicates.exists()); } else { return this; } } } Constraints(Schema schema);  Constraints(Schema schema, PartitionStrategy strategy); private  Constraints(Schema schema, PartitionStrategy strategy,
                      Map<String, Predicate> constraints,
                      Map<String, Object> provided); private  Constraints(Constraints copy, String name, Predicate predicate); private  Constraints(Constraints copy,
                      String name, Predicate predicate, Object value); Predicate<E> toEntityPredicate(EntityAccessor<E> accessor); Predicate<E> toEntityPredicate(StorageKey key, EntityAccessor<E> accessor); Iterator<E> filter(Iterator<E> iterator, EntityAccessor<E> accessor); KeyPredicate toKeyPredicate(); Iterable<MarkerRange> toKeyRanges(); @SuppressWarnings("unchecked") boolean alignedWithBoundaries(); Map<String, Object> getProvidedValues(); @SuppressWarnings("unchecked") Constraints with(String name, Object... values); Constraints from(String name, Comparable value); Constraints fromAfter(String name, Comparable value); Constraints to(String name, Comparable value); Constraints toBefore(String name, Comparable value); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Map<String, String> toQueryMap(); Map<String, String> toNormalizedQueryMap(); static Constraints fromQueryMap(Schema schema,
                                         PartitionStrategy strategy,
                                         Map<String, String> query); boolean isUnbounded();  }### Answer:
@Test(expected=NullPointerException.class) public void testWithNull() { emptyConstraints.with("id", (Object) null); }
@Test public void testRejectsNonSchemaOrPartitionFields() { TestHelpers.assertThrows("Should reject unknown field name", ValidationException.class, new Runnable() { @Override public void run() { emptyConstraints.with("prescription", 34); } }); }
@Test public void testRejectsFieldSchemaMismatch() { TestHelpers.assertThrows("Should reject incorrect schema, string for long", IllegalArgumentException.class, new Runnable() { @Override public void run() { emptyConstraints.with("timestamp", "boat"); } }); TestHelpers.assertThrows("Should reject incorrect schema, int for string", IllegalArgumentException.class, new Runnable() { @Override public void run() { emptyConstraints.with("color", 34); } }); }
@Test public void testRejectsPartitionFieldSchemaMismatch() { TestHelpers.assertThrows("Should reject incorrect schema, string for int", IllegalArgumentException.class, new Runnable() { @Override public void run() { emptyConstraints.with("year", "joker"); } }); TestHelpers.assertThrows("Should reject incorrect schema, int for string", IllegalArgumentException.class, new Runnable() { @Override public void run() { emptyConstraints.with("id", 34); } }); }