use of org.apache.ranger.view.VXRepository in project ranger by apache.
the class ServiceUtil method toVXRepository.
public VXRepository toVXRepository(RangerService service) {
if (service == null || toAssetType(service.getType()) == null) {
return null;
}
VXRepository ret = new VXRepository();
rangerObjectToDataObject(service, ret);
ret.setRepositoryType(service.getType());
ret.setName(service.getName());
ret.setDescription(service.getDescription());
ret.setIsActive(service.getIsEnabled());
ret.setConfig(jsonUtil.readMapToString(service.getConfigs()));
ret.setVersion(Long.toString(service.getVersion()));
return ret;
}
use of org.apache.ranger.view.VXRepository in project ranger by apache.
the class ServiceUtil method vXAssetToPublicObject.
public VXRepository vXAssetToPublicObject(VXAsset asset) {
VXRepository ret = new VXRepository();
vXDataObjectToPublicDataObject(ret, asset);
ret.setRepositoryType(toServiceType(asset.getAssetType()));
ret.setName(asset.getName());
ret.setDescription(asset.getDescription());
ret.setIsActive(asset.getActiveStatus() == RangerCommonEnums.STATUS_ENABLED ? true : false);
ret.setConfig(asset.getConfig());
ret.setVersion(version);
return ret;
}
use of org.apache.ranger.view.VXRepository 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.VXRepository in project ranger by apache.
the class TestServiceUtil method testToVXRepositoryForNull.
@Test
public void testToVXRepositoryForNull() {
RangerService rangerService = null;
VXRepository actualvXRepository = serviceUtil.toVXRepository(rangerService);
Assert.assertNull(actualvXRepository);
}
use of org.apache.ranger.view.VXRepository in project ranger by apache.
the class TestPublicAPIs method test2createRepository.
@Test
public void test2createRepository() throws Exception {
VXAsset vXAsset = new VXAsset();
RangerService rangerService = rangerService();
VXRepository vXRepository = vXRepository(rangerService);
Mockito.when(serviceUtil.publicObjecttoVXAsset(vXRepository)).thenReturn(vXAsset);
Mockito.when(serviceUtil.toRangerService(vXAsset)).thenReturn(rangerService);
Mockito.when(serviceREST.createService(rangerService)).thenReturn(rangerService);
Mockito.when(serviceUtil.toVXAsset(rangerService)).thenReturn(vXAsset);
Mockito.when(serviceUtil.vXAssetToPublicObject(vXAsset)).thenReturn(vXRepository);
VXRepository dbVXRepository = publicAPIs.createRepository(vXRepository);
Assert.assertNotNull(dbVXRepository);
Assert.assertEquals(dbVXRepository, vXRepository);
Assert.assertEquals(dbVXRepository.getId(), vXRepository.getId());
Assert.assertEquals(dbVXRepository.getName(), vXRepository.getName());
Mockito.verify(serviceREST).createService(rangerService);
Mockito.verify(serviceUtil).publicObjecttoVXAsset(vXRepository);
Mockito.verify(serviceUtil).toRangerService(vXAsset);
Mockito.verify(serviceUtil).toVXAsset(rangerService);
Mockito.verify(serviceUtil).vXAssetToPublicObject(vXAsset);
}
Aggregations