use of org.apache.ranger.db.XXGroupDao in project ranger by apache.
the class TestXUserMgr method test122UpdateDeletedGroups.
@Test
public void test122UpdateDeletedGroups() {
destroySession();
setup();
XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
VXGroup vxGroup = vxGroup();
XXGroup xxGroup = new XXGroup();
xxGroup.setId(vxGroup.getId());
xxGroup.setName(vxGroup.getName());
xxGroup.setDescription(vxGroup.getDescription());
xxGroup.setIsVisible(vxGroup.getIsVisible());
Set<String> delGroups = new HashSet<String>();
delGroups.add(vxGroup.getName());
Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
Mockito.when(xxGroupDao.findByGroupName(vxGroup.getName())).thenReturn(xxGroup);
Mockito.when(xGroupService.populateViewBean(xxGroup)).thenReturn(vxGroup);
Mockito.when(xGroupService.updateResource(vxGroup)).thenReturn(vxGroup);
int count = xUserMgr.updateDeletedGroups(delGroups);
Assert.assertNotNull(count);
Assert.assertEquals(count, 1);
}
use of org.apache.ranger.db.XXGroupDao 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());
}
use of org.apache.ranger.db.XXGroupDao in project ranger by apache.
the class TestXUserMgr method test12ModifyGroupsVisibilitySetZero.
@Test
public void test12ModifyGroupsVisibilitySetZero() {
setup();
XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
VXGroup vXGroup = vxGroup();
XXGroup xxGroup = new XXGroup();
HashMap<Long, Integer> groupVisibilityMap = new HashMap<Long, Integer>();
Integer value = 0;
groupVisibilityMap.put(userId, value);
Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
Mockito.when(xxGroupDao.getById(vXGroup.getId())).thenReturn(xxGroup);
Mockito.when(xGroupService.populateViewBean(xxGroup)).thenReturn(vXGroup);
Mockito.when(xGroupService.updateResource(vXGroup)).thenReturn(vXGroup);
xUserMgr.modifyGroupsVisibility(groupVisibilityMap);
Assert.assertEquals(value, vXGroup.getIsVisible());
Assert.assertEquals(userId, vXGroup.getId());
Mockito.verify(daoManager).getXXGroup();
Mockito.verify(xGroupService).populateViewBean(xxGroup);
Mockito.verify(xGroupService).updateResource(vXGroup);
}
use of org.apache.ranger.db.XXGroupDao in project ranger by apache.
the class TestXUserMgr method test17UpdateXGroup.
@Test
public void test17UpdateXGroup() {
XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
XXGroupUserDao xxGroupUserDao = Mockito.mock(XXGroupUserDao.class);
List<XXGroupUser> grpUsers = new ArrayList<XXGroupUser>();
setup();
VXGroup vXGroup = new VXGroup();
vXGroup.setId(userId);
vXGroup.setDescription("group test");
vXGroup.setName("grouptest");
XXGroup xxGroup = new XXGroup();
Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
Mockito.when(xxGroupDao.getById(vXGroup.getId())).thenReturn(xxGroup);
Mockito.when(xGroupService.updateResource(vXGroup)).thenReturn(vXGroup);
Mockito.when(daoManager.getXXGroupUser()).thenReturn(xxGroupUserDao);
Mockito.when(xxGroupUserDao.findByGroupId(vXGroup.getId())).thenReturn(grpUsers);
VXGroup dbvxGroup = xUserMgr.updateXGroup(vXGroup);
Assert.assertNotNull(dbvxGroup);
userId = dbvxGroup.getId();
Assert.assertEquals(userId, dbvxGroup.getId());
Assert.assertEquals(vXGroup.getDescription(), dbvxGroup.getDescription());
Assert.assertEquals(vXGroup.getName(), dbvxGroup.getName());
Mockito.verify(daoManager).getXXGroup();
Mockito.verify(daoManager).getXXGroupUser();
Mockito.verify(xGroupService).updateResource(vXGroup);
Mockito.verify(xxGroupUserDao).findByGroupId(vXGroup.getId());
}
use of org.apache.ranger.db.XXGroupDao in project ranger by apache.
the class TestXUserMgr method test19ModifyGroupsVisibilitySetZero.
@Test
public void test19ModifyGroupsVisibilitySetZero() {
XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
VXGroup vXGroup = new VXGroup();
vXGroup.setId(userId);
vXGroup.setDescription("group test");
vXGroup.setName("grouptest");
XXGroup xxGroup = new XXGroup();
HashMap<Long, Integer> groupVisibilityMap = new HashMap<Long, Integer>();
Integer value = 0;
groupVisibilityMap.put(userId, value);
Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
Mockito.when(xxGroupDao.getById(vXGroup.getId())).thenReturn(xxGroup);
Mockito.when(xGroupService.populateViewBean(xxGroup)).thenReturn(vXGroup);
Mockito.when(xGroupService.updateResource(vXGroup)).thenReturn(vXGroup);
xUserMgr.modifyGroupsVisibility(groupVisibilityMap);
Assert.assertEquals(value, vXGroup.getIsVisible());
Assert.assertEquals(userId, vXGroup.getId());
Mockito.verify(daoManager).getXXGroup();
Mockito.verify(xGroupService).populateViewBean(xxGroup);
Mockito.verify(xGroupService).updateResource(vXGroup);
}
Aggregations