Search in sources :

Example 1 with VXRepository

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

Example 2 with VXRepository

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

Example 3 with VXRepository

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXLong(org.apache.ranger.view.VXLong) VXRepositoryList(org.apache.ranger.view.VXRepositoryList) ArrayList(java.util.ArrayList) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerService(org.apache.ranger.plugin.model.RangerService) VXRepository(org.apache.ranger.view.VXRepository) Test(org.junit.Test)

Example 4 with VXRepository

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

Example 5 with VXRepository

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

Aggregations

VXRepository (org.apache.ranger.view.VXRepository)15 Test (org.junit.Test)9 RangerService (org.apache.ranger.plugin.model.RangerService)8 VXAsset (org.apache.ranger.view.VXAsset)5 ArrayList (java.util.ArrayList)4 VXRepositoryList (org.apache.ranger.view.VXRepositoryList)4 Date (java.util.Date)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)2 HashMap (java.util.HashMap)1 XXServiceDao (org.apache.ranger.db.XXServiceDao)1 XXService (org.apache.ranger.entity.XXService)1 VXLong (org.apache.ranger.view.VXLong)1