use of org.apache.ranger.view.VXGroup in project ranger by apache.
the class TestXUserMgr method test26CreateXGroupWithoutLogin.
@Test
public void test26CreateXGroupWithoutLogin() {
setup();
VXGroup vXGroup = new VXGroup();
vXGroup.setId(userId);
vXGroup.setDescription("group test");
vXGroup.setName("grouptest");
Mockito.when(xGroupService.createXGroupWithOutLogin(vXGroup)).thenReturn(vXGroup);
VXGroup dbVXGroup = xUserMgr.createXGroupWithoutLogin(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(xGroupService).createXGroupWithOutLogin(vXGroup);
}
use of org.apache.ranger.view.VXGroup in project ranger by apache.
the class TestXUserMgr method test21createXGroupUser.
@Test
public void test21createXGroupUser() {
setup();
VXGroupUser vxGroupUser = new VXGroupUser();
vxGroupUser.setId(userId);
vxGroupUser.setName("group user test");
vxGroupUser.setOwner("Admin");
vxGroupUser.setUserId(userId);
vxGroupUser.setUpdatedBy("User");
Mockito.when(xGroupUserService.createXGroupUserWithOutLogin(vxGroupUser)).thenReturn(vxGroupUser);
VXGroupUser dbVXGroupUser = xUserMgr.createXGroupUser(vxGroupUser);
Assert.assertNotNull(dbVXGroupUser);
userId = dbVXGroupUser.getId();
Assert.assertEquals(userId, dbVXGroupUser.getId());
Assert.assertEquals(dbVXGroupUser.getOwner(), vxGroupUser.getOwner());
Assert.assertEquals(dbVXGroupUser.getName(), vxGroupUser.getName());
Assert.assertEquals(dbVXGroupUser.getUserId(), vxGroupUser.getUserId());
Assert.assertEquals(dbVXGroupUser.getUpdatedBy(), vxGroupUser.getUpdatedBy());
Mockito.verify(xGroupUserService).createXGroupUserWithOutLogin(vxGroupUser);
Mockito.when(xGroupUserService.readResourceWithOutLogin(userId)).thenReturn(vxGroupUser);
VXGroup vXGroup = new VXGroup();
vXGroup.setId(userId);
vXGroup.setDescription("group test");
vXGroup.setName("grouptest");
VXGroupUser dbvxGroupUser = xUserMgr.getXGroupUser(userId);
Assert.assertNotNull(dbvxGroupUser);
userId = dbvxGroupUser.getId();
Assert.assertEquals(userId, dbvxGroupUser.getId());
Assert.assertEquals(dbvxGroupUser.getOwner(), vxGroupUser.getOwner());
Assert.assertEquals(dbvxGroupUser.getName(), vxGroupUser.getName());
Assert.assertEquals(dbvxGroupUser.getUserId(), vxGroupUser.getUserId());
Assert.assertEquals(dbvxGroupUser.getUpdatedBy(), vxGroupUser.getUpdatedBy());
Mockito.verify(xGroupUserService).readResourceWithOutLogin(userId);
}
use of org.apache.ranger.view.VXGroup in project ranger by apache.
the class TestXUserMgr method test18ModifyGroupsVisibilitySetOne.
@Test
public void test18ModifyGroupsVisibilitySetOne() {
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 = 1;
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.view.VXGroup in project ranger by apache.
the class TestXUserMgr method test27DeleteXGroup.
@Test
public void test27DeleteXGroup() {
setup();
boolean force = true;
VXGroup vXGroup = new VXGroup();
vXGroup.setId(userId);
vXGroup.setDescription("group test");
vXGroup.setName("grouptest");
// XXGroup
XXGroupDao xXGroupDao = Mockito.mock(XXGroupDao.class);
XXGroup xXGroup = new XXGroup();
Mockito.when(daoManager.getXXGroup()).thenReturn(xXGroupDao);
Mockito.when(xXGroupDao.getById(vXGroup.getId())).thenReturn(xXGroup);
Mockito.when(xGroupService.populateViewBean(xXGroup)).thenReturn(vXGroup);
// VXGroupUser
VXGroupUserList vxGroupUserList = new VXGroupUserList();
XXGroupUserDao xGroupUserDao = Mockito.mock(XXGroupUserDao.class);
VXGroupUser vxGroupUser = new VXGroupUser();
vxGroupUser.setId(userId);
vxGroupUser.setName("group user test");
vxGroupUser.setOwner("Admin");
vxGroupUser.setUserId(userId);
vxGroupUser.setUpdatedBy("User");
Mockito.when(xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito.any())).thenReturn(vxGroupUserList);
Mockito.when(daoManager.getXXGroupUser()).thenReturn(xGroupUserDao);
// VXPermMap
VXPermMapList vXPermMapList = new VXPermMapList();
XXPermMapDao xXPermMapDao = Mockito.mock(XXPermMapDao.class);
Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria) Mockito.any())).thenReturn(vXPermMapList);
Mockito.when(daoManager.getXXPermMap()).thenReturn(xXPermMapDao);
// VXAuditMap
VXAuditMapList vXAuditMapList = new VXAuditMapList();
XXAuditMapDao xXAuditMapDao = Mockito.mock(XXAuditMapDao.class);
Mockito.when(xAuditMapService.searchXAuditMaps((SearchCriteria) Mockito.any())).thenReturn(vXAuditMapList);
Mockito.when(daoManager.getXXAuditMap()).thenReturn(xXAuditMapDao);
// XXGroupGroup
XXGroupGroupDao xXGroupGroupDao = Mockito.mock(XXGroupGroupDao.class);
List<XXGroupGroup> xXGroupGroups = new ArrayList<XXGroupGroup>();
Mockito.when(daoManager.getXXGroupGroup()).thenReturn(xXGroupGroupDao);
Mockito.when(xXGroupGroupDao.findByGroupId(userId)).thenReturn(xXGroupGroups);
// update XXGroupPermission
XXGroupPermissionDao xXGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class);
Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xXGroupPermissionDao);
List<XXGroupPermission> xXGroupPermissions = new ArrayList<XXGroupPermission>();
Mockito.when(xXGroupPermissionDao.findByGroupId(vXGroup.getId())).thenReturn(xXGroupPermissions);
// update XXPolicyItemUserPerm
XXPolicyDao xXPolicyDao = Mockito.mock(XXPolicyDao.class);
List<XXPolicy> xXPolicyList = new ArrayList<XXPolicy>();
Mockito.when(daoManager.getXXPolicy()).thenReturn(xXPolicyDao);
Mockito.when(xXPolicyDao.findByGroupId(userId)).thenReturn(xXPolicyList);
xUserMgr.deleteXGroup(vXGroup.getId(), force);
Mockito.verify(xGroupUserService).searchXGroupUsers((SearchCriteria) Mockito.any());
}
use of org.apache.ranger.view.VXGroup in project ranger by apache.
the class TestXUserREST method test3createXGroup.
@Test
public void test3createXGroup() {
VXGroup compareTestVXGroup = createVXGroup();
Mockito.when(xUserMgr.createXGroupWithoutLogin(compareTestVXGroup)).thenReturn(compareTestVXGroup);
VXGroup retVxGroup = xUserRest.createXGroup(compareTestVXGroup);
assertNotNull(retVxGroup);
assertEquals(compareTestVXGroup.getId(), retVxGroup.getId());
assertEquals(compareTestVXGroup.getName(), retVxGroup.getName());
Mockito.verify(xUserMgr).createXGroupWithoutLogin(compareTestVXGroup);
}
Aggregations