use of org.apache.ranger.entity.XXPolicy in project ranger by apache.
the class PatchForKafkaServiceDefUpdate_J10025 method createDefaultPolicyForNewResources.
private void createDefaultPolicyForNewResources() {
logger.info("==> createDefaultPolicyForNewResources ");
XXPortalUser xxPortalUser = daoMgr.getXXPortalUser().findByLoginId(LOGIN_ID_ADMIN);
Long currentUserId = xxPortalUser.getId();
XXServiceDef xXServiceDefObj = daoMgr.getXXServiceDef().findByName(EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_KAFKA_NAME);
if (xXServiceDefObj == null) {
logger.debug("ServiceDef not fount with name :" + EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_KAFKA_NAME);
return;
}
Long xServiceDefId = xXServiceDefObj.getId();
List<XXService> xxServices = daoMgr.getXXService().findByServiceDefId(xServiceDefId);
for (XXService xxService : xxServices) {
int resourceMapOrder = 0;
for (String newResource : POLICY_NAMES) {
XXPolicy xxPolicy = new XXPolicy();
xxPolicy.setName(newResource);
xxPolicy.setDescription(newResource);
xxPolicy.setService(xxService.getId());
xxPolicy.setPolicyPriority(RangerPolicy.POLICY_PRIORITY_NORMAL);
xxPolicy.setIsAuditEnabled(Boolean.TRUE);
xxPolicy.setIsEnabled(Boolean.TRUE);
xxPolicy.setPolicyType(RangerPolicy.POLICY_TYPE_ACCESS);
xxPolicy.setGuid(guidUtil.genGUID());
xxPolicy.setAddedByUserId(currentUserId);
xxPolicy.setUpdatedByUserId(currentUserId);
RangerPolicy rangerPolicy = getRangerPolicy(newResource, xxPortalUser, xxService);
xxPolicy.setPolicyText(JsonUtils.objectToJson(rangerPolicy));
xxPolicy.setResourceSignature(rangerPolicy.getResourceSignature());
xxPolicy.setZoneId(1L);
XXPolicy createdPolicy = daoMgr.getXXPolicy().create(xxPolicy);
XXPolicyItem xxPolicyItem = new XXPolicyItem();
xxPolicyItem.setIsEnabled(Boolean.TRUE);
xxPolicyItem.setDelegateAdmin(Boolean.TRUE);
xxPolicyItem.setItemType(0);
xxPolicyItem.setOrder(0);
xxPolicyItem.setAddedByUserId(currentUserId);
xxPolicyItem.setUpdatedByUserId(currentUserId);
xxPolicyItem.setPolicyId(createdPolicy.getId());
XXPolicyItem createdXXPolicyItem = daoMgr.getXXPolicyItem().create(xxPolicyItem);
List<String> accessTypes = getAccessTypes();
for (int i = 0; i < accessTypes.size(); i++) {
XXAccessTypeDef xAccTypeDef = daoMgr.getXXAccessTypeDef().findByNameAndServiceId(accessTypes.get(i), xxPolicy.getService());
if (xAccTypeDef == null) {
throw new RuntimeException(accessTypes.get(i) + ": is not a valid access-type. policy='" + xxPolicy.getName() + "' service='" + xxPolicy.getService() + "'");
}
XXPolicyItemAccess xPolItemAcc = new XXPolicyItemAccess();
xPolItemAcc.setIsAllowed(Boolean.TRUE);
xPolItemAcc.setType(xAccTypeDef.getId());
xPolItemAcc.setOrder(i);
xPolItemAcc.setAddedByUserId(currentUserId);
xPolItemAcc.setUpdatedByUserId(currentUserId);
xPolItemAcc.setPolicyitemid(createdXXPolicyItem.getId());
daoMgr.getXXPolicyItemAccess().create(xPolItemAcc);
}
for (int i = 0; i < DEFAULT_POLICY_USERS.size(); i++) {
String user = DEFAULT_POLICY_USERS.get(i);
if (StringUtils.isBlank(user)) {
continue;
}
XXUser xxUser = daoMgr.getXXUser().findByUserName(user);
if (xxUser == null) {
throw new RuntimeException(user + ": user does not exist. policy='" + xxPolicy.getName() + "' service='" + xxPolicy.getService() + "' user='" + user + "'");
}
XXPolicyItemUserPerm xUserPerm = new XXPolicyItemUserPerm();
xUserPerm.setUserId(xxUser.getId());
xUserPerm.setPolicyItemId(createdXXPolicyItem.getId());
xUserPerm.setOrder(i);
xUserPerm.setAddedByUserId(currentUserId);
xUserPerm.setUpdatedByUserId(currentUserId);
daoMgr.getXXPolicyItemUserPerm().create(xUserPerm);
}
String policyResourceName = KAFKA_RESOURCE_CLUSTER;
if ("all - delegationtoken".equals(newResource)) {
policyResourceName = KAFKA_RESOURCE_DELEGATIONTOKEN;
}
XXResourceDef xResDef = daoMgr.getXXResourceDef().findByNameAndPolicyId(policyResourceName, createdPolicy.getId());
if (xResDef == null) {
throw new RuntimeException(policyResourceName + ": is not a valid resource-type. policy='" + createdPolicy.getName() + "' service='" + createdPolicy.getService() + "'");
}
XXPolicyResource xPolRes = new XXPolicyResource();
xPolRes.setAddedByUserId(currentUserId);
xPolRes.setUpdatedByUserId(currentUserId);
xPolRes.setIsExcludes(Boolean.FALSE);
xPolRes.setIsRecursive(Boolean.FALSE);
xPolRes.setPolicyId(createdPolicy.getId());
xPolRes.setResDefId(xResDef.getId());
xPolRes = daoMgr.getXXPolicyResource().create(xPolRes);
XXPolicyResourceMap xPolResMap = new XXPolicyResourceMap();
xPolResMap.setResourceId(xPolRes.getId());
xPolResMap.setValue("*");
xPolResMap.setOrder(resourceMapOrder);
xPolResMap.setAddedByUserId(currentUserId);
xPolResMap.setUpdatedByUserId(currentUserId);
daoMgr.getXXPolicyResourceMap().create(xPolResMap);
resourceMapOrder++;
logger.info("Creating policy for service id : " + xxService.getId());
}
}
logger.info("<== createDefaultPolicyForNewResources ");
}
use of org.apache.ranger.entity.XXPolicy in project ranger by apache.
the class PatchForAtlasResourceAndAccessTypeUpdate_J10016 method createDefaultPolicyToExistingService.
private void createDefaultPolicyToExistingService() {
logger.info("==> createDefaultPolicyToExistingService ");
XXPortalUser xxPortalUser = daoMgr.getXXPortalUser().findByLoginId(LOGIN_ID_ADMIN);
Long currentUserId = xxPortalUser.getId();
XXServiceDef xXServiceDefObj = daoMgr.getXXServiceDef().findByName(EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_ATLAS_NAME);
if (xXServiceDefObj == null) {
logger.debug("ServiceDef not fount with name :" + EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_ATLAS_NAME);
return;
}
Long xServiceDefId = xXServiceDefObj.getId();
List<XXService> xxServices = daoMgr.getXXService().findByServiceDefId(xServiceDefId);
for (XXService xxService : xxServices) {
List<XXPolicy> xxPolicies = daoMgr.getXXPolicy().findByServiceId(xxService.getId());
Boolean isPolicyPresent = true;
for (XXPolicy xxPolicy : xxPolicies) {
if (!xxPolicy.getName().equalsIgnoreCase(RESOURCE_DEF_NAME)) {
isPolicyPresent = false;
} else {
isPolicyPresent = true;
break;
}
}
if (!isPolicyPresent) {
XXPolicy xxPolicy = new XXPolicy();
xxPolicy.setName(RESOURCE_DEF_NAME);
xxPolicy.setDescription(RESOURCE_DEF_NAME);
xxPolicy.setService(xxService.getId());
xxPolicy.setPolicyPriority(RangerPolicy.POLICY_PRIORITY_NORMAL);
xxPolicy.setIsAuditEnabled(Boolean.TRUE);
xxPolicy.setIsEnabled(Boolean.TRUE);
xxPolicy.setPolicyType(RangerPolicy.POLICY_TYPE_ACCESS);
xxPolicy.setGuid(guidUtil.genGUID());
xxPolicy.setAddedByUserId(currentUserId);
xxPolicy.setUpdatedByUserId(currentUserId);
RangerPolicy rangerPolicy = new RangerPolicy();
RangerPolicyResourceSignature resourceSignature = new RangerPolicyResourceSignature(rangerPolicy);
xxPolicy.setResourceSignature(resourceSignature.getSignature());
xxPolicy.setZoneId(1L);
XXPolicy createdPolicy = daoMgr.getXXPolicy().create(xxPolicy);
XXPolicyItem xxPolicyItem = new XXPolicyItem();
xxPolicyItem.setIsEnabled(Boolean.TRUE);
xxPolicyItem.setDelegateAdmin(Boolean.TRUE);
xxPolicyItem.setItemType(0);
xxPolicyItem.setOrder(0);
xxPolicyItem.setAddedByUserId(currentUserId);
xxPolicyItem.setUpdatedByUserId(currentUserId);
xxPolicyItem.setPolicyId(createdPolicy.getId());
XXPolicyItem createdXXPolicyItem = daoMgr.getXXPolicyItem().create(xxPolicyItem);
List<String> accessTypes = Arrays.asList("add-relationship", "update-relationship", "remove-relationship");
for (int i = 0; i < accessTypes.size(); i++) {
XXAccessTypeDef xAccTypeDef = daoMgr.getXXAccessTypeDef().findByNameAndServiceId(accessTypes.get(i), xxPolicy.getService());
if (xAccTypeDef == null) {
throw new RuntimeException(accessTypes.get(i) + ": is not a valid access-type. policy='" + xxPolicy.getName() + "' service='" + xxPolicy.getService() + "'");
}
XXPolicyItemAccess xPolItemAcc = new XXPolicyItemAccess();
xPolItemAcc.setIsAllowed(Boolean.TRUE);
xPolItemAcc.setType(xAccTypeDef.getId());
xPolItemAcc.setOrder(i);
xPolItemAcc.setAddedByUserId(currentUserId);
xPolItemAcc.setUpdatedByUserId(currentUserId);
xPolItemAcc.setPolicyitemid(createdXXPolicyItem.getId());
daoMgr.getXXPolicyItemAccess().create(xPolItemAcc);
}
List<String> groups = Arrays.asList(GROUP_PUBLIC);
for (int i = 0; i < groups.size(); i++) {
String group = groups.get(i);
if (StringUtils.isBlank(group)) {
continue;
}
XXGroup xGrp = daoMgr.getXXGroup().findByGroupName(group);
if (xGrp == null) {
throw new RuntimeException(group + ": group does not exist. policy='" + xxPolicy.getName() + "' service='" + xxPolicy.getService() + "' group='" + group + "'");
}
XXPolicyItemGroupPerm xGrpPerm = new XXPolicyItemGroupPerm();
xGrpPerm.setGroupId(xGrp.getId());
xGrpPerm.setPolicyItemId(createdXXPolicyItem.getId());
xGrpPerm.setOrder(i);
xGrpPerm.setAddedByUserId(currentUserId);
xGrpPerm.setUpdatedByUserId(currentUserId);
daoMgr.getXXPolicyItemGroupPerm().create(xGrpPerm);
}
for (int i = 0; i < ATLAS_RESOURCES.size(); i++) {
XXResourceDef xResDef = daoMgr.getXXResourceDef().findByNameAndPolicyId(ATLAS_RESOURCES.get(i), createdPolicy.getId());
if (xResDef == null) {
throw new RuntimeException(ATLAS_RESOURCES.get(i) + ": is not a valid resource-type. policy='" + createdPolicy.getName() + "' service='" + createdPolicy.getService() + "'");
}
XXPolicyResource xPolRes = new XXPolicyResource();
xPolRes.setAddedByUserId(currentUserId);
xPolRes.setUpdatedByUserId(currentUserId);
xPolRes.setIsExcludes(Boolean.FALSE);
xPolRes.setIsRecursive(Boolean.FALSE);
xPolRes.setPolicyId(createdPolicy.getId());
xPolRes.setResDefId(xResDef.getId());
xPolRes = daoMgr.getXXPolicyResource().create(xPolRes);
XXPolicyResourceMap xPolResMap = new XXPolicyResourceMap();
xPolResMap.setResourceId(xPolRes.getId());
xPolResMap.setValue("*");
xPolResMap.setOrder(i);
xPolResMap.setAddedByUserId(currentUserId);
xPolResMap.setUpdatedByUserId(currentUserId);
daoMgr.getXXPolicyResourceMap().create(xPolResMap);
}
logger.info("Creating policy for service id : " + xxService.getId());
}
}
logger.info("<== createDefaultPolicyToExistingService ");
}
use of org.apache.ranger.entity.XXPolicy in project ranger by apache.
the class PatchForAtlasToAddEntityLabelAndBusinessMetadata_J10034 method createDefaultPolicyForEntityLabelAndEntityBusinessMetadata.
private void createDefaultPolicyForEntityLabelAndEntityBusinessMetadata() throws Exception {
logger.info("==> createDefaultPolicyForEntityLabelAndEntityBusinessMetadata ");
XXServiceDef xXServiceDefObj = daoMgr.getXXServiceDef().findByName(EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_ATLAS_NAME);
if (xXServiceDefObj == null) {
logger.debug("ServiceDef not found with name :" + EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_ATLAS_NAME);
return;
}
Long xServiceDefId = xXServiceDefObj.getId();
List<XXService> xxServices = daoMgr.getXXService().findByServiceDefId(xServiceDefId);
for (XXService xxService : xxServices) {
List<XXPolicy> xxPolicies = daoMgr.getXXPolicy().findByServiceId(xxService.getId());
Boolean isEntityLabelPolicyPresent = false;
Boolean isEntityBusinessMetadataPolicyPresent = false;
for (XXPolicy xxPolicy : xxPolicies) {
if (xxPolicy.getName().equalsIgnoreCase(RESOURCE_DEF_ENTITY_LABEL)) {
isEntityLabelPolicyPresent = true;
}
if (xxPolicy.getName().equalsIgnoreCase(RESOURCE_DEF_ENTITY_BUSINESS_METADATA)) {
isEntityBusinessMetadataPolicyPresent = true;
}
if (isEntityLabelPolicyPresent && isEntityBusinessMetadataPolicyPresent) {
break;
}
}
if (!isEntityLabelPolicyPresent) {
List<String> accessTypesLabel = Arrays.asList("entity-add-label", "entity-remove-label");
List<String> accessTypesReadEntity = Arrays.asList("entity-read");
createDefaultRangerPolicy(xServiceDefId, xxService, RESOURCE_DEF_ENTITY_LABEL, accessTypesLabel, accessTypesReadEntity, ATLAS_RESOURCE_LABEL);
}
if (!isEntityBusinessMetadataPolicyPresent) {
List<String> accessTypesBusinessMetadata = Arrays.asList("entity-update-business-metadata");
List<String> accessTypesReadEntity = Arrays.asList("entity-read");
createDefaultRangerPolicy(xServiceDefId, xxService, RESOURCE_DEF_ENTITY_BUSINESS_METADATA, accessTypesBusinessMetadata, accessTypesReadEntity, ATLAS_RESOURCE_BUSINESS_METADATA);
}
}
logger.info("<== createDefaultPolicyForEntityLabelAndEntityBusinessMetadata ");
}
use of org.apache.ranger.entity.XXPolicy in project ranger by apache.
the class TestXUserMgr method test126DeleteXGroup.
@Test
public void test126DeleteXGroup() {
destroySession();
setup();
boolean force = true;
VXGroup vXGroup = vxGroup();
VXPermMapList vXPermMapList = new VXPermMapList();
VXPermMap vXPermMap1 = getVXPermMap();
List<VXPermMap> vXPermMaps = new ArrayList<VXPermMap>();
vXPermMaps.add(vXPermMap1);
vXPermMapList.setVXPermMaps(vXPermMaps);
VXAuditMapList vXAuditMapList = new VXAuditMapList();
List<VXAuditMap> vXAuditMaps = new ArrayList<VXAuditMap>();
VXAuditMap vXAuditMap = getVXAuditMap();
vXAuditMaps.add(vXAuditMap);
vXAuditMapList.setVXAuditMaps(vXAuditMaps);
List<XXGroupGroup> xXGroupGroups = new ArrayList<XXGroupGroup>();
XXGroupGroup xXGroupGroup = xxGroupGroup();
xXGroupGroups.add(xXGroupGroup);
List<XXGroupPermission> xXGroupPermissions = new ArrayList<XXGroupPermission>();
XXGroupPermission xGroupPermissionObj = xxGroupPermission();
xXGroupPermissions.add(xGroupPermissionObj);
List<XXPolicy> xXPolicyList = new ArrayList<XXPolicy>();
XXPolicy xXPolicy = getXXPolicy();
xXPolicyList.add(xXPolicy);
List<XXResource> xResourceList = new ArrayList<XXResource>();
XXResource xXResource = new XXResource();
xXResource.setId(userId);
xXResource.setName("hadoopdev");
xXResource.setIsRecursive(AppConstants.BOOL_TRUE);
xXResource.setResourceStatus(AppConstants.STATUS_ENABLED);
xResourceList.add(xXResource);
XXSecurityZoneRefGroup xZoneAdminGroup = new XXSecurityZoneRefGroup();
xZoneAdminGroup.setZoneId(2L);
xZoneAdminGroup.setGroupId(vXGroup.getId());
xZoneAdminGroup.setGroupName(vXGroup.getName());
xZoneAdminGroup.setGroupType(1);
List<XXSecurityZoneRefGroup> zoneSecRefGroup = new ArrayList<XXSecurityZoneRefGroup>();
zoneSecRefGroup.add(xZoneAdminGroup);
XXSecurityZoneRefGroupDao zoneSecRefGroupDao = Mockito.mock(XXSecurityZoneRefGroupDao.class);
Mockito.when(daoManager.getXXSecurityZoneRefGroup()).thenReturn(zoneSecRefGroupDao);
Mockito.when(zoneSecRefGroupDao.findByGroupId(userId)).thenReturn(zoneSecRefGroup);
RangerSecurityZone securityZone = new RangerSecurityZone();
securityZone.setId(2L);
securityZone.setName("sz1");
XXSecurityZone xxSecurityZone = new XXSecurityZone();
xxSecurityZone.setId(2L);
xxSecurityZone.setName("sz1");
XXSecurityZoneDao xXSecurityZoneDao = Mockito.mock(XXSecurityZoneDao.class);
Mockito.when(daoManager.getXXSecurityZoneDao()).thenReturn(xXSecurityZoneDao);
Mockito.when(xXSecurityZoneDao.getById(xZoneAdminGroup.getZoneId())).thenReturn(xxSecurityZone);
List<XXRoleRefGroup> roleRefGroup = new ArrayList<XXRoleRefGroup>();
XXRoleRefGroup xRoleRefGroup = new XXRoleRefGroup();
xRoleRefGroup.setRoleId(userId);
xRoleRefGroup.setGroupId(userId);
xRoleRefGroup.setGroupName(groupName);
xRoleRefGroup.setGroupType(0);
roleRefGroup.add(xRoleRefGroup);
XXRole xRole = new XXRole();
xRole.setId(userId);
xRole.setName("Role1");
VXResponse vXResponse = new VXResponse();
vXResponse.setStatusCode(HttpServletResponse.SC_BAD_REQUEST);
vXResponse.setMsgDesc("Can Not Delete Group '" + vXGroup.getName().trim() + "' as its present in " + RangerConstants.ROLE_FIELD);
Mockito.when(restErrorUtil.generateRESTException((VXResponse) Mockito.any())).thenThrow(new WebApplicationException());
thrown.expect(WebApplicationException.class);
xUserMgr.deleteXGroup(vXGroup.getId(), force);
}
use of org.apache.ranger.entity.XXPolicy in project ranger by apache.
the class TestXUserMgr method test20DeleteXGroup.
@Test
public void test20DeleteXGroup() {
setup();
boolean force = true;
VXGroup vXGroup = vxGroup();
XXGroupDao xXGroupDao = Mockito.mock(XXGroupDao.class);
XXUserDao xXUserDao = Mockito.mock(XXUserDao.class);
VXUser vxUser = vxUser();
XXUser xXUser = xxUser(vxUser);
Mockito.when(daoManager.getXXUser()).thenReturn(xXUserDao);
Mockito.when(xXUserDao.getById(xXUser.getId())).thenReturn(xXUser);
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);
VXGroupUserList vxGroupUserList = vxGroupUserList();
XXGroupUserDao xGroupUserDao = Mockito.mock(XXGroupUserDao.class);
Mockito.when(xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito.any())).thenReturn(vxGroupUserList);
Mockito.when(daoManager.getXXGroupUser()).thenReturn(xGroupUserDao);
VXPermMapList vXPermMapList = new VXPermMapList();
VXPermMap vXPermMap1 = getVXPermMap();
List<VXPermMap> vXPermMaps = new ArrayList<VXPermMap>();
vXPermMaps.add(vXPermMap1);
vXPermMapList.setVXPermMaps(vXPermMaps);
XXPermMapDao xXPermMapDao = Mockito.mock(XXPermMapDao.class);
Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria) Mockito.any())).thenReturn(vXPermMapList);
Mockito.when(daoManager.getXXPermMap()).thenReturn(xXPermMapDao);
VXAuditMapList vXAuditMapList = new VXAuditMapList();
List<VXAuditMap> vXAuditMaps = new ArrayList<VXAuditMap>();
VXAuditMap vXAuditMap = getVXAuditMap();
vXAuditMaps.add(vXAuditMap);
vXAuditMapList.setVXAuditMaps(vXAuditMaps);
XXAuditMapDao xXAuditMapDao = Mockito.mock(XXAuditMapDao.class);
Mockito.when(xAuditMapService.searchXAuditMaps((SearchCriteria) Mockito.any())).thenReturn(vXAuditMapList);
Mockito.when(daoManager.getXXAuditMap()).thenReturn(xXAuditMapDao);
XXGroupGroupDao xXGroupGroupDao = Mockito.mock(XXGroupGroupDao.class);
List<XXGroupGroup> xXGroupGroups = new ArrayList<XXGroupGroup>();
XXGroupGroup xXGroupGroup = xxGroupGroup();
xXGroupGroups.add(xXGroupGroup);
Mockito.when(daoManager.getXXGroupGroup()).thenReturn(xXGroupGroupDao);
Mockito.when(xXGroupGroupDao.findByGroupId(userId)).thenReturn(xXGroupGroups);
XXGroupPermissionDao xXGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class);
Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xXGroupPermissionDao);
List<XXGroupPermission> xXGroupPermissions = new ArrayList<XXGroupPermission>();
XXGroupPermission xGroupPermissionObj = xxGroupPermission();
xXGroupPermissions.add(xGroupPermissionObj);
Mockito.when(xXGroupPermissionDao.findByGroupId(vXGroup.getId())).thenReturn(xXGroupPermissions);
XXPolicyDao xXPolicyDao = Mockito.mock(XXPolicyDao.class);
List<XXPolicy> xXPolicyList = new ArrayList<XXPolicy>();
XXPolicy xXPolicy = getXXPolicy();
xXPolicyList.add(xXPolicy);
Mockito.when(daoManager.getXXPolicy()).thenReturn(xXPolicyDao);
Mockito.when(xXPolicyDao.findByGroupId(userId)).thenReturn(xXPolicyList);
List<XXResource> xResourceList = new ArrayList<XXResource>();
XXResource xXResource = new XXResource();
xXResource.setId(userId);
xXResource.setName("hadoopdev");
xXResource.setIsRecursive(AppConstants.BOOL_TRUE);
xXResource.setResourceStatus(AppConstants.STATUS_ENABLED);
xResourceList.add(xXResource);
XXResourceDao xxResourceDao = Mockito.mock(XXResourceDao.class);
Mockito.when(daoManager.getXXResource()).thenReturn(xxResourceDao);
Mockito.when(xxResourceDao.getById(Mockito.anyLong())).thenReturn(xXResource);
RangerPolicy rangerPolicy = rangerPolicy();
Mockito.when(policyService.getPopulatedViewObject(xXPolicy)).thenReturn(rangerPolicy);
XXModuleDefDao xModuleDefDao = Mockito.mock(XXModuleDefDao.class);
Mockito.when(daoManager.getXXModuleDef()).thenReturn(xModuleDefDao);
XXModuleDef xModuleDef = xxModuleDef();
Mockito.when(xModuleDefDao.findByModuleId(Mockito.anyLong())).thenReturn(xModuleDef);
List<XXSecurityZoneRefGroup> zoneSecRefGroup = new ArrayList<XXSecurityZoneRefGroup>();
XXSecurityZoneRefGroupDao zoneSecRefGroupDao = Mockito.mock(XXSecurityZoneRefGroupDao.class);
Mockito.when(daoManager.getXXSecurityZoneRefGroup()).thenReturn(zoneSecRefGroupDao);
Mockito.when(zoneSecRefGroupDao.findByGroupId(userId)).thenReturn(zoneSecRefGroup);
List<XXRoleRefGroup> roleRefGroup = new ArrayList<XXRoleRefGroup>();
XXRoleRefGroupDao roleRefGroupDao = Mockito.mock(XXRoleRefGroupDao.class);
Mockito.when(daoManager.getXXRoleRefGroup()).thenReturn(roleRefGroupDao);
Mockito.when(roleRefGroupDao.findByGroupId(userId)).thenReturn(roleRefGroup);
xUserMgr.deleteXGroup(vXGroup.getId(), force);
}
Aggregations