use of org.apache.ranger.view.VXModuleDef in project ranger by apache.
the class TestXUserMgr method test32getXModuleDefPermission.
@Test
public void test32getXModuleDefPermission() {
VXModuleDef vXModuleDef = vXModuleDef();
Mockito.when(xModuleDefService.readResource(1L)).thenReturn(vXModuleDef);
VXModuleDef dbMuduleDef = xUserMgr.getXModuleDefPermission(1L);
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).readResource(1L);
}
use of org.apache.ranger.view.VXModuleDef in project ranger by apache.
the class TestXUserMgr method vXModuleDef.
private VXModuleDef vXModuleDef() {
VXUserPermission userPermission = vXUserPermission();
List<VXUserPermission> userPermList = new ArrayList<VXUserPermission>();
userPermList.add(userPermission);
VXGroupPermission groupPermission = vXGroupPermission();
List<VXGroupPermission> groupPermList = new ArrayList<VXGroupPermission>();
groupPermList.add(groupPermission);
VXModuleDef vxModuleDef = new VXModuleDef();
vxModuleDef.setAddedById(userId);
vxModuleDef.setCreateDate(new Date());
vxModuleDef.setCreateTime(new Date());
vxModuleDef.setId(userId);
vxModuleDef.setModule("Policy manager");
vxModuleDef.setOwner("admin");
vxModuleDef.setUpdateDate(new Date());
vxModuleDef.setUpdatedBy("admin");
vxModuleDef.setUpdatedById(userId);
vxModuleDef.setUpdateTime(new Date());
vxModuleDef.setUrl("/policy manager");
vxModuleDef.setUserPermList(userPermList);
vxModuleDef.setGroupPermList(groupPermList);
return vxModuleDef;
}
use of org.apache.ranger.view.VXModuleDef in project ranger by apache.
the class TestXUserREST method createVXModuleDef.
private VXModuleDef createVXModuleDef() {
VXModuleDef testVXModuleDef = new VXModuleDef();
testVXModuleDef.setAddedById(id);
testVXModuleDef.setCreateDate(new Date());
testVXModuleDef.setCreateTime(new Date());
VXGroupPermission testVXGroupPermission = createVXGroupPermission();
List<VXGroupPermission> groupPermList = new ArrayList<VXGroupPermission>();
groupPermList.add(testVXGroupPermission);
testVXModuleDef.setGroupPermList(groupPermList);
testVXModuleDef.setId(id);
testVXModuleDef.setModule("testModule");
testVXModuleDef.setOwner("Admin");
testVXModuleDef.setUpdateDate(new Date());
testVXModuleDef.setUpdatedBy("Admin");
testVXModuleDef.setUpdatedById(id);
testVXModuleDef.setUpdateTime(new Date());
testVXModuleDef.setUrl("testUrrl");
List<VXUserPermission> userPermList = new ArrayList<VXUserPermission>();
VXUserPermission testVXUserPermission = createVXUserPermission();
userPermList.add(testVXUserPermission);
testVXModuleDef.setUserPermList(userPermList);
return testVXModuleDef;
}
use of org.apache.ranger.view.VXModuleDef in project ranger by apache.
the class TestXUserREST method test77getXModuleDefPermission.
@Test
public void test77getXModuleDefPermission() {
VXModuleDef testVXModuleDef = createVXModuleDef();
Mockito.when(xUserMgr.getXModuleDefPermission(testVXModuleDef.getId())).thenReturn(testVXModuleDef);
VXModuleDef retVxModuleDef = xUserRest.getXModuleDefPermission(testVXModuleDef.getId());
assertNotNull(retVxModuleDef);
assertEquals(testVXModuleDef.getId(), retVxModuleDef.getId());
assertEquals(testVXModuleDef.getOwner(), retVxModuleDef.getOwner());
Mockito.verify(xUserMgr).getXModuleDefPermission(testVXModuleDef.getId());
}
use of org.apache.ranger.view.VXModuleDef in project ranger by apache.
the class XModuleDefService method populateViewBean.
@Override
public VXModuleDef populateViewBean(XXModuleDef xObj) {
VXModuleDef vModuleDef = super.populateViewBean(xObj);
Map<Long, XXUser> xXPortalUserIdXXUserMap = xUserService.getXXPortalUserIdXXUserMap();
Map<Long, XXGroup> xXGroupMap = xGroupService.getXXGroupIdXXGroupMap();
List<VXUserPermission> vXUserPermissionList = new ArrayList<VXUserPermission>();
List<VXGroupPermission> vXGroupPermissionList = new ArrayList<VXGroupPermission>();
List<XXUserPermission> xuserPermissionList = daoManager.getXXUserPermission().findByModuleId(xObj.getId(), false);
List<XXGroupPermission> xgroupPermissionList = daoManager.getXXGroupPermission().findByModuleId(xObj.getId(), false);
if (CollectionUtils.isEmpty(xXPortalUserIdXXUserMap)) {
for (XXUserPermission xUserPerm : xuserPermissionList) {
VXUserPermission vXUserPerm = xUserPermService.populateViewBean(xUserPerm);
vXUserPermissionList.add(vXUserPerm);
}
} else {
vXUserPermissionList = xUserPermService.getPopulatedVXUserPermissionList(xuserPermissionList, xXPortalUserIdXXUserMap, vModuleDef);
}
if (CollectionUtils.isEmpty(xXGroupMap)) {
for (XXGroupPermission xGrpPerm : xgroupPermissionList) {
VXGroupPermission vXGrpPerm = xGrpPermService.populateViewBean(xGrpPerm);
vXGroupPermissionList.add(vXGrpPerm);
}
} else {
vXGroupPermissionList = xGrpPermService.getPopulatedVXGroupPermissionList(xgroupPermissionList, xXGroupMap, vModuleDef);
}
vModuleDef.setUserPermList(vXUserPermissionList);
vModuleDef.setGroupPermList(vXGroupPermissionList);
return vModuleDef;
}
Aggregations