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);
}
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;
}
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());
}
Aggregations