use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class ServiceDBStore method getPaginatedServicePolicies.
public PList<RangerPolicy> getPaginatedServicePolicies(String serviceName, SearchFilter filter) throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug("==> ServiceDBStore.getPaginatedServicePolicies(" + serviceName + ")");
}
if (filter == null) {
filter = new SearchFilter();
}
filter.setParam(SearchFilter.SERVICE_NAME, serviceName);
PList<RangerPolicy> ret = getPaginatedPolicies(filter);
if (LOG.isDebugEnabled()) {
LOG.debug("<== ServiceDBStore.getPaginatedServicePolicies(" + serviceName + "): count=" + ((ret == null) ? 0 : ret.getListSize()));
}
return ret;
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestRangerServiceDefServiceBase method test21searchRangerServiceDefs.
@Test
public void test21searchRangerServiceDefs() {
setup();
SearchFilter searchFilter = new SearchFilter();
searchFilter.setParam(SearchFilter.POLICY_NAME, "policyName");
searchFilter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
BaseDao baseDao = Mockito.mock(BaseDao.class);
Mockito.when(daoManager.getDaoForClassName(Mockito.anyString())).thenReturn(baseDao);
RangerServiceDefList dbRangerServiceDefList = rangerServiceDefService.searchRangerServiceDefs(searchFilter);
Assert.assertNotNull(dbRangerServiceDefList);
Mockito.verify(daoManager).getDaoForClassName(Mockito.anyString());
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestRangerServiceServiceBase method test3searchRangerServices.
@Test
public void test3searchRangerServices() {
SearchFilter searchFilter = new SearchFilter();
searchFilter.setParam(SearchFilter.POLICY_NAME, "policyName");
searchFilter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
BaseDao baseDao = Mockito.mock(BaseDao.class);
Mockito.when(daoManager.getDaoForClassName(Mockito.anyString())).thenReturn(baseDao);
RangerServiceList dbRangerServiceList = rangerServiceService.searchRangerServices(searchFilter);
Assert.assertNotNull(dbRangerServiceList);
Mockito.verify(daoManager).getDaoForClassName(Mockito.anyString());
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestAssetREST method testSearchXAssets.
@Test
public void testSearchXAssets() {
RangerService rangerService1 = rangerService(Id);
RangerService rangerService2 = rangerService(9L);
VXAsset vXAsset1 = vXAsset(Id);
VXAsset vXAsset2 = vXAsset(9L);
VXAssetList expectedVXAsset = new VXAssetList();
List<VXAsset> vXAsset = Arrays.asList(vXAsset1, vXAsset2);
expectedVXAsset.setVXAssets(vXAsset);
List<RangerService> services = Arrays.asList(rangerService1, rangerService2);
SearchFilter searchFilter = new SearchFilter();
Mockito.when(searchUtil.getSearchFilterFromLegacyRequestForRepositorySearch(request, null)).thenReturn(searchFilter);
Mockito.when(serviceREST.getServices(searchFilter)).thenReturn(services);
Mockito.when(serviceUtil.toVXAsset(rangerService1)).thenReturn(vXAsset1);
Mockito.when(serviceUtil.toVXAsset(rangerService2)).thenReturn(vXAsset2);
VXAssetList vXAssetList = assetREST.searchXAssets(request);
Assert.assertNotNull(vXAssetList);
Assert.assertEquals(expectedVXAsset.getVXAssets(), vXAssetList.getVXAssets());
Mockito.verify(searchUtil).getSearchFilterFromLegacyRequestForRepositorySearch(request, null);
Mockito.verify(serviceREST).getServices(searchFilter);
Mockito.verify(serviceUtil, Mockito.times(1)).toVXAsset(rangerService1);
Mockito.verify(serviceUtil, Mockito.times(1)).toVXAsset(rangerService2);
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestAssetREST method testCountXResource.
@Test
public void testCountXResource() {
List<RangerPolicy> rangerPolicyList = new ArrayList<RangerPolicy>();
List<VXResource> vXResourcesList = new ArrayList<VXResource>();
RangerService rangerService = rangerService(Id);
long i;
for (i = 1; i <= 2; i++) {
RangerPolicy rangerPolicy = rangerPolicy(i);
VXResource vXresource = vxResource(i);
rangerPolicyList.add(rangerPolicy);
vXResourcesList.add(vXresource);
Mockito.when(serviceUtil.toVXResource(rangerPolicy, rangerService)).thenReturn(vXresource);
}
VXLong expectedXResouce = new VXLong();
expectedXResouce.setValue(2l);
Mockito.when(serviceREST.getServiceByName(rangerPolicyList.get(0).getService())).thenReturn(rangerService);
VXResourceList expectedVXResourceList = new VXResourceList();
expectedVXResourceList.setVXResources(vXResourcesList);
SearchFilter searchFilter = new SearchFilter();
Mockito.when(searchUtil.getSearchFilterFromLegacyRequest(request, null)).thenReturn(searchFilter);
Mockito.when(serviceREST.getPolicies(searchFilter)).thenReturn(rangerPolicyList);
VXLong actualXResource = assetREST.countXResources(request);
Assert.assertEquals(expectedXResouce.getValue(), actualXResource.getValue());
}
Aggregations