### Question:
NotNullValidator implements ValidationPolicy { @Override public boolean validate(Object value) { if (value == null) { return false; } if (!allowEmptyString && value instanceof String) { String svalue = (trimString ? StringUtils.trim((String) value) : (String) value); return (!StringUtils.isEmpty(svalue)); } return true; } NotNullValidator(@PolicyPropertyRef(name = "EMPTY_STRING") boolean allowEmptyString,
                            @PolicyPropertyRef(name = "TRIM_STRING") boolean trimString); @Override boolean validate(Object value); boolean isAllowEmptyString(); boolean isTrimString();  }### Answer:
@Test public void testValidate() throws Exception { NotNullValidator validator = new NotNullValidator(false, true); assertTrue(validator.validate("foo")); assertFalse(validator.validate("")); assertFalse(validator.validate(" ")); assertFalse(validator.validate(null)); validator = new NotNullValidator(true, true); assertTrue(validator.validate("foo")); assertTrue(validator.validate("")); assertTrue(validator.validate(" ")); assertFalse(validator.validate(null)); validator = new NotNullValidator(true, false); assertTrue(validator.validate("foo")); assertTrue(validator.validate("")); assertTrue(validator.validate(" ")); assertFalse(validator.validate(null)); }