use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestAssetREST method testCountXAssets.
@Test
public void testCountXAssets() {
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);
VXLong expectedAsset = new VXLong();
expectedAsset.setValue(2l);
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);
VXLong actualAsset = assetREST.countXAssets(request);
Assert.assertEquals(expectedAsset.getValue(), actualAsset.getValue());
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestPublicAPIs method test11searchPolicies.
@Test
public void test11searchPolicies() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
RangerService service = rangerService();
RangerPolicy policy = rangerPolicy();
List<RangerPolicy> policyList = new ArrayList<RangerPolicy>();
policyList.add(policy);
VXPolicy vXPolicy = vXPolicy(policy, service);
List<VXPolicy> vXPolicies = new ArrayList<VXPolicy>();
vXPolicies.add(vXPolicy);
VXPolicyList vXPolicyList = new VXPolicyList(vXPolicies);
SearchFilter filter = new SearchFilter();
filter.setParam(SearchFilter.POLICY_NAME, "policyName");
filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
filter.setStartIndex(0);
filter.setMaxRows(10);
Mockito.when(searchUtil.getSearchFilterFromLegacyRequest(request, policyService.sortFields)).thenReturn(filter);
Mockito.when(serviceREST.getPolicies(filter)).thenReturn(policyList);
Mockito.when(serviceUtil.rangerPolicyListToPublic(policyList, filter)).thenReturn(vXPolicyList);
VXPolicyList dbVXPolicyList = publicAPIs.searchPolicies(request);
Assert.assertNotNull(dbVXPolicyList);
Assert.assertEquals(dbVXPolicyList.getResultSize(), vXPolicyList.getResultSize());
Mockito.verify(searchUtil).getSearchFilterFromLegacyRequest(request, policyService.sortFields);
Mockito.verify(serviceREST).getPolicies(filter);
Mockito.verify(serviceUtil).rangerPolicyListToPublic(policyList, filter);
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestServiceREST method test21countPolicies.
@Test
public void test21countPolicies() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
SearchFilter filter = new SearchFilter();
filter.setParam(SearchFilter.POLICY_NAME, "policyName");
filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
Mockito.when(searchUtil.getSearchFilter(request, policyService.sortFields)).thenReturn(filter);
Long data = serviceREST.countPolicies(request);
Assert.assertNotNull(data);
Mockito.verify(searchUtil).getSearchFilter(request, policyService.sortFields);
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestServiceREST method test31getServices.
@Test
public void test31getServices() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
SearchFilter filter = new SearchFilter();
filter.setParam(SearchFilter.POLICY_NAME, "policyName");
filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
RangerServiceList dbRangerService = serviceREST.getServices(request);
Assert.assertNull(dbRangerService);
}
use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.
the class TestServiceREST method test25getPolicies.
@Test
public void test25getPolicies() throws Exception {
List<RangerPolicy> ret = new ArrayList<RangerPolicy>();
SearchFilter filter = new SearchFilter();
filter.setParam(SearchFilter.POLICY_NAME, "policyName");
filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
Mockito.when(svcStore.getPolicies(filter)).thenReturn(ret);
List<RangerPolicy> dbRangerPolicyList = serviceREST.getPolicies(filter);
Assert.assertNotNull(dbRangerPolicyList);
Mockito.verify(svcStore).getPolicies(filter);
}
Aggregations