### Question:
UserValidator extends AbstractPaginationValidator { public static BindingResult createSelfDeleteUserError(BindingResult bindingResult) { bindingResult.reject(UserValidator.ERRCODE_SELF_DELETE, new String[]{}, "user.self.delete.error"); return bindingResult; }  IUserManager getUserManager(); void setUserManager(IUserManager userManager); IGroupManager getGroupManager(); void setGroupManager(IGroupManager groupManager); IRoleManager getRoleManager(); void setRoleManager(IRoleManager roleManager); PasswordEncoder getPasswordEncoder(); void setPasswordEncoder(PasswordEncoder passwordEncoder); @Override boolean supports(Class<?> paramClass); @Override void validate(Object target, Errors errors); void validateUserPost(UserRequest request, BindingResult bindingResult); static boolean isAdminUser(String username); static boolean isUserDeletingHimself(String username, String currentUser); static BindingResult createDeleteAdminError(); static BindingResult createSelfDeleteUserError(BindingResult bindingResult); void validateGroupsAndRoles(UserAuthoritiesRequest request, Errors errors); void validateUpdateSelf(String username, String currentUser, BindingResult bindingResult); void validatePutBody(String username, UserRequest userRequest, BindingResult bindingResult); void validateChangePasswords(String username, UserPasswordRequest passwordRequest, BindingResult bindingResult); static final String ERRCODE_USER_ALREADY_EXISTS; static final String ERRCODE_USER_NOT_FOUND; static final String ERRCODE_USERNAME_FORMAT_INVALID; static final String ERRCODE_PASSWORD_FORMAT_INVALID; static final String ERRCODE_USERNAME_MISMATCH; static final String ERRCODE_OLD_PASSWORD_FORMAT; static final String ERRCODE_NEW_PASSWORD_EQUALS; static final String ERRCODE_AUTHORITIES_INVALID_REQ; static final String ERRCODE_SELF_UPDATE; static final String ERRCODE_DELETE_ADMIN; static final String ERRCODE_SELF_DELETE; }### Answer:
@Test public void createErrorSelfDeleteContainsErrorMessage() { MapBindingResult bindingResult = new MapBindingResult(new HashMap<Object, Object>(), "username"); BindingResult bindingSelfDeleteError = UserValidator.createSelfDeleteUserError(bindingResult); assertEquals(1, bindingSelfDeleteError.getErrorCount()); List<ObjectError> errors = bindingSelfDeleteError.getAllErrors(); ObjectError error = errors.get(0); assertEquals(UserValidator.ERRCODE_SELF_DELETE, error.getCode()); assertEquals("user.self.delete.error", error.getDefaultMessage()); }