use of org.apache.ranger.view.VXUserPermission in project ranger by apache.
the class TestXUserMgr method test37updateXUserPermission.
@Test
public void test37updateXUserPermission() {
VXUserPermission vXUserPermission = vXUserPermission();
Mockito.when(xUserPermissionService.updateResource(vXUserPermission)).thenReturn(vXUserPermission);
VXUserPermission dbUserPermission = xUserMgr.updateXUserPermission(vXUserPermission);
Assert.assertNotNull(dbUserPermission);
Assert.assertEquals(dbUserPermission, vXUserPermission);
Assert.assertEquals(dbUserPermission.getId(), vXUserPermission.getId());
Assert.assertEquals(dbUserPermission.getOwner(), vXUserPermission.getOwner());
Assert.assertEquals(dbUserPermission.getUpdatedBy(), vXUserPermission.getUpdatedBy());
Assert.assertEquals(dbUserPermission.getUserName(), vXUserPermission.getUserName());
Assert.assertEquals(dbUserPermission.getCreateDate(), vXUserPermission.getCreateDate());
Assert.assertEquals(dbUserPermission.getIsAllowed(), vXUserPermission.getIsAllowed());
Assert.assertEquals(dbUserPermission.getModuleId(), vXUserPermission.getModuleId());
Assert.assertEquals(dbUserPermission.getUpdateDate(), vXUserPermission.getUpdateDate());
Assert.assertEquals(dbUserPermission.getUserId(), vXUserPermission.getUserId());
Mockito.verify(xUserPermissionService).updateResource(vXUserPermission);
}
use of org.apache.ranger.view.VXUserPermission in project ranger by apache.
the class TestXUserMgr method test33updateXModuleDefPermission.
@Test
public void test33updateXModuleDefPermission() {
XXModuleDefDao xModuleDefDao = Mockito.mock(XXModuleDefDao.class);
XXModuleDef xModuleDef = Mockito.mock(XXModuleDef.class);
XXUserPermissionDao xUserPermissionDao = Mockito.mock(XXUserPermissionDao.class);
XXGroupPermissionDao xGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class);
VXUserPermission vXUserPermission = vXUserPermission();
VXGroupPermission vXGroupPermission = vXGroupPermission();
VXModuleDef vXModuleDef = vXModuleDef();
Mockito.when(xModuleDefService.updateResource(vXModuleDef)).thenReturn(vXModuleDef);
Mockito.when(daoManager.getXXModuleDef()).thenReturn(xModuleDefDao);
Mockito.when(xModuleDefDao.getById(userId)).thenReturn(xModuleDef);
Mockito.when(xModuleDefService.populateViewBean(xModuleDef)).thenReturn(vXModuleDef);
Mockito.when(daoManager.getXXUserPermission()).thenReturn(xUserPermissionDao);
Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xGroupPermissionDao);
XXGroupUserDao xGrpUserDao = Mockito.mock(XXGroupUserDao.class);
Mockito.when(daoManager.getXXGroupUser()).thenReturn(xGrpUserDao);
UserSessionBase userSession = Mockito.mock(UserSessionBase.class);
Set<UserSessionBase> userSessions = new HashSet<UserSessionBase>();
userSessions.add(userSession);
Mockito.when(xGroupPermissionService.createResource((VXGroupPermission) Mockito.any())).thenReturn(vXGroupPermission);
Mockito.when(xUserPermissionService.createResource((VXUserPermission) Mockito.any())).thenReturn(vXUserPermission);
Mockito.when(sessionMgr.getActiveUserSessionsForPortalUserId(userId)).thenReturn(userSessions);
VXModuleDef dbMuduleDef = xUserMgr.updateXModuleDefPermission(vXModuleDef);
Assert.assertEquals(dbMuduleDef, vXModuleDef);
Assert.assertNotNull(dbMuduleDef);
Assert.assertEquals(dbMuduleDef, vXModuleDef);
Assert.assertEquals(dbMuduleDef.getId(), vXModuleDef.getId());
Assert.assertEquals(dbMuduleDef.getOwner(), vXModuleDef.getOwner());
Assert.assertEquals(dbMuduleDef.getUpdatedBy(), vXModuleDef.getUpdatedBy());
Assert.assertEquals(dbMuduleDef.getUrl(), vXModuleDef.getUrl());
Assert.assertEquals(dbMuduleDef.getAddedById(), vXModuleDef.getAddedById());
Assert.assertEquals(dbMuduleDef.getCreateDate(), vXModuleDef.getCreateDate());
Assert.assertEquals(dbMuduleDef.getCreateTime(), vXModuleDef.getCreateTime());
Assert.assertEquals(dbMuduleDef.getUserPermList(), vXModuleDef.getUserPermList());
Assert.assertEquals(dbMuduleDef.getGroupPermList(), vXModuleDef.getGroupPermList());
Mockito.verify(xModuleDefService).updateResource(vXModuleDef);
Mockito.verify(daoManager).getXXModuleDef();
Mockito.verify(xModuleDefService).populateViewBean(xModuleDef);
Mockito.verify(daoManager).getXXUserPermission();
Mockito.verify(daoManager).getXXGroupPermission();
}
use of org.apache.ranger.view.VXUserPermission in project ranger by apache.
the class TestXUserMgr method test35createXUserPermission.
@Test
public void test35createXUserPermission() {
VXUserPermission vXUserPermission = vXUserPermission();
Mockito.when(xUserPermissionService.createResource(vXUserPermission)).thenReturn(vXUserPermission);
VXUserPermission dbUserPermission = xUserMgr.createXUserPermission(vXUserPermission);
Assert.assertNotNull(dbUserPermission);
Assert.assertEquals(dbUserPermission, vXUserPermission);
Assert.assertEquals(dbUserPermission.getId(), vXUserPermission.getId());
Assert.assertEquals(dbUserPermission.getOwner(), vXUserPermission.getOwner());
Assert.assertEquals(dbUserPermission.getUpdatedBy(), vXUserPermission.getUpdatedBy());
Assert.assertEquals(dbUserPermission.getUserName(), vXUserPermission.getUserName());
Assert.assertEquals(dbUserPermission.getCreateDate(), vXUserPermission.getCreateDate());
Assert.assertEquals(dbUserPermission.getIsAllowed(), vXUserPermission.getIsAllowed());
Assert.assertEquals(dbUserPermission.getModuleId(), vXUserPermission.getModuleId());
Assert.assertEquals(dbUserPermission.getUpdateDate(), vXUserPermission.getUpdateDate());
Assert.assertEquals(dbUserPermission.getUserId(), vXUserPermission.getUserId());
Mockito.verify(xUserPermissionService).createResource(vXUserPermission);
}
use of org.apache.ranger.view.VXUserPermission in project ranger by apache.
the class TestXUserMgr method test36getXUserPermission.
@Test
public void test36getXUserPermission() {
VXUserPermission vXUserPermission = vXUserPermission();
Mockito.when(xUserPermissionService.readResource(1L)).thenReturn(vXUserPermission);
VXUserPermission dbUserPermission = xUserMgr.getXUserPermission(1L);
Assert.assertNotNull(dbUserPermission);
Assert.assertEquals(dbUserPermission, vXUserPermission);
Assert.assertEquals(dbUserPermission.getId(), vXUserPermission.getId());
Assert.assertEquals(dbUserPermission.getOwner(), vXUserPermission.getOwner());
Assert.assertEquals(dbUserPermission.getUpdatedBy(), vXUserPermission.getUpdatedBy());
Assert.assertEquals(dbUserPermission.getUserName(), vXUserPermission.getUserName());
Assert.assertEquals(dbUserPermission.getCreateDate(), vXUserPermission.getCreateDate());
Assert.assertEquals(dbUserPermission.getIsAllowed(), vXUserPermission.getIsAllowed());
Assert.assertEquals(dbUserPermission.getModuleId(), vXUserPermission.getModuleId());
Assert.assertEquals(dbUserPermission.getUpdateDate(), vXUserPermission.getUpdateDate());
Assert.assertEquals(dbUserPermission.getUserId(), vXUserPermission.getUserId());
Mockito.verify(xUserPermissionService).readResource(1L);
}
use of org.apache.ranger.view.VXUserPermission in project ranger by apache.
the class XUserPermissionService method populateViewBean.
@Override
public VXUserPermission populateViewBean(XXUserPermission xObj) {
VXUserPermission vObj = super.populateViewBean(xObj);
XXPortalUser xPortalUser = daoManager.getXXPortalUser().getById(xObj.getUserId());
if (xPortalUser != null) {
vObj.setUserName(xPortalUser.getLoginId());
}
XXModuleDef xModuleDef = daoManager.getXXModuleDef().getById(xObj.getModuleId());
if (xModuleDef != null) {
vObj.setModuleName(xModuleDef.getModule());
}
return vObj;
}
Aggregations