Search in sources :

Example 11 with VXAsset

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

Example 12 with VXAsset

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

Example 13 with VXAsset

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

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

Example 15 with VXAsset

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

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