### Question:
StringPatternValidator implements AtlasValidator { @Override public void validate(Object target, List<Validation> validations, String id) { validate(target, validations, id, ValidationStatus.ERROR); } StringPatternValidator(ValidationScope scope, String violationMessage, String pattern);  StringPatternValidator(ValidationScope scope, String violationMessage, String pattern, boolean useMatch); @Override boolean supports(Class<?> clazz); @Override void validate(Object target, List<Validation> validations, String id); @Override void validate(Object target, List<Validation> validations, String id, ValidationStatus status);  }### Answer:
@Test public void testValidate() { validator = new StringPatternValidator(ValidationScope.MAPPING, "Must match [^A-Za-z0-9_.]", "[^A-Za-z0-9_.]"); validator.validate("This. &* should result in an error", validations, "testValidate"); assertTrue(validationHelper.hasErrors()); validations.clear(); assertFalse(validationHelper.hasErrors()); validator.validate("This_isafineexample.whatever1223", validations, "testValidate-2"); assertFalse(validationHelper.hasErrors()); }
@Test public void testValidateUsingMatch() { validator = new StringPatternValidator(ValidationScope.LOOKUP_TABLE, "Must match [0-9]+", "[0-9]+", true); validator.validate("0333", validations, "testValidateUsingMatch"); assertFalse(validationHelper.hasErrors()); validator = new StringPatternValidator(ValidationScope.PROPERTY, "Must match [0-9]", "[0-9]", true); validator.validate("This_isafineexample.whatever", validations, "testValidateUsingMatch-2"); assertTrue(validationHelper.hasErrors()); }