Search in sources :

Example 1 with VXGroupUserInfo

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);
}
Also used : XXUser(org.apache.ranger.entity.XXUser) XXUserDao(org.apache.ranger.db.XXUserDao) ArrayList(java.util.ArrayList) XXModuleDefDao(org.apache.ranger.db.XXModuleDefDao) VXString(org.apache.ranger.view.VXString) VXUser(org.apache.ranger.view.VXUser) XXPortalUserRoleDao(org.apache.ranger.db.XXPortalUserRoleDao) XXPortalUser(org.apache.ranger.entity.XXPortalUser) XXModuleDef(org.apache.ranger.entity.XXModuleDef) VXGroupUserInfo(org.apache.ranger.view.VXGroupUserInfo) XXPortalUserDao(org.apache.ranger.db.XXPortalUserDao) VXPortalUser(org.apache.ranger.view.VXPortalUser) VXGroup(org.apache.ranger.view.VXGroup) Test(org.junit.Test)

Example 2 with VXGroupUserInfo

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());
}
Also used : XXUser(org.apache.ranger.entity.XXUser) VXGroupUserList(org.apache.ranger.view.VXGroupUserList) XXUserDao(org.apache.ranger.db.XXUserDao) ArrayList(java.util.ArrayList) VXGroupUser(org.apache.ranger.view.VXGroupUser) VXString(org.apache.ranger.view.VXString) VXUser(org.apache.ranger.view.VXUser) SearchCriteria(org.apache.ranger.common.SearchCriteria) XXPortalUser(org.apache.ranger.entity.XXPortalUser) XXPortalUserRoleDao(org.apache.ranger.db.XXPortalUserRoleDao) XXGroup(org.apache.ranger.entity.XXGroup) VXGroupUserInfo(org.apache.ranger.view.VXGroupUserInfo) VXPortalUser(org.apache.ranger.view.VXPortalUser) XXPortalUserDao(org.apache.ranger.db.XXPortalUserDao) VXGroup(org.apache.ranger.view.VXGroup) XXGroupDao(org.apache.ranger.db.XXGroupDao) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 XXPortalUserDao (org.apache.ranger.db.XXPortalUserDao)2 XXPortalUserRoleDao (org.apache.ranger.db.XXPortalUserRoleDao)2 XXUserDao (org.apache.ranger.db.XXUserDao)2 XXPortalUser (org.apache.ranger.entity.XXPortalUser)2 XXUser (org.apache.ranger.entity.XXUser)2 VXGroup (org.apache.ranger.view.VXGroup)2 VXGroupUserInfo (org.apache.ranger.view.VXGroupUserInfo)2 VXPortalUser (org.apache.ranger.view.VXPortalUser)2 VXString (org.apache.ranger.view.VXString)2 VXUser (org.apache.ranger.view.VXUser)2 Test (org.junit.Test)2 SearchCriteria (org.apache.ranger.common.SearchCriteria)1 XXGroupDao (org.apache.ranger.db.XXGroupDao)1 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)1 XXGroup (org.apache.ranger.entity.XXGroup)1 XXModuleDef (org.apache.ranger.entity.XXModuleDef)1 VXGroupUser (org.apache.ranger.view.VXGroupUser)1 VXGroupUserList (org.apache.ranger.view.VXGroupUserList)1