@Test public void test21getUserProfile() { setup(); XXPortalUserDao xPortalUserDao = Mockito.mock(XXPortalUserDao.class); XXPortalUser xPortalUser = Mockito.mock(XXPortalUser.class); XXUserPermissionDao xUserPermissionDao = Mockito.mock(XXUserPermissionDao.class); XXGroupPermissionDao xGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class); XXPortalUserRoleDao xPortalUserRoleDao = Mockito.mock(XXPortalUserRoleDao.class); List<XXPortalUserRole> xPortalUserRoleList = new ArrayList<XXPortalUserRole>(); XXPortalUserRole XXPortalUserRole = new XXPortalUserRole(); XXPortalUserRole.setId(userId); XXPortalUserRole.setUserRole("ROLE_USER"); xPortalUserRoleList.add(XXPortalUserRole); List<XXUserPermission> xUserPermissionsList = new ArrayList<XXUserPermission>(); XXUserPermission xUserPermissionObj = new XXUserPermission(); xUserPermissionObj.setAddedByUserId(userId); xUserPermissionObj.setCreateTime(new Date()); xUserPermissionObj.setId(userId); xUserPermissionObj.setIsAllowed(1); xUserPermissionObj.setModuleId(1L); xUserPermissionObj.setUpdatedByUserId(userId); xUserPermissionObj.setUpdateTime(new Date()); xUserPermissionObj.setUserId(userId); xUserPermissionsList.add(xUserPermissionObj); List<XXGroupPermission> xGroupPermissionList = new ArrayList<XXGroupPermission>(); XXGroupPermission xGroupPermissionObj = new XXGroupPermission(); xGroupPermissionObj.setAddedByUserId(userId); xGroupPermissionObj.setCreateTime(new Date()); xGroupPermissionObj.setId(userId); xGroupPermissionObj.setIsAllowed(1); xGroupPermissionObj.setModuleId(1L); xGroupPermissionObj.setUpdatedByUserId(userId); xGroupPermissionObj.setUpdateTime(new Date()); xGroupPermissionObj.setGroupId(userId); xGroupPermissionList.add(xGroupPermissionObj); Mockito.when(daoManager.getXXPortalUser()).thenReturn(xPortalUserDao); Mockito.when(xPortalUserDao.getById(userId)).thenReturn(null); Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(xPortalUserRoleDao); Mockito.when(daoManager.getXXUserPermission()).thenReturn(xUserPermissionDao); Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xGroupPermissionDao); VXPortalUser dbVXPortalUser = userMgr.getUserProfile(userId); Mockito.when(xPortalUserDao.getById(userId)).thenReturn(xPortalUser); dbVXPortalUser = userMgr.getUserProfile(userId); Assert.assertNotNull(dbVXPortalUser); }
public VXPortalUser getUserProfile(Long id) { XXPortalUser user = daoManager.getXXPortalUser().getById(id); if (user != null) { checkAccess(user); return mapXXPortalUserVXPortalUser(user); } else { if (logger.isDebugEnabled()) { logger.debug("User not found. userId=" + id); } return null; } }
UserMgr { public VXPortalUser getUserProfile(Long id) { XXPortalUser user = daoManager.getXXPortalUser().getById(id); if (user != null) { checkAccess(user); return mapXXPortalUserVXPortalUser(user); } else { if (logger.isDebugEnabled()) { logger.debug("User not found. userId=" + id); } return null; } } }
UserMgr { public VXPortalUser getUserProfile(Long id) { XXPortalUser user = daoManager.getXXPortalUser().getById(id); if (user != null) { checkAccess(user); return mapXXPortalUserVXPortalUser(user); } else { if (logger.isDebugEnabled()) { logger.debug("User not found. userId=" + id); } return null; } } UserMgr(); }
UserMgr { public VXPortalUser getUserProfile(Long id) { XXPortalUser user = daoManager.getXXPortalUser().getById(id); if (user != null) { checkAccess(user); return mapXXPortalUserVXPortalUser(user); } else { if (logger.isDebugEnabled()) { logger.debug("User not found. userId=" + id); } return null; } } UserMgr(); XXPortalUser createUser(VXPortalUser userProfile, int userStatus,
			Collection<String> userRoleList); XXPortalUser createUser(XXPortalUser user, int userStatus,
			Collection<String> userRoleList); XXPortalUser createUser(VXPortalUser userProfile, int userStatus); XXPortalUser updateUser(VXPortalUser userProfile); boolean updateRoles(Long userId, Collection<String> rolesList); void setUserRoles(Long userId, List<VXString> vStringRolesList); VXResponse changePassword(VXPasswordChange pwdChange); VXPortalUser changeEmailAddress(XXPortalUser gjUser,
			VXPasswordChange changeEmail); VXPortalUser deactivateUser(XXPortalUser gjUser); VXPortalUser getUserProfile(Long id); VXPortalUser getUserProfileByLoginId(); VXPortalUser getUserProfileByLoginId(String loginId); XXPortalUser mapVXPortalUserToXXPortalUser(VXPortalUser userProfile); VXPortalUser mapXXPortalUserToVXPortalUser(XXPortalUser user,
			Collection<String> userRoleList); VXPortalUser mapXXPortalUserVXPortalUser(XXPortalUser user); XXPortalUser findByEmailAddress(String emailId); XXPortalUser findByLoginId(String loginId); @Transactional(readOnly = true, propagation = Propagation.REQUIRED) Collection<String> getRolesForUser(XXPortalUser user); VXPortalUserList searchUsers(SearchCriteria searchCriteria); boolean deleteUserRole(Long userId, String userRole); boolean deleteUserRole(Long userId, XXPortalUserRole gjUserRole); XXPortalUserRole addUserRole(Long userId, String userRole); void checkAccess(Long userId); void checkAccess(XXPortalUser gjUser); void checkAccessForUpdate(XXPortalUser gjUser); String encrypt(String loginId, String password); String encryptWithOlderAlgo(String loginId, String password); VXPortalUser createUser(VXPortalUser userProfile); VXPortalUser createDefaultAccountUser(VXPortalUser userProfile); boolean isUserInRole(Long userId, String role); XXPortalUser updateUserWithPass(VXPortalUser userProfile); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) XXPortalUser updatePasswordInSHA256(String userName,String userPassword,boolean logAudits); void checkAdminAccess(); Collection<String> getRolesByLoginId(String loginId); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) XXPortalUser updateOldUserName(String userLoginId,String newUserName, String currentPassword); }
UserMgr { public VXPortalUser getUserProfile(Long id) { XXPortalUser user = daoManager.getXXPortalUser().getById(id); if (user != null) { checkAccess(user); return mapXXPortalUserVXPortalUser(user); } else { if (logger.isDebugEnabled()) { logger.debug("User not found. userId=" + id); } return null; } } UserMgr(); XXPortalUser createUser(VXPortalUser userProfile, int userStatus,
			Collection<String> userRoleList); XXPortalUser createUser(XXPortalUser user, int userStatus,
			Collection<String> userRoleList); XXPortalUser createUser(VXPortalUser userProfile, int userStatus); XXPortalUser updateUser(VXPortalUser userProfile); boolean updateRoles(Long userId, Collection<String> rolesList); void setUserRoles(Long userId, List<VXString> vStringRolesList); VXResponse changePassword(VXPasswordChange pwdChange); VXPortalUser changeEmailAddress(XXPortalUser gjUser,
			VXPasswordChange changeEmail); VXPortalUser deactivateUser(XXPortalUser gjUser); VXPortalUser getUserProfile(Long id); VXPortalUser getUserProfileByLoginId(); VXPortalUser getUserProfileByLoginId(String loginId); XXPortalUser mapVXPortalUserToXXPortalUser(VXPortalUser userProfile); VXPortalUser mapXXPortalUserToVXPortalUser(XXPortalUser user,
			Collection<String> userRoleList); VXPortalUser mapXXPortalUserVXPortalUser(XXPortalUser user); XXPortalUser findByEmailAddress(String emailId); XXPortalUser findByLoginId(String loginId); @Transactional(readOnly = true, propagation = Propagation.REQUIRED) Collection<String> getRolesForUser(XXPortalUser user); VXPortalUserList searchUsers(SearchCriteria searchCriteria); boolean deleteUserRole(Long userId, String userRole); boolean deleteUserRole(Long userId, XXPortalUserRole gjUserRole); XXPortalUserRole addUserRole(Long userId, String userRole); void checkAccess(Long userId); void checkAccess(XXPortalUser gjUser); void checkAccessForUpdate(XXPortalUser gjUser); String encrypt(String loginId, String password); String encryptWithOlderAlgo(String loginId, String password); VXPortalUser createUser(VXPortalUser userProfile); VXPortalUser createDefaultAccountUser(VXPortalUser userProfile); boolean isUserInRole(Long userId, String role); XXPortalUser updateUserWithPass(VXPortalUser userProfile); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) XXPortalUser updatePasswordInSHA256(String userName,String userPassword,boolean logAudits); void checkAdminAccess(); Collection<String> getRolesByLoginId(String loginId); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) XXPortalUser updateOldUserName(String userLoginId,String newUserName, String currentPassword);  }