use of org.apache.ranger.view.VXGroupUserInfo in project ranger by apache.
the class TestXUserMgr method test52createXGroupUserFromMap.
@Test
public void test52createXGroupUserFromMap() {
setup();
VXGroup vxGroup = vxGroup();
VXUser vxUser = vxUser();
List<VXUser> vXUserList = new ArrayList<VXUser>();
vXUserList.add(vxUser);
VXGroupUserInfo vxGUInfo = new VXGroupUserInfo();
vxGUInfo.setXgroupInfo(vxGroup);
vxGUInfo.setXuserInfo(vXUserList);
XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
XXPortalUserRoleDao userRoleDao = Mockito.mock(XXPortalUserRoleDao.class);
XXModuleDefDao xXModuleDefDao = Mockito.mock(XXModuleDefDao.class);
XXUser xXUser = xxUser(vxUser);
VXPortalUser userProfile = userProfile();
XXPortalUser xXPortalUser = xxPortalUser(userProfile);
xXPortalUser.setUserSource(RangerCommonEnums.USER_EXTERNAL);
List<String> lstRole = new ArrayList<String>();
lstRole.add(RangerConstants.ROLE_SYS_ADMIN);
List<XXModuleDef> xXModuleDefs = new ArrayList<XXModuleDef>();
Mockito.when(daoManager.getXXUser()).thenReturn(xxUserDao);
Mockito.when(xxUserDao.findByUserName(vxUser.getName())).thenReturn(xXUser);
Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
Mockito.when(userDao.findByLoginId(vxUser.getName())).thenReturn(xXPortalUser);
Mockito.when(xGroupService.createXGroupWithOutLogin(vxGroup)).thenReturn(vxGroup);
Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(userRoleDao);
Mockito.when(userMgr.mapXXPortalUserToVXPortalUserForDefaultAccount(xXPortalUser)).thenReturn(userProfile);
Mockito.when(daoManager.getXXModuleDef()).thenReturn(xXModuleDefDao);
Mockito.when(xXModuleDefDao.getAll()).thenReturn(xXModuleDefs);
VXGroupUserInfo vxGUInfoObj = xUserMgr.createXGroupUserFromMap(vxGUInfo);
Assert.assertNotNull(vxGUInfoObj);
}
use of org.apache.ranger.view.VXGroupUserInfo in project ranger by apache.
the class TestXUserMgr method test53getXGroupUserFromMap.
@Test
public void test53getXGroupUserFromMap() {
setup();
VXGroup vxGroup = vxGroup();
VXUser vxUser = vxUser();
List<VXUser> vXUserList = new ArrayList<VXUser>();
vXUserList.add(vxUser);
VXGroupUserInfo vxGUInfo = new VXGroupUserInfo();
vxGUInfo.setXgroupInfo(vxGroup);
vxGUInfo.setXuserInfo(vXUserList);
XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
XXGroup xxGroup = new XXGroup();
xxGroup.setId(vxGroup.getId());
xxGroup.setName(vxGroup.getName());
xxGroup.setDescription(vxGroup.getDescription());
xxGroup.setIsVisible(vxGroup.getIsVisible());
VXPortalUser userProfile = userProfile();
XXPortalUser xXPortalUser = xxPortalUser(userProfile);
xXPortalUser.setUserSource(RangerCommonEnums.USER_EXTERNAL);
VXGroupUserList vxGroupUserList = new VXGroupUserList();
List<VXGroupUser> vXGroupUsers = new ArrayList<VXGroupUser>();
VXGroupUser vxGroupUser = vxGroupUser();
vXGroupUsers.add(vxGroupUser);
vxGroupUserList.setVXGroupUsers(vXGroupUsers);
List<String> lstRole = new ArrayList<String>();
lstRole.add(RangerConstants.ROLE_USER);
Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
SearchCriteria searchCriteria = createsearchCriteria();
searchCriteria.addParam("xGroupId", xxGroup.getId());
Mockito.when(xxGroupDao.findByGroupName("")).thenReturn(null);
VXGroupUserInfo vxGUInfoObjNull = xUserMgr.getXGroupUserFromMap("");
Assert.assertNull(vxGUInfoObjNull.getXgroupInfo());
Mockito.when(xxGroupDao.findByGroupName(Mockito.anyString())).thenReturn(xxGroup);
Mockito.when(xGroupService.populateViewBean(xxGroup)).thenReturn(vxGroup);
Mockito.when(xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito.any())).thenReturn(vxGroupUserList);
XXUser xXUser = xxUser(vxUser);
XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
Mockito.when(daoManager.getXXUser()).thenReturn(xxUserDao);
Mockito.when(xxUserDao.getById(userId)).thenReturn(xXUser);
XXPortalUserDao xXPortalUserDao = Mockito.mock(XXPortalUserDao.class);
Mockito.when(daoManager.getXXPortalUser()).thenReturn(xXPortalUserDao);
Mockito.when(xXPortalUserDao.findByLoginId(xXUser.getName().trim())).thenReturn(xXPortalUser);
XXPortalUserRoleDao xXPortalUserRoleDao = Mockito.mock(XXPortalUserRoleDao.class);
Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(xXPortalUserRoleDao);
vxGUInfoObjNull = xUserMgr.getXGroupUserFromMap(xxGroup.getName());
}
Aggregations