ModifyUserController { @PostMapping("modifyuser") @SuppressWarnings("AssignmentToMethodParameter") public String update(Model model, @RequestParam("oldPassword") String oldPassword, @RequestParam("newPassword") String newPassword, @RequestParam("rptPassword") String rptPassword, @RequestParam("email") String email, @RequestParam("nick") String nick, @RequestParam("school") String school, Authentication authentication) { if (!Objects.equals(newPassword, rptPassword)) { throw new BusinessException(BusinessCode.REPEAT_PASSWORD_MISMATCH); } String userId = authentication.getName(); User user = accountService.findOne(userId); String password = user.getPassword(); if (!passwordEncoder.matches(oldPassword, password)) { throw new BusinessException(BusinessCode.INCORRECT_PASSWORD); } if (StringUtils.isEmpty(nick)) { nick = userId; } if (StringUtils.isEmpty(newPassword)) { newPassword = oldPassword; } else { ValueCheck.checkPassword(newPassword); } if (StringUtils.hasText(email)) { ValueCheck.checkEmail(email); } else { email = ""; } ValueCheck.checkNick(nick); user = User.builder() .id(userId) .email(email) .nick(nick) .password(newPassword) .school(school) .build(); accountService.updateSelective(userId, user); model.addAttribute("user", user); return "users/modifySuccess"; }  @GetMapping({"modifyuserpage", "modifyuser"}) String updatePage(Model model, Authentication authentication); @PostMapping("modifyuser") @SuppressWarnings("AssignmentToMethodParameter") String update(Model model,
            @RequestParam("oldPassword") String oldPassword,
            @RequestParam("newPassword") String newPassword,
            @RequestParam("rptPassword") String rptPassword,
            @RequestParam("email") String email,
            @RequestParam("nick") String nick,
            @RequestParam("school") String school,
            Authentication authentication);  }
@Test public void testUpdate() throws Exception { log.info("update"); User user = mockDataService.user(); String userId = user.getId(); String oldPassword = user.getPassword(); String newPassword = ""; String rptPassword = newPassword; String email = ""; String nick = ""; String school = ""; MvcResult result = mvc.perform(post("/modifyuser").with(user(userId)) .param("oldPassword", oldPassword) .param("newPassword", newPassword) .param("rptPassword", rptPassword) .param("email", email) .param("nick", nick) .param("school", school)) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) .andExpect(view().name("users/modifySuccess")) .andReturn(); }