AccountManagerBean implements IAccountManagerLocal { @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override public Account updateAccount(String pName, String pEmail, String pLanguage, String pPassword, String pTimeZone) throws AccountNotFoundException, NotAllowedException { if(!isLanguageSupported(pLanguage)){ throw new NotAllowedException("NotAllowedException74"); } if(!isTimeZoneAvailable(pTimeZone)) { throw new NotAllowedException("NotAllowedException75"); } Account account = accountDAO.loadAccount(contextManager.getCallerPrincipalLogin()); account.setName(pName); account.setEmail(pEmail); account.setLanguage(pLanguage); account.setTimeZone(pTimeZone); if (pPassword != null) { accountDAO.updateCredential(account.getLogin(), pPassword, configManager.getDigestAlgorithm()); } return account; } AccountManagerBean(); @Override Account authenticateAccount(String login, String password); @Override UserGroupMapping getUserGroupMapping(String login); @Override Account createAccount(String pLogin, String pName, String pEmail, String pLanguage, String pPassword, String pTimeZone); @Override Account getAccount(String pLogin); String getRole(String login); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override Account updateAccount(String pName, String pEmail, String pLanguage, String pPassword, String pTimeZone); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override Account checkAdmin(Organization pOrganization); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override Account checkAdmin(String pOrganizationName); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void setGCMAccount(String gcmId); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override void deleteGCMAccount(); @Override boolean isAccountEnabled(String pLogin); @Override @RolesAllowed(UserGroupMapping.ADMIN_ROLE_ID) List<Account> getAccounts(); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override Account getMyAccount(); @Override @RolesAllowed(UserGroupMapping.ADMIN_ROLE_ID) Account enableAccount(String login, boolean enabled); @Override @RolesAllowed(UserGroupMapping.ADMIN_ROLE_ID) Account updateAccount(String pLogin, String pName, String pEmail, String pLanguage, String pPassword, String pTimeZone);  }
@Test public void updateAccountTest()throws AccountNotFoundException,NotAllowedException{ Account accountClone = account.clone(); Mockito.when(accountDAO.loadAccount(contextManager.getCallerPrincipalLogin())).thenReturn(accountClone); Account accountResult = accountManager.updateAccount(account.getName(), "test@test.com","fr", "test", "GMT"); Assert.assertNotEquals(account.getEmail(), accountResult.getEmail()); try { accountManager.updateAccount(account.getName(), account.getEmail(),"bidon", "test", "GMT"); Assert.fail(); }catch(NotAllowedException e){ Assert.assertNotNull(e.getMessage()); } try { accountManager.updateAccount(account.getName(), account.getEmail(),"fr", "test", "bidon"); Assert.fail(); }catch(NotAllowedException e){ Assert.assertNotNull(e.getMessage()); } }