### Question:
PatientIdentifierValidator implements Validator { public static void checkIdentifierAgainstFormat(String identifier, String format, String formatDescription) throws PatientIdentifierException { log.debug("Checking identifier: " + identifier + " against format: " + format); if (StringUtils.isBlank(identifier)) { throw new BlankIdentifierException("PatientIdentifier.error.nullOrBlank"); } if (StringUtils.isBlank(format)) { log.debug("Format is blank, identifier passes."); return; } if (!identifier.matches(format)) { log.debug("The two DO NOT match"); throw new InvalidIdentifierFormatException(getMessage("PatientIdentifier.error.invalidFormat", identifier, StringUtils.isNotBlank(formatDescription) ? formatDescription : format)); } log.debug("The two match!!"); }  @Override boolean supports(Class<?> c); @Override void validate(Object obj, Errors errors); static void validateIdentifier(PatientIdentifier pi); static void validateIdentifier(String identifier, PatientIdentifierType pit); static void checkIdentifierAgainstFormat(String identifier, String format, String formatDescription); static void checkIdentifierAgainstValidator(String identifier, IdentifierValidator validator);  }### Answer:
@Test(expected = InvalidIdentifierFormatException.class) public void checkIdentifierAgainstFormat_shouldFailValidationIfIdentifierDoesNotMatchTheFormat() { PatientIdentifierValidator.checkIdentifierAgainstFormat("111-222-333", "[0-9]{3}\\-[0-9]{2}\\-[0-9]{4}", null); }
@Test public void checkIdentifierAgainstFormat_shouldPassValidationIfIdentifierMatchesTheFormat() { PatientIdentifierValidator.checkIdentifierAgainstFormat("111-22-3333", "[0-9]{3}\\-[0-9]{2}\\-[0-9]{4}", null); }
@Test public void checkIdentifierAgainstFormat_shouldPassValidationIfTheFormatIsBlank() { PatientIdentifierValidator.checkIdentifierAgainstFormat("abcdefg", "", null); }