### Question:
ConstraintValidator { public void validateDocs(List<? extends JsonDoc> docList) { currentDocList = docList; currentDoc = null; LOGGER.debug("validateDocs() enter with {} docs", docList.size()); Error.push("validateDocs"); try { for (JsonDoc doc : docList) { validateDoc(doc); } } catch (Error e) { throw e; } catch (Exception e) { LOGGER.error(e.getMessage(), e); throw Error.get(CrudConstants.ERR_CRUD, e.getMessage()); } finally { Error.pop(); } LOGGER.debug("validateDocs() complete"); } protected  ConstraintValidator(Registry<String, FieldConstraintChecker> r,
                                  Registry<String, EntityConstraintChecker> e,
                                  EntityMetadata md); void clearErrors(); List<? extends JsonDoc> getCurrentDocList(); JsonDoc getCurrentDoc(); FieldTreeNode getCurrentFieldMetadata(); Path getCurrentFieldPath(); FieldConstraint getCurrentFieldConstraint(); EntityConstraint getCurrentEntityConstraint(); Map<JsonDoc, List<Error>> getDocErrors(); void addDocError(Error err); void addDocErrors(List<Error> list); void addError(Error err); List<Error> getErrors(); boolean hasErrors(); void validateDocs(List<? extends JsonDoc> docList); void validateDoc(JsonDoc doc); EntityMetadata getEntityMetadata();  }### Answer:
@Test public void testValidate_WithInvalidEntityConstraint_ExpectError() throws IOException { expectedEx.expect(com.redhat.lightblue.util.Error.class); expectedEx.expectMessage("{\"objectType\":\"error\",\"context\":\"validateDocs/validateDoc/Does Not Exist\",\"errorCode\":\"crud:NoConstraint\"}"); JsonNode validatorNode = loadJsonNode("crud/validator/schema-test-validation-simple.json"); EntityMetadata entityMetadata = createEntityMetadata(validatorNode, Arrays.asList(new TestEntityConstraint("Does Not Exist")), null); ConstraintValidator validator = createConstraintValidator(entityMetadata); validator.validateDocs(Arrays.asList(new JsonDoc(validatorNode))); }
@Test public void testValidate_WithNullFieldConstraint_ExpectError() throws IOException { expectedEx.expect(com.redhat.lightblue.util.Error.class); expectedEx.expectMessage("{\"objectType\":\"error\",\"context\":\"validateDocs/validateDoc/field1/testFieldConstraintChecker\",\"errorCode\":\"crud:NoConstraint\""); JsonNode validatorNode = loadJsonNode("crud/validator/schema-test-validation-testFieldConstraint.json"); Map<String, FieldConstraintParser<JsonNode>> fieldConstraintParsers = new HashMap<>(); fieldConstraintParsers.put("testFieldConstraint", new TestFieldConstraintParser(new TestFieldConstraint("testFieldConstraintChecker"))); EntityMetadata entityMetadata = createEntityMetadata(validatorNode, null, fieldConstraintParsers); ConstraintValidator validator = createConstraintValidator(entityMetadata, null, null); validator.validateDocs(Arrays.asList(new JsonDoc(validatorNode))); }