use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestServiceDBStore method test37getPaginatedServicePolicies.
@Test
public void test37getPaginatedServicePolicies() throws Exception {
SearchFilter filter = new SearchFilter();
filter.setParam(SearchFilter.POLICY_NAME, "policyName");
filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
RangerService rangerService = rangerService();
XXService xService = xService();
XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
Mockito.when(xServiceDao.getById(Id)).thenReturn(xService);
// PList<RangerPolicy> dbRangerPolicyList =
serviceDBStore.getPaginatedServicePolicies(rangerService.getId(), filter);
Mockito.verify(daoManager).getXXService();
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestServiceDBStore method test31getPaginatedPolicies.
@Test
public void test31getPaginatedPolicies() throws Exception {
SearchFilter filter = new SearchFilter();
filter.setParam(SearchFilter.POLICY_NAME, "policyName");
filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
RangerPolicyList policyListObj = new RangerPolicyList();
policyListObj.setPageSize(0);
policyListObj.setResultSize(1);
policyListObj.setSortBy("asc");
policyListObj.setSortType("1");
policyListObj.setStartIndex(0);
policyListObj.setTotalCount(10);
PList<RangerPolicy> dbRangerPolicyList = serviceDBStore.getPaginatedPolicies(filter);
Assert.assertNotNull(dbRangerPolicyList);
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestServiceDBStore method test32getServicePolicies.
@Test
public void test32getServicePolicies() throws Exception {
SearchFilter filter = new SearchFilter();
filter.setParam(SearchFilter.POLICY_NAME, "policyName");
filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
XXService xService = xService();
XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
Mockito.when(xServiceDao.getById(Id)).thenReturn(xService);
thrown.expect(Exception.class);
List<RangerPolicy> dbRangerPolicy = serviceDBStore.getServicePolicies(Id, filter);
Assert.assertFalse(dbRangerPolicy.isEmpty());
Mockito.verify(daoManager).getXXService();
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestServiceDBStore method test25getPaginatedServiceDefs.
@Test
public void test25getPaginatedServiceDefs() throws Exception {
SearchFilter filter = new SearchFilter();
filter.setParam(SearchFilter.POLICY_NAME, "policyName");
filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
List<RangerService> serviceList = new ArrayList<RangerService>();
RangerService rangerService = rangerService();
serviceList.add(rangerService);
RangerServiceList serviceListObj = new RangerServiceList();
serviceListObj.setPageSize(0);
serviceListObj.setResultSize(1);
serviceListObj.setSortBy("asc");
serviceListObj.setSortType("1");
serviceListObj.setStartIndex(0);
serviceListObj.setTotalCount(10);
serviceListObj.setServices(serviceList);
Mockito.when(svcService.searchRangerServices(filter)).thenReturn(serviceListObj);
PList<RangerService> dbServiceList = serviceDBStore.getPaginatedServices(filter);
Assert.assertNotNull(dbServiceList);
Assert.assertEquals(dbServiceList.getList(), serviceListObj.getServices());
Mockito.verify(svcService).searchRangerServices(filter);
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class RangerSearchUtil method getSearchFilterFromLegacyRequestForRepositorySearch.
public SearchFilter getSearchFilterFromLegacyRequestForRepositorySearch(HttpServletRequest request, List<SortField> sortFields) {
if (request == null) {
return null;
}
SearchFilter ret = new SearchFilter();
if (MapUtils.isEmpty(request.getParameterMap())) {
ret.setParams(new HashMap<String, String>());
}
ret.setParam(SearchFilter.SERVICE_NAME, request.getParameter("name"));
ret.setParam(SearchFilter.IS_ENABLED, request.getParameter("status"));
String serviceType = request.getParameter("type");
if (serviceType != null) {
serviceType = serviceType.toLowerCase();
}
ret.setParam(SearchFilter.SERVICE_TYPE, serviceType);
extractCommonCriteriasForFilter(request, ret, sortFields);
return ret;
}
Aggregations