@Test
public void test77updateUserRolesPermissions() {

	setup();
	List<String> existingRoleList = new ArrayList<String>();
	existingRoleList.add(RangerConstants.ROLE_USER);
	List<String> reqRoleList = new ArrayList<String>();
	reqRoleList.add(RangerConstants.ROLE_SYS_ADMIN);
	Collection<Long> groupIdList = new ArrayList<Long>();
	groupIdList.add(userId);
	VXUser vxUser = vxUser();
	vxUser.setUserRoleList(reqRoleList);
	vxUser.setUserSource(RangerCommonEnums.USER_EXTERNAL);
	vxUser.setGroupIdList(groupIdList);
	vxUser.setFirstName("null");
	vxUser.setLastName("null");
	vxUser.setPassword("*****");
	VXPortalUser oldUserProfile = userProfile();
	oldUserProfile.setUserSource(RangerCommonEnums.USER_APP);
	oldUserProfile.setPassword(vxUser.getPassword());
	oldUserProfile.setUserRoleList(existingRoleList);
	VXPortalUser vXPortalUser = userProfile();
	vXPortalUser.setUserRoleList(reqRoleList);
	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);
	UserSessionBase userSession = Mockito.mock(UserSessionBase.class);
	Set<UserSessionBase> userSessions = new HashSet<UserSessionBase>();
	userSessions.add(userSession);
	XXUserPermissionDao xUserPermissionDao = Mockito.mock(XXUserPermissionDao.class);
	Mockito.when(daoManager.getXXUserPermission()).thenReturn(xUserPermissionDao);
	XXModuleDefDao xXModuleDefDao = Mockito.mock(XXModuleDefDao.class);
	XXUserPermissionDao xXUserPermissionDao= Mockito.mock(XXUserPermissionDao.class);
	XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
	Collection<String> userRoleList = new ArrayList<String>();
	userRoleList.add("ROLE_USER");
	vXPortalUser.setUserRoleList(userRoleList);
	XXUser xXUser = xxUser(vxUser);
	List<XXModuleDef> xXModuleDefs = xxModuleDefs();
	VXUserPermission userPermission = vxUserPermission();
	List<VXUserPermission> userPermList = new ArrayList<VXUserPermission>();
	userPermList.add(userPermission);
	xUserPermissionObj.setModuleId(userPermission.getModuleId());
	xUserPermissionObj.setUserId(userPermission.getUserId());
	xUserPermissionsList.add(xUserPermissionObj);
	Mockito.when(daoManager.getXXModuleDef()).thenReturn(xXModuleDefDao);
	Mockito.when(xXModuleDefDao.getAll()).thenReturn(xXModuleDefs);
	Mockito.when(daoManager.getXXUserPermission()).thenReturn(xXUserPermissionDao);
	Mockito.when(daoManager.getXXUser()).thenReturn(xxUserDao);
	Mockito.when(xxUserDao.findByPortalUserId(vXPortalUser.getId())).thenReturn(xXUser);
	Mockito.when(xXUserPermissionDao.findByUserPermissionId(vXPortalUser.getId())).thenReturn(xUserPermissionsList);
	Mockito.when(xUserPermissionService.createResource((VXUserPermission) Mockito.any())).thenReturn(userPermission);
	Mockito.when(sessionMgr.getActiveUserSessionsForPortalUserId(userId)).thenReturn(userSessions);
	xUserMgr.updateUserRolesPermissions(oldUserProfile,reqRoleList);
}