### Question:
NonNullValidator implements AtlasValidator { @Override public void validate(Object target, List<Validation> validations, String id) { validate(target, validations, id, ValidationStatus.ERROR); } NonNullValidator(ValidationScope scope, String violationMessage); @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() { String notNull = "notNull"; validator.validate(notNull, validations, null); assertFalse(validationHelper.hasErrors()); }
@Test public void testValidateInvalid() { validator.validate(null, validations, null); assertTrue(validationHelper.hasErrors()); assertEquals(new Integer(1), new Integer(validationHelper.getCount())); Validation validation = validationHelper.getAllValidations().get(0); assertNotNull(validation); assertTrue("Cannot be null".equals(validation.getMessage())); assertEquals(ValidationScope.MAPPING, validation.getScope()); assertNull(validation.getId()); String empty = ""; validationHelper.getAllValidations().clear(); validator.validate(empty, validations, "testValidateInvalid-2"); assertTrue(validationHelper.hasErrors()); assertEquals(new Integer(1), new Integer(validationHelper.getCount())); assertEquals(ValidationScope.MAPPING, validationHelper.getValidation().get(0).getScope()); assertEquals("testValidateInvalid-2", validationHelper.getValidation().get(0).getId()); }