use of org.apache.ranger.view.VXGroupUser 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.VXGroupUser 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.VXGroupUser in project ranger by apache.
the class TestXUserREST method test27createXGroupUser.
@Test
public void test27createXGroupUser() {
VXGroupUser testVXGroupUser = createVXGroupUser();
Mockito.when(xUserMgr.createXGroupUser(testVXGroupUser)).thenReturn(testVXGroupUser);
VXGroupUser retVxGroupUser = xUserRest.createXGroupUser(testVXGroupUser);
assertNotNull(retVxGroupUser);
assertEquals(testVXGroupUser.getClass(), retVxGroupUser.getClass());
assertEquals(testVXGroupUser.getId(), retVxGroupUser.getId());
Mockito.verify(xUserMgr).createXGroupUser(testVXGroupUser);
}
use of org.apache.ranger.view.VXGroupUser in project ranger by apache.
the class TestXUserREST method test26getXGroupUser.
@Test
public void test26getXGroupUser() {
VXGroupUser testVXGroupUser = createVXGroupUser();
Mockito.when(xUserMgr.getXGroupUser(id)).thenReturn(testVXGroupUser);
VXGroupUser retVxGroupUser = xUserRest.getXGroupUser(id);
assertNotNull(retVxGroupUser);
assertEquals(testVXGroupUser.getClass(), retVxGroupUser.getClass());
assertEquals(testVXGroupUser.getId(), retVxGroupUser.getId());
Mockito.verify(xUserMgr).getXGroupUser(id);
}
use of org.apache.ranger.view.VXGroupUser in project ranger by apache.
the class TestXUserREST method createVXGroupUser.
private VXGroupUser createVXGroupUser() {
VXGroupUser testVXGroupUser = new VXGroupUser();
testVXGroupUser.setId(id);
testVXGroupUser.setCreateDate(new Date());
testVXGroupUser.setUpdateDate(new Date());
testVXGroupUser.setOwner("Admin");
testVXGroupUser.setUpdatedBy("Admin");
testVXGroupUser.setName("finance");
testVXGroupUser.setParentGroupId(id);
testVXGroupUser.setUserId(id);
return testVXGroupUser;
}
Aggregations