Search in sources :

Example 1 with VXAssetList

use of org.apache.ranger.view.VXAssetList 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);
}
Also used : VXAsset(org.apache.ranger.view.VXAsset) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerService(org.apache.ranger.plugin.model.RangerService) VXAssetList(org.apache.ranger.view.VXAssetList) Test(org.junit.Test)

Example 2 with VXAssetList

use of org.apache.ranger.view.VXAssetList in project ranger by apache.

the class XAssetServiceBase method searchXAssets.

/**
 * @param searchCriteria
 * @return
 */
public VXAssetList searchXAssets(SearchCriteria searchCriteria) {
    VXAssetList returnList = new VXAssetList();
    List<VXAsset> xAssetList = new ArrayList<VXAsset>();
    List<T> resultList = searchResources(searchCriteria, searchFields, sortFields, returnList);
    // Iterate over the result list and create the return list
    for (T gjXAsset : resultList) {
        VXAsset vXAsset = populateViewBean(gjXAsset);
        xAssetList.add(vXAsset);
    }
    returnList.setVXAssets(xAssetList);
    return returnList;
}
Also used : VXAsset(org.apache.ranger.view.VXAsset) ArrayList(java.util.ArrayList) VXAssetList(org.apache.ranger.view.VXAssetList)

Example 3 with VXAssetList

use of org.apache.ranger.view.VXAssetList 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());
}
Also used : VXAsset(org.apache.ranger.view.VXAsset) VXLong(org.apache.ranger.view.VXLong) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerService(org.apache.ranger.plugin.model.RangerService) VXAssetList(org.apache.ranger.view.VXAssetList) Test(org.junit.Test)

Aggregations

VXAsset (org.apache.ranger.view.VXAsset)3 VXAssetList (org.apache.ranger.view.VXAssetList)3 RangerService (org.apache.ranger.plugin.model.RangerService)2 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 VXLong (org.apache.ranger.view.VXLong)1