UserMgmtServerEao { public void modify(UserMgmtServer usrMgmtServer) { encryptPassword(usrMgmtServer); UserMgmtServerEntity userMgmtServerEntity = userMgmtServerDao.findById(usrMgmtServer.getName()); userMgmtServerEntity.copyFrom(usrMgmtServer); userMgmtServerDao.update(userMgmtServerEntity); }  void persist(UserMgmtServer usrMgmtServer); @Transactional(propagation = Propagation.SUPPORTS) UserMgmtServer findByName(String name, boolean safely); void delete(String name); void checkServerChanged(UserMgmtServer userMgtServer); void modify(UserMgmtServer usrMgmtServer);  }
@Test(groups = {"TestUserMgmtServerEao"}) public void testModify() { userMgmtServerDao = new MockUp<IBaseDAO<UserMgmtServerEntity>>() { @Mock(invocations = 1) public UserMgmtServerEntity findById(Serializable id) { UserMgmtServerEntity userMgmtServerEntity = prepareUserMgmtServerEntity(password); return userMgmtServerEntity; } @Mock(invocations = 1) public void update(UserMgmtServerEntity userMgmtServerEntity) { assertUserMgmtServerEntity(userMgmtServerEntity); } }.getMockInstance(); TestUtils.setPrivateField(userMgmtServerEao, "userMgmtServerDao", userMgmtServerDao); UserMgmtServer userMgmtServer = prepareUserMgmtServer(true); userMgmtServerEao.modify(userMgmtServer); }