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