@Test
public void test97updateXModuleDefPermission() {

	XXModuleDefDao xModuleDefDao = Mockito.mock(XXModuleDefDao.class);
	XXModuleDef xModuleDef = xxModuleDef();
	XXUserPermissionDao xUserPermissionDao = Mockito.mock(XXUserPermissionDao.class);
	XXGroupPermissionDao xGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class);
	VXModuleDef vXModuleDef = vxModuleDef();
	Mockito.when(xModuleDefService.updateResource(vXModuleDef)).thenReturn(vXModuleDef);
	Mockito.when(daoManager.getXXModuleDef()).thenReturn(xModuleDefDao);
	Mockito.when(xModuleDefDao.getById(userId)).thenReturn(xModuleDef);
	Mockito.when(xModuleDefService.populateViewBean(xModuleDef)).thenReturn(vXModuleDef);
	Mockito.when(daoManager.getXXUserPermission()).thenReturn(xUserPermissionDao);
	Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xGroupPermissionDao);
	List<XXGroupPermission> xXGroupPermissions=new ArrayList<XXGroupPermission>();
	XXGroupPermission xGroupPermissionObj = xxGroupPermission();
	xXGroupPermissions.add(xGroupPermissionObj);
	List<VXGroupPermission> vXGroupPermissions=new ArrayList<VXGroupPermission>();
	VXGroupPermission vXGroupPermission=vxGroupPermission();
	vXGroupPermission.setIsAllowed(0);
	Mockito.when(xGroupPermissionDao.findByModuleId(vXModuleDef.getId(),true)).thenReturn(xXGroupPermissions);
	List<XXUserPermission> xXUserPermissions=new ArrayList<XXUserPermission>();
	XXUserPermission xUserPermissionObj=xxUserPermission();
	xXUserPermissions.add(xUserPermissionObj);
	VXUserPermission vxUserPermission=vxUserPermission();
	vxUserPermission.setIsAllowed(0);
	Mockito.when(xUserPermissionDao.findByModuleId(vXModuleDef.getId(),true)).thenReturn(xXUserPermissions);
	UserSessionBase userSession = Mockito.mock(UserSessionBase.class);
	Set<UserSessionBase> userSessions = new HashSet<UserSessionBase>();
	userSessions.add(userSession);
	Map<Long, XXGroup> xXGroupMap =new HashMap<Long, XXGroup>();
	VXGroup vxGroup=vxGroup();
	XXGroup xxGroup = new XXGroup();
	xxGroup.setId(vxGroup.getId());
	xxGroup.setName(vxGroup.getName());
	xxGroup.setDescription(vxGroup.getDescription());
	xxGroup.setIsVisible(vxGroup.getIsVisible());
	xXGroupMap.put(xGroupPermissionObj.getGroupId(), xxGroup);
	Mockito.when(xGroupService.getXXGroupIdXXGroupMap()).thenReturn(xXGroupMap);
	Map<Long, XXUser> xXUserMap =new HashMap<Long, XXUser>();
	VXUser vxUser=vxUser();
	XXUser xXUser=xxUser(vxUser);
	xXUserMap.put(xXUser.getId(), xXUser);
	Mockito.when(xUserService.getXXPortalUserIdXXUserMap()).thenReturn(xXUserMap);
	Mockito.when(xGroupPermissionService.getPopulatedVXGroupPermissionList(xXGroupPermissions,xXGroupMap,vXModuleDef)).thenReturn(vXGroupPermissions);
	XXGroupUserDao xxGroupUserDao = Mockito.mock(XXGroupUserDao.class);
	Mockito.when(daoManager.getXXGroupUser()).thenReturn(xxGroupUserDao);
	List<XXGroupUser> grpUsers =new ArrayList<XXGroupUser>();
	Mockito.when(xxGroupUserDao.findByGroupId(vXGroupPermission.getGroupId())).thenReturn(grpUsers);
	List<VXUserPermission> userPermListOld = new ArrayList<VXUserPermission>();
	Mockito.when(xUserPermissionService.getPopulatedVXUserPermissionList(xXUserPermissions,xXUserMap,vXModuleDef)).thenReturn(userPermListOld);
	Mockito.when(sessionMgr.getActiveUserSessionsForPortalUserId(vxUserPermission.getUserId())).thenReturn(userSessions);
	Mockito.when(xGroupPermissionService.createResource((VXGroupPermission) Mockito.any())).thenReturn(vXGroupPermission);
	Mockito.when(xUserPermissionService.createResource((VXUserPermission) Mockito.any())).thenReturn(vxUserPermission);
	VXModuleDef dbMuduleDef = xUserMgr.updateXModuleDefPermission(vXModuleDef);
	Assert.assertEquals(dbMuduleDef, vXModuleDef);
	Assert.assertNotNull(dbMuduleDef);
	Assert.assertEquals(dbMuduleDef, vXModuleDef);
	Assert.assertEquals(dbMuduleDef.getId(), vXModuleDef.getId());
	Assert.assertEquals(dbMuduleDef.getOwner(), vXModuleDef.getOwner());
	Assert.assertEquals(dbMuduleDef.getUpdatedBy(),vXModuleDef.getUpdatedBy());
	Assert.assertEquals(dbMuduleDef.getUrl(), vXModuleDef.getUrl());
	Assert.assertEquals(dbMuduleDef.getAddedById(),vXModuleDef.getAddedById());
	Assert.assertEquals(dbMuduleDef.getCreateDate(),vXModuleDef.getCreateDate());
	Assert.assertEquals(dbMuduleDef.getCreateTime(),vXModuleDef.getCreateTime());
	Assert.assertEquals(dbMuduleDef.getUserPermList(),vXModuleDef.getUserPermList());
	Assert.assertEquals(dbMuduleDef.getGroupPermList(),vXModuleDef.getGroupPermList());
	Mockito.verify(xModuleDefService).updateResource(vXModuleDef);
	Mockito.verify(daoManager).getXXModuleDef();
	Mockito.verify(xModuleDefService).populateViewBean(xModuleDef);
	Mockito.verify(daoManager).getXXUserPermission();
	Mockito.verify(daoManager).getXXGroupPermission();
}