use of org.apache.ranger.view.VXAsset 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.VXAsset in project ranger by apache.
the class TestAssetREST method vXAsset.
private VXAsset vXAsset(Long id) {
Map<String, String> configs = new HashMap<String, String>();
configs.put("username", "servicemgr");
configs.put("password", "servicemgr");
configs.put("namenode", "servicemgr");
configs.put("hadoop.security.authorization", "No");
configs.put("hadoop.security.authentication", "Simple");
configs.put("hadoop.security.auth_to_local", "");
configs.put("dfs.datanode.kerberos.principal", "");
configs.put("dfs.namenode.kerberos.principal", "");
configs.put("dfs.secondary.namenode.kerberos.principal", "");
configs.put("hadoop.rpc.protection", "Privacy");
configs.put("commonNameForCertificate", "");
VXAsset vXAsset = new VXAsset();
vXAsset.setId(id);
vXAsset.setActiveStatus(1);
vXAsset.setAssetType(1);
vXAsset.setDescription("service policy");
vXAsset.setSupportNative(false);
vXAsset.setName("HDFS_1");
vXAsset.setUpdatedBy("Admin");
vXAsset.setConfig(getSampleConfig().toString());
return vXAsset;
}
use of org.apache.ranger.view.VXAsset in project ranger by apache.
the class TestAssetREST method testUpdateXAsset.
@Test
public void testUpdateXAsset() {
RangerService rangerService = rangerService(Id);
HttpServletRequest request = null;
VXAsset vXAsset = vXAsset(Id);
Mockito.when(serviceUtil.toRangerService(vXAsset)).thenReturn(rangerService);
Mockito.when(serviceREST.updateService(rangerService, request)).thenReturn(rangerService);
Mockito.when(serviceUtil.toVXAsset(rangerService)).thenReturn(vXAsset);
VXAsset asset = assetREST.updateXAsset(vXAsset);
Assert.assertNotNull(asset);
Assert.assertEquals(vXAsset, asset);
Mockito.verify(serviceREST).updateService(rangerService, request);
Mockito.verify(serviceUtil).toRangerService(vXAsset);
Mockito.verify(serviceUtil).toVXAsset(rangerService);
}
use of org.apache.ranger.view.VXAsset 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);
}
use of org.apache.ranger.view.VXAsset 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;
}
Aggregations