### Question:
PermissionManager { public void updateUser(Person user) { String login = StringUtils.trimToNull(user.getUserName()); if (login == null) { throw new TabMissingValueException("Cannot update user: user login is null"); } Person userDB = getUserByLogin(login); mergeProps(user, userDB, "address", "firstName", "lastName", "affiliation", "password", "email"); UserRole role = user.getRole(); if (role != null) { userDB.setRole(role); } Date date = user.getJoinDate(); if (date != null) { userDB.setJoinDate(date); } validateUser(userDB); daoFactory.getUserDAO().update(userDB); } PermissionManager(EntityManager entityManager); static Options createUserDefOptions(); @SuppressWarnings("static-access") static Options createUserDefOptions(Options baseOptions); @SuppressWarnings("static-access") static Options createPermModOptions(Options baseOptions); static Options createPermModOptions(); Person createNewUserFromOptions(String login, CommandLine cmdl); void validateUser(Person user); long addUser(Person user); void updateUser(Person user); void deleteUser(String login); void setStudyOwners(CommandLine cmdl); void setStudyOwners(String spec); void setStudyOwners(String studyAcc, String operation, String... logins); void setStatus(CommandLine cmdl, VisibilityStatus status); void setVisibility(CommandLine cmdl); void setPrivate(String spec); void setPrivate(String... studyAccs); void setStatus(VisibilityStatus status, String... studyAccs); void setPublic(String spec); void setPublic(String... studyAccs); @SuppressWarnings("unchecked") List<Study> getStudies(); @SuppressWarnings("unchecked") List<Person> getUsers(); Person getUserByLogin(String login); Study getStudyByAcc(String acc); static String formatUser(Person user); static String formatStudy(Study study); final static String[] VALID_DATE_FORMATS; }### Answer:
@Test public void testUpdateUser() { Person user = createTestUser(); user.setPassword("secret1"); user.setRole(UserRole.SUBMITTER); user.setJoinDate(new GregorianCalendar(1973, Calendar.SEPTEMBER, 10).getTime()); PermissionManager permMgr = new PermissionManager(entityManager); permMgr.updateUser(user); commitTansaction(); session.flush(); Person userdb = permMgr.getUserByLogin(user.getUserName()); assertEquals("Wrong saved user!", user.getUserName(), userdb.getUserName()); assertEquals("Wrong saved user!", user.getFirstName(), userdb.getFirstName()); assertEquals("Wrong saved user!", user.getJoinDate(), userdb.getJoinDate()); assertEquals("Wrong saved user!", user.getRole(), userdb.getRole()); }