Search in sources :

Example 1 with VXRepositoryList

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXLong(org.apache.ranger.view.VXLong) VXRepositoryList(org.apache.ranger.view.VXRepositoryList) ArrayList(java.util.ArrayList) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerService(org.apache.ranger.plugin.model.RangerService) VXRepository(org.apache.ranger.view.VXRepository) Test(org.junit.Test)

Example 2 with VXRepositoryList

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());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXRepositoryList(org.apache.ranger.view.VXRepositoryList) ArrayList(java.util.ArrayList) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerService(org.apache.ranger.plugin.model.RangerService) VXRepository(org.apache.ranger.view.VXRepository) Test(org.junit.Test)

Example 3 with VXRepositoryList

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;
}
Also used : VXAsset(org.apache.ranger.view.VXAsset) VXRepositoryList(org.apache.ranger.view.VXRepositoryList) ArrayList(java.util.ArrayList) VXRepository(org.apache.ranger.view.VXRepository)

Example 4 with 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;
}
Also used : VXRepositoryList(org.apache.ranger.view.VXRepositoryList) ArrayList(java.util.ArrayList) RangerService(org.apache.ranger.plugin.model.RangerService) VXRepository(org.apache.ranger.view.VXRepository)

Aggregations

ArrayList (java.util.ArrayList)4 VXRepository (org.apache.ranger.view.VXRepository)4 VXRepositoryList (org.apache.ranger.view.VXRepositoryList)4 RangerService (org.apache.ranger.plugin.model.RangerService)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)2 Test (org.junit.Test)2 VXAsset (org.apache.ranger.view.VXAsset)1 VXLong (org.apache.ranger.view.VXLong)1