@Test
public void test21deleteService() throws Exception {

	setup();
	XXPolicyDao xPolicyDao = Mockito.mock(XXPolicyDao.class);
	XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
	XXService xService = Mockito.mock(XXService.class);
	XXServiceConfigMapDao xServiceConfigMapDao = Mockito
			.mock(XXServiceConfigMapDao.class);
	XXPolicyLabelMapDao xPolicyLabelMapDao = Mockito.mock(XXPolicyLabelMapDao.class);
	XXSecurityZoneDao xSecurityZoneDao = Mockito.mock(XXSecurityZoneDao.class);
       RangerService rangerService = rangerService();
	RangerPolicy rangerPolicy = rangerPolicy();
	String name = "HDFS_1-1-20150316062453";
	List<XXPolicy> policiesList = new ArrayList<XXPolicy>();
	XXPolicy policy = new XXPolicy();
	policy.setAddedByUserId(Id);
	policy.setCreateTime(new Date());
	policy.setDescription("polcy test");
	policy.setGuid("");
	policy.setId(rangerService.getId());
	policy.setIsAuditEnabled(true);
	policy.setName("HDFS_1-1-20150316062453");
	policy.setService(rangerService.getId());
	policiesList.add(policy);
	List<Long> policiesIds = new ArrayList<Long>();
	policiesIds.add(Id);
	List<String> zonesNameList =new ArrayList<String>();
	List<XXTrxLog> trxLogList = new ArrayList<XXTrxLog>();
	XXTrxLog xTrxLogObj = new XXTrxLog();
	xTrxLogObj.setAction("delete");
	xTrxLogObj.setAddedByUserId(Id);
	xTrxLogObj.setAttributeName("User Role");
	xTrxLogObj.setCreateTime(new Date());
	xTrxLogObj.setId(Id);
	xTrxLogObj.setNewValue("admin");
	xTrxLogObj.setObjectClassType(0);
	xTrxLogObj.setObjectId(1L);
	xTrxLogObj.setParentObjectClassType(0);
	xTrxLogObj.setParentObjectId(Id);
	trxLogList.add(xTrxLogObj);
	List<XXPolicyItem> policyItemList = new ArrayList<XXPolicyItem>();
	XXPolicyItem policyItem = new XXPolicyItem();
	policyItem.setAddedByUserId(Id);
	policyItem.setCreateTime(new Date());
	policyItem.setDelegateAdmin(false);
	policyItem.setId(Id);
	policyItem.setOrder(1);
	policyItem.setPolicyId(Id);
	policyItem.setUpdatedByUserId(Id);
	policyItem.setUpdateTime(new Date());
	policyItemList.add(policyItem);
	List<XXPolicyItemCondition> policyItemConditionList = new ArrayList<XXPolicyItemCondition>();
	XXPolicyItemCondition policyItemCondition = new XXPolicyItemCondition();
	policyItemCondition.setAddedByUserId(Id);
	policyItemCondition.setCreateTime(new Date());
	policyItemCondition.setType(1L);
	policyItemCondition.setId(Id);
	policyItemCondition.setOrder(1);
	policyItemCondition.setPolicyItemId(Id);
	policyItemCondition.setUpdatedByUserId(Id);
	policyItemCondition.setUpdateTime(new Date());
	policyItemConditionList.add(policyItemCondition);
	List<XXPolicyItemGroupPerm> policyItemGroupPermList = new ArrayList<XXPolicyItemGroupPerm>();
	XXPolicyItemGroupPerm policyItemGroupPerm = new XXPolicyItemGroupPerm();
	policyItemGroupPerm.setAddedByUserId(Id);
	policyItemGroupPerm.setCreateTime(new Date());
	policyItemGroupPerm.setGroupId(Id);
	List<XXServiceConfigMap> xConfMapList = new ArrayList<XXServiceConfigMap>();
	XXServiceConfigMap xConfMap = new XXServiceConfigMap();
	xConfMap.setAddedByUserId(null);
	xConfMap.setConfigkey(name);
	xConfMap.setConfigvalue(name);
	xConfMap.setCreateTime(new Date());
	xConfMap.setServiceId(null);
	xConfMap.setId(Id);
	xConfMap.setUpdatedByUserId(null);
	xConfMap.setUpdateTime(new Date());
	xConfMapList.add(xConfMap);
	policyItemGroupPerm.setId(Id);
	policyItemGroupPerm.setOrder(1);
	policyItemGroupPerm.setPolicyItemId(Id);
	policyItemGroupPerm.setUpdatedByUserId(Id);
	policyItemGroupPerm.setUpdateTime(new Date());
	policyItemGroupPermList.add(policyItemGroupPerm);
	List<XXPolicyItemUserPerm> policyItemUserPermList = new ArrayList<XXPolicyItemUserPerm>();
	XXPolicyItemUserPerm policyItemUserPerm = new XXPolicyItemUserPerm();
	policyItemUserPerm.setAddedByUserId(Id);
	policyItemUserPerm.setCreateTime(new Date());
	policyItemUserPerm.setPolicyItemId(Id);
	policyItemUserPerm.setId(Id);
	policyItemUserPerm.setOrder(1);
	policyItemUserPerm.setUpdatedByUserId(Id);
	policyItemUserPerm.setUpdateTime(new Date());
	policyItemUserPermList.add(policyItemUserPerm);
	List<XXPolicyItemAccess> policyItemAccessList = new ArrayList<XXPolicyItemAccess>();
	XXPolicyItemAccess policyItemAccess = new XXPolicyItemAccess();
	policyItemAccess.setAddedByUserId(Id);
	policyItemAccess.setCreateTime(new Date());
	policyItemAccess.setPolicyitemid(Id);
	policyItemAccess.setId(Id);
	policyItemAccess.setOrder(1);
	policyItemAccess.setUpdatedByUserId(Id);
	policyItemAccess.setUpdateTime(new Date());
	policyItemAccessList.add(policyItemAccess);
	List<XXPolicyResource> policyResourceList = new ArrayList<XXPolicyResource>();
	XXPolicyResource policyResource = new XXPolicyResource();
	policyResource.setId(Id);
	policyResource.setCreateTime(new Date());
	policyResource.setAddedByUserId(Id);
	policyResource.setIsExcludes(false);
	policyResource.setIsRecursive(false);
	policyResource.setPolicyId(Id);
	policyResource.setResDefId(Id);
	policyResource.setUpdatedByUserId(Id);
	policyResource.setUpdateTime(new Date());
	policyResourceList.add(policyResource);
	List<XXPolicyResourceMap> policyResourceMapList = new ArrayList<XXPolicyResourceMap>();
	XXPolicyResourceMap policyResourceMap = new XXPolicyResourceMap();
	policyResourceMap.setAddedByUserId(Id);
	policyResourceMap.setCreateTime(new Date());
	policyResourceMap.setId(Id);
	policyResourceMap.setOrder(1);
	policyResourceMap.setResourceId(Id);
	policyResourceMap.setUpdatedByUserId(Id);
	policyResourceMap.setUpdateTime(new Date());
	policyResourceMap.setValue("1L");
	policyResourceMapList.add(policyResourceMap);
	List<XXServiceConfigDef> xServiceConfigDefList = new ArrayList<XXServiceConfigDef>();
	XXServiceConfigDef serviceConfigDefObj = new XXServiceConfigDef();
	serviceConfigDefObj.setId(Id);
	xServiceConfigDefList.add(serviceConfigDefObj);
	Mockito.when(daoManager.getXXSecurityZoneDao()).thenReturn(xSecurityZoneDao);
	Mockito.when(xSecurityZoneDao.findZonesByServiceName(rangerService.getName())).thenReturn(zonesNameList);
	Mockito.when(daoManager.getXXPolicy()).thenReturn(xPolicyDao);
	Mockito.when(xPolicyDao.findPolicyIdsByServiceId(rangerService.getId()))
			.thenReturn(policiesIds);
	Mockito.when(svcService.delete(rangerService)).thenReturn(true);
	Mockito.when(svcService.getTransactionLog(rangerService, 3))
			.thenReturn(trxLogList);
	Mockito.when(policyService.read(Id)).thenReturn(rangerPolicy);
	Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
	Mockito.when(svcService.getPopulatedViewObject(xService)).thenReturn(
			rangerService);
	Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
	Mockito.when(xServiceDao.getById(Id)).thenReturn(xService);
	Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
	Mockito.when(xServiceDao.getById(rangerService.getId())).thenReturn(
			xService);
	Mockito.when(daoManager.getXXServiceConfigMap()).thenReturn(
			xServiceConfigMapDao);
	Mockito.when(
			xServiceConfigMapDao.findByServiceId(rangerService.getId()))
			.thenReturn(xConfMapList);
	Mockito.when(daoManager.getXXPolicyLabelMap()).thenReturn(xPolicyLabelMapDao);
	Mockito.when(xPolicyLabelMapDao.findByPolicyId(rangerPolicy.getId())).thenReturn(ListUtils.EMPTY_LIST);
	Mockito.when(!bizUtil.hasAccess(xService, null)).thenReturn(true);
       serviceDBStore.deleteService(Id);
	Mockito.verify(svcService).delete(rangerService);
}