Search in sources :

Example 6 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 7 with VXRepository

use of org.apache.ranger.view.VXRepository in project ranger by apache.

the class XRepositoryService method mapXAToPublicObject.

public VXRepository mapXAToPublicObject(VXAsset vXAsset) {
    VXRepository vRepo = new VXRepository();
    vRepo = super.mapBaseAttributesToPublicObject(vXAsset, vRepo);
    vRepo.setName(vXAsset.getName());
    vRepo.setDescription(vXAsset.getDescription());
    vRepo.setRepositoryType(AppConstants.getLabelFor_AssetType(vXAsset.getAssetType()));
    vRepo.setConfig(vXAsset.getConfig());
    int actStatus = vXAsset.getActiveStatus();
    boolean isAct = (actStatus == RangerCommonEnums.STATUS_DISABLED) ? false : true;
    vRepo.setIsActive(isAct);
    vRepo.setVersion(version);
    return vRepo;
}
Also used : VXRepository(org.apache.ranger.view.VXRepository)

Example 8 with VXRepository

use of org.apache.ranger.view.VXRepository in project ranger by apache.

the class TestPublicAPIs method test3updateRepository.

@Test
public void test3updateRepository() throws Exception {
    VXAsset vXAsset = new VXAsset();
    RangerService rangerService = rangerService();
    HttpServletRequest request = null;
    VXRepository vXRepository = vXRepository(rangerService);
    XXService xService = xService();
    XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
    Mockito.when(daoMgr.getXXService()).thenReturn(xServiceDao);
    Mockito.when(xServiceDao.getById(Id)).thenReturn(xService);
    Mockito.when(serviceUtil.publicObjecttoVXAsset(vXRepository)).thenReturn(vXAsset);
    Mockito.when(serviceUtil.toRangerService(vXAsset)).thenReturn(rangerService);
    Mockito.when(serviceREST.updateService(rangerService, request)).thenReturn(rangerService);
    Mockito.when(serviceUtil.toVXAsset(rangerService)).thenReturn(vXAsset);
    Mockito.when(serviceUtil.vXAssetToPublicObject(vXAsset)).thenReturn(vXRepository);
    VXRepository dbVXRepository = publicAPIs.updateRepository(vXRepository, Id);
    Assert.assertNotNull(dbVXRepository);
    Assert.assertEquals(dbVXRepository, vXRepository);
    Assert.assertEquals(dbVXRepository.getId(), vXRepository.getId());
    Assert.assertEquals(dbVXRepository.getName(), vXRepository.getName());
    Mockito.verify(serviceREST).updateService(rangerService, request);
    Mockito.verify(serviceUtil).publicObjecttoVXAsset(vXRepository);
    Mockito.verify(serviceUtil).toRangerService(vXAsset);
    Mockito.verify(serviceUtil).toVXAsset(rangerService);
    Mockito.verify(serviceUtil).vXAssetToPublicObject(vXAsset);
    Mockito.verify(daoMgr).getXXService();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXAsset(org.apache.ranger.view.VXAsset) RangerService(org.apache.ranger.plugin.model.RangerService) XXService(org.apache.ranger.entity.XXService) XXServiceDao(org.apache.ranger.db.XXServiceDao) VXRepository(org.apache.ranger.view.VXRepository) Test(org.junit.Test)

Example 9 with VXRepository

use of org.apache.ranger.view.VXRepository in project ranger by apache.

the class TestPublicAPIs method vXRepository.

private VXRepository vXRepository(RangerService service) {
    VXRepository ret = new VXRepository();
    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()));
    ret.setId(service.getId());
    ret.setCreateDate(service.getCreateTime());
    ret.setUpdateDate(service.getUpdateTime());
    ret.setOwner(service.getCreatedBy());
    ret.setUpdatedBy(service.getUpdatedBy());
    return ret;
}
Also used : VXRepository(org.apache.ranger.view.VXRepository)

Example 10 with VXRepository

use of org.apache.ranger.view.VXRepository in project ranger by apache.

the class TestPublicAPIs method test1getRepository.

@Test
public void test1getRepository() throws Exception {
    RangerService rangerService = rangerService();
    VXRepository vXRepository = vXRepository(rangerService);
    Mockito.when(serviceREST.getService(rangerService.getId())).thenReturn(rangerService);
    Mockito.when(serviceUtil.toVXRepository(rangerService)).thenReturn(vXRepository);
    VXRepository dbVXRepository = publicAPIs.getRepository(Id);
    Assert.assertNotNull(dbVXRepository);
    Assert.assertEquals(dbVXRepository, vXRepository);
    Assert.assertEquals(dbVXRepository.getId(), vXRepository.getId());
    Assert.assertEquals(dbVXRepository.getName(), vXRepository.getName());
    Mockito.verify(serviceREST).getService(Id);
    Mockito.verify(serviceUtil).toVXRepository(rangerService);
}
Also used : RangerService(org.apache.ranger.plugin.model.RangerService) VXRepository(org.apache.ranger.view.VXRepository) Test(org.junit.Test)

Aggregations

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