Search in sources :

Example 1 with VXAsset

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);
}
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 VXAsset

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

Example 3 with 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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXAsset(org.apache.ranger.view.VXAsset) RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Example 4 with VXAsset

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

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

Aggregations

VXAsset (org.apache.ranger.view.VXAsset)16 Test (org.junit.Test)10 RangerService (org.apache.ranger.plugin.model.RangerService)9 ArrayList (java.util.ArrayList)3 VXAssetList (org.apache.ranger.view.VXAssetList)3 VXRepository (org.apache.ranger.view.VXRepository)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)2 X509Certificate (java.security.cert.X509Certificate)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 BaseDao (org.apache.ranger.common.db.BaseDao)1 XXServiceDao (org.apache.ranger.db.XXServiceDao)1 XXAsset (org.apache.ranger.entity.XXAsset)1 XXDBBase (org.apache.ranger.entity.XXDBBase)1 XXService (org.apache.ranger.entity.XXService)1 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)1 ServicePolicies (org.apache.ranger.plugin.util.ServicePolicies)1 VXLong (org.apache.ranger.view.VXLong)1