@Test public void lockUser() { User user = new User(); user.setUserName("tom"); user.setPassword("1234"); doReturn(user).when(userDao).getUserByUserName("tom"); doNothing().when(userDao).update(user); userService.lockUser("tom"); User u = userService.getUserByUserName("tom"); assertEquals(User.USER_LOCK, u.getLocked()); }
public void lockUser(String userName){ User user = userDao.getUserByUserName(userName); user.setLocked(User.USER_LOCK); userDao.update(user); }
UserService { public void lockUser(String userName){ User user = userDao.getUserByUserName(userName); user.setLocked(User.USER_LOCK); userDao.update(user); } }
UserService { public void lockUser(String userName){ User user = userDao.getUserByUserName(userName); user.setLocked(User.USER_LOCK); userDao.update(user); }  }
UserService { public void lockUser(String userName){ User user = userDao.getUserByUserName(userName); user.setLocked(User.USER_LOCK); userDao.update(user); }  void register(User user); void update(User user); User getUserByUserName(String userName); User getUserById(int userId); void lockUser(String userName); void unlockUser(String userName); List<User> queryUserByUserName(String userName); List<User> getAllUsers(); void loginSuccess(User user); }
UserService { public void lockUser(String userName){ User user = userDao.getUserByUserName(userName); user.setLocked(User.USER_LOCK); userDao.update(user); }  void register(User user); void update(User user); User getUserByUserName(String userName); User getUserById(int userId); void lockUser(String userName); void unlockUser(String userName); List<User> queryUserByUserName(String userName); List<User> getAllUsers(); void loginSuccess(User user);  }