### Question:
UserValidator extends AbstractPaginationValidator { public static BindingResult createDeleteAdminError() { Map<String, String> map = new HashMap<>(); map.put("username", "admin"); BindingResult bindingResult = new MapBindingResult(map, "username"); bindingResult.reject(UserValidator.ERRCODE_DELETE_ADMIN, new String[]{}, "user.admin.cant.delete"); 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 createErrorDeleteAdminContainsErrorMessage() { BindingResult bindingAdminDeleteError = UserValidator.createDeleteAdminError(); assertEquals(1, bindingAdminDeleteError.getErrorCount()); List<ObjectError> errors = bindingAdminDeleteError.getAllErrors(); ObjectError adminError = errors.get(0); assertEquals(UserValidator.ERRCODE_DELETE_ADMIN, adminError.getCode()); assertEquals("user.admin.cant.delete", adminError.getDefaultMessage()); }