Search in sources :

Example 6 with RangerServiceList

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

the class TestServiceDBStore method test24getServices.

@Test
public void test24getServices() throws Exception {
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    List<RangerService> serviceList = new ArrayList<RangerService>();
    RangerService rangerService = rangerService();
    serviceList.add(rangerService);
    RangerServiceList serviceListObj = new RangerServiceList();
    serviceListObj.setPageSize(0);
    serviceListObj.setResultSize(1);
    serviceListObj.setSortBy("asc");
    serviceListObj.setSortType("1");
    serviceListObj.setStartIndex(0);
    serviceListObj.setTotalCount(10);
    serviceListObj.setServices(serviceList);
    Mockito.when(svcService.searchRangerServices(filter)).thenReturn(serviceListObj);
    List<RangerService> dbRangerService = serviceDBStore.getServices(filter);
    Assert.assertNotNull(dbRangerService);
    Assert.assertEquals(dbRangerService, serviceList);
    Mockito.verify(svcService).searchRangerServices(filter);
}
Also used : ArrayList(java.util.ArrayList) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerServiceList(org.apache.ranger.view.RangerServiceList) RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Example 7 with RangerServiceList

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

the class TestPublicAPIsv2 method test11searchServices.

@Test
public void test11searchServices() throws Exception {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    List<RangerService> servicesList = new ArrayList<RangerService>();
    RangerService service = rangerService();
    servicesList.add(service);
    RangerServiceList serviceList = new RangerServiceList(servicesList);
    Mockito.when(serviceREST.getServices(request)).thenReturn(serviceList);
    List<RangerService> dbRangerServiceList = publicAPIsv2.searchServices(request);
    Assert.assertNotNull(dbRangerServiceList);
    Assert.assertEquals(dbRangerServiceList.size(), servicesList.size());
    Mockito.verify(serviceREST).getServices(request);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ArrayList(java.util.ArrayList) RangerServiceList(org.apache.ranger.view.RangerServiceList) RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Example 8 with RangerServiceList

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

the class TestServiceREST method test31getServices.

@Test
public void test31getServices() throws Exception {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    RangerServiceList dbRangerService = serviceREST.getServices(request);
    Assert.assertNull(dbRangerService);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerServiceList(org.apache.ranger.view.RangerServiceList) Test(org.junit.Test)

Aggregations

RangerServiceList (org.apache.ranger.view.RangerServiceList)8 RangerService (org.apache.ranger.plugin.model.RangerService)5 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 BaseDao (org.apache.ranger.common.db.BaseDao)1 RangerPerfTracer (org.apache.ranger.plugin.util.RangerPerfTracer)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1