@Test public void test18DeleteUserRole() { setup(); XXPortalUserRoleDao roleDao = Mockito.mock(XXPortalUserRoleDao.class); XXPortalUserRole XXPortalUserRole = new XXPortalUserRole(); String userRole = "ROLE_USER"; XXPortalUser user = new XXPortalUser(); XXPortalUserRole.setId(user.getId()); XXPortalUserRole.setUserRole("ROLE_USER"); List<XXPortalUserRole> list = new ArrayList<XXPortalUserRole>(); list.add(XXPortalUserRole); Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(roleDao); Mockito.when(roleDao.findByUserId(userId)).thenReturn(list); boolean deleteValue = userMgr.deleteUserRole(userId, userRole); Assert.assertTrue(deleteValue); }
public boolean deleteUserRole(Long userId, String userRole) { List<XXPortalUserRole> roleList = daoManager.getXXPortalUserRole() .findByUserId(userId); for (XXPortalUserRole gjUserRole : roleList) { if (gjUserRole.getUserRole().equalsIgnoreCase(userRole)) { return deleteUserRole(userId, gjUserRole); } } return false; }
UserMgr { public boolean deleteUserRole(Long userId, String userRole) { List<XXPortalUserRole> roleList = daoManager.getXXPortalUserRole() .findByUserId(userId); for (XXPortalUserRole gjUserRole : roleList) { if (gjUserRole.getUserRole().equalsIgnoreCase(userRole)) { return deleteUserRole(userId, gjUserRole); } } return false; } }
UserMgr { public boolean deleteUserRole(Long userId, String userRole) { List<XXPortalUserRole> roleList = daoManager.getXXPortalUserRole() .findByUserId(userId); for (XXPortalUserRole gjUserRole : roleList) { if (gjUserRole.getUserRole().equalsIgnoreCase(userRole)) { return deleteUserRole(userId, gjUserRole); } } return false; } UserMgr(); }
UserMgr { public boolean deleteUserRole(Long userId, String userRole) { List<XXPortalUserRole> roleList = daoManager.getXXPortalUserRole() .findByUserId(userId); for (XXPortalUserRole gjUserRole : roleList) { if (gjUserRole.getUserRole().equalsIgnoreCase(userRole)) { return deleteUserRole(userId, gjUserRole); } } return false; } 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 boolean deleteUserRole(Long userId, String userRole) { List<XXPortalUserRole> roleList = daoManager.getXXPortalUserRole() .findByUserId(userId); for (XXPortalUserRole gjUserRole : roleList) { if (gjUserRole.getUserRole().equalsIgnoreCase(userRole)) { return deleteUserRole(userId, gjUserRole); } } return false; } 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);  }