use of org.apache.ranger.view.VXRepositoryList in project ranger by apache.
the class TestPublicAPIs method test6countRepositories.
@Test
public void test6countRepositories() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
VXLong vXLong = new VXLong();
List<RangerService> ret = new ArrayList<RangerService>();
RangerService rangerService = rangerService();
VXRepository vXRepository = vXRepository(rangerService);
List<VXRepository> repoList = new ArrayList<VXRepository>();
repoList.add(vXRepository);
VXRepositoryList vXRepositoryList = new VXRepositoryList(repoList);
SearchFilter filter = new SearchFilter();
filter.setParam(SearchFilter.POLICY_NAME, "policyName");
filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
Mockito.when(searchUtil.getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields)).thenReturn(filter);
Mockito.when(serviceREST.getServices(filter)).thenReturn(ret);
Mockito.when(serviceUtil.rangerServiceListToPublicObjectList(ret)).thenReturn(vXRepositoryList);
VXRepositoryList dbVXRepositoryList = publicAPIs.searchRepositories(request);
vXLong.setValue(dbVXRepositoryList.getResultSize());
Assert.assertNotNull(vXLong);
Assert.assertEquals(vXLong.getValue(), 1);
Mockito.verify(searchUtil).getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields);
Mockito.verify(serviceREST).getServices(filter);
Mockito.verify(serviceUtil).rangerServiceListToPublicObjectList(ret);
}
use of org.apache.ranger.view.VXRepositoryList in project ranger by apache.
the class TestPublicAPIs method test5searchRepositories.
@Test
public void test5searchRepositories() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
List<RangerService> ret = new ArrayList<RangerService>();
RangerService rangerService = rangerService();
VXRepository vXRepository = vXRepository(rangerService);
List<VXRepository> repoList = new ArrayList<VXRepository>();
repoList.add(vXRepository);
VXRepositoryList vXRepositoryList = new VXRepositoryList(repoList);
SearchFilter filter = new SearchFilter();
filter.setParam(SearchFilter.POLICY_NAME, "policyName");
filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
Mockito.when(searchUtil.getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields)).thenReturn(filter);
Mockito.when(serviceREST.getServices(filter)).thenReturn(ret);
Mockito.when(serviceUtil.rangerServiceListToPublicObjectList(ret)).thenReturn(vXRepositoryList);
VXRepositoryList dbVXRepositoryList = publicAPIs.searchRepositories(request);
Assert.assertNotNull(dbVXRepositoryList);
Assert.assertEquals(dbVXRepositoryList.getResultSize(), vXRepositoryList.getResultSize());
}
use of org.apache.ranger.view.VXRepositoryList in project ranger by apache.
the class XRepositoryService method mapToVXRepositoryList.
public VXRepositoryList mapToVXRepositoryList(VXAssetList vXAssetList) {
List<VXRepository> repoList = new ArrayList<VXRepository>();
for (VXAsset vXAsset : vXAssetList.getVXAssets()) {
VXRepository vXRepo = mapXAToPublicObject(vXAsset);
repoList.add(vXRepo);
}
VXRepositoryList vXRepositoryList = new VXRepositoryList(repoList);
return vXRepositoryList;
}
use of org.apache.ranger.view.VXRepositoryList in project ranger by apache.
the class ServiceUtil method rangerServiceListToPublicObjectList.
public VXRepositoryList rangerServiceListToPublicObjectList(List<RangerService> serviceList) {
List<VXRepository> repoList = new ArrayList<VXRepository>();
for (RangerService service : serviceList) {
VXRepository vXRepo = toVXRepository(service);
if (vXRepo != null) {
repoList.add(vXRepo);
}
}
VXRepositoryList vXRepositoryList = new VXRepositoryList(repoList);
return vXRepositoryList;
}
Aggregations