use of org.apache.ranger.view.VXAsset in project ranger by apache.
the class TestAssetREST method testCreateXAsset.
@Test
public void testCreateXAsset() {
RangerService rangerService = rangerService(Id);
VXAsset vXAsset = vXAsset(Id);
Mockito.when(serviceREST.createService(rangerService)).thenReturn(rangerService);
Mockito.when(serviceUtil.toRangerService(vXAsset)).thenReturn(rangerService);
Mockito.when(serviceUtil.toVXAsset(rangerService)).thenReturn(vXAsset);
VXAsset asset = assetREST.createXAsset(vXAsset);
Assert.assertNotNull(asset);
Assert.assertEquals(vXAsset, asset);
Mockito.verify(serviceREST).createService(rangerService);
Mockito.verify(serviceUtil).toRangerService(vXAsset);
Mockito.verify(serviceUtil).toVXAsset(rangerService);
}
use of org.apache.ranger.view.VXAsset in project ranger by apache.
the class TestAssetREST method testGetXAsset.
@Test
public void testGetXAsset() {
RangerService rangerService = rangerService(Id);
VXAsset vXAsset = vXAsset(Id);
Mockito.when(serviceREST.getService(rangerService.getId())).thenReturn(rangerService);
Mockito.when(serviceUtil.toVXAsset(rangerService)).thenReturn(vXAsset);
VXAsset asset = assetREST.getXAsset(Id);
Assert.assertNotNull(asset);
Assert.assertEquals(vXAsset, asset);
Mockito.verify(serviceREST).getService(rangerService.getId());
Mockito.verify(serviceUtil).toVXAsset(rangerService);
}
use of org.apache.ranger.view.VXAsset in project ranger by apache.
the class TestAssetREST method testCountXAssets.
@Test
public void testCountXAssets() {
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);
VXLong expectedAsset = new VXLong();
expectedAsset.setValue(2l);
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);
VXLong actualAsset = assetREST.countXAssets(request);
Assert.assertEquals(expectedAsset.getValue(), actualAsset.getValue());
}
use of org.apache.ranger.view.VXAsset in project ranger by apache.
the class TestAssetREST method testConfigTest.
@Test
public void testConfigTest() {
RangerService rangerService = rangerService(Id);
VXResponse expectedVxResponse = new VXResponse();
expectedVxResponse.setStatusCode(VXResponse.STATUS_SUCCESS);
expectedVxResponse.setMsgDesc("test connection successful");
VXAsset vXAsset = vXAsset(Id);
Mockito.when(serviceUtil.toRangerService(vXAsset)).thenReturn(rangerService);
Mockito.when(serviceREST.validateConfig(rangerService)).thenReturn(expectedVxResponse);
VXResponse actualVxResponse = assetREST.configTest(vXAsset);
Assert.assertNotNull(actualVxResponse);
Assert.assertEquals(expectedVxResponse, actualVxResponse);
Mockito.verify(serviceUtil).toRangerService(vXAsset);
Mockito.verify(serviceREST).validateConfig(rangerService);
}
use of org.apache.ranger.view.VXAsset 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();
}
Aggregations