Search in sources :

Example 1 with RangerServiceDefList

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

the class TestPublicAPIsv2 method test3searchServiceDefs.

@Test
public void test3searchServiceDefs() throws Exception {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    List<RangerServiceDef> serviceDefsList = new ArrayList<RangerServiceDef>();
    RangerServiceDef serviceDef = rangerServiceDef();
    serviceDefsList.add(serviceDef);
    RangerServiceDefList serviceDefList = new RangerServiceDefList(serviceDefsList);
    Mockito.when(serviceREST.getServiceDefs(request)).thenReturn(serviceDefList);
    List<RangerServiceDef> dbRangerServiceDefList = publicAPIsv2.searchServiceDefs(request);
    Assert.assertNotNull(dbRangerServiceDefList);
    Assert.assertEquals(dbRangerServiceDefList.size(), serviceDefsList.size());
    Mockito.verify(serviceREST).getServiceDefs(request);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) ArrayList(java.util.ArrayList) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList) Test(org.junit.Test)

Example 2 with RangerServiceDefList

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

the class ServiceDBStore method getServiceDefs.

@Override
public List<RangerServiceDef> getServiceDefs(SearchFilter filter) throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceDBStore.getServiceDefs(" + filter + ")");
    }
    RangerServiceDefList svcDefList = serviceDefService.searchRangerServiceDefs(filter);
    predicateUtil.applyFilter(svcDefList.getServiceDefs(), filter);
    List<RangerServiceDef> ret = svcDefList.getServiceDefs();
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceDBStore.getServiceDefs(" + filter + "): " + ret);
    }
    return ret;
}
Also used : RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList)

Example 3 with RangerServiceDefList

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

the class TestServiceDBStore method test42getMetricByTypeaudits.

@Test
public void test42getMetricByTypeaudits() throws Exception {
    String type = "audits";
    Date date = new Date();
    date.setYear(2018);
    Mockito.when(restErrorUtil.parseDate(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.anyString(), Mockito.anyString())).thenReturn(date);
    RangerServiceDefList svcDefList = new RangerServiceDefList();
    svcDefList.setTotalCount(10l);
    Mockito.when(serviceDefService.searchRangerServiceDefs(Mockito.any(SearchFilter.class))).thenReturn(svcDefList);
    serviceDBStore.getMetricByType(ServiceDBStore.METRIC_TYPE.getMetricTypeByName(type));
}
Also used : SearchFilter(org.apache.ranger.plugin.util.SearchFilter) VXString(org.apache.ranger.view.VXString) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList) Date(java.util.Date) Test(org.junit.Test)

Example 4 with RangerServiceDefList

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

the class TestServiceDBStore method test47getMetricByTypeDenyconditions.

@Test
public void test47getMetricByTypeDenyconditions() throws Exception {
    String type = "denyconditions";
    RangerServiceDefList svcDefList = new RangerServiceDefList();
    svcDefList.setTotalCount(10l);
    Mockito.when(serviceDefService.searchRangerServiceDefs(Mockito.any(SearchFilter.class))).thenReturn(svcDefList);
    serviceDBStore.getMetricByType(ServiceDBStore.METRIC_TYPE.getMetricTypeByName(type));
}
Also used : SearchFilter(org.apache.ranger.plugin.util.SearchFilter) VXString(org.apache.ranger.view.VXString) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList) Test(org.junit.Test)

Example 5 with RangerServiceDefList

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

the class TestRangerServiceDefServiceBase method test21searchRangerServiceDefs.

@Test
public void test21searchRangerServiceDefs() {
    setup();
    SearchFilter searchFilter = new SearchFilter();
    searchFilter.setParam(SearchFilter.POLICY_NAME, "policyName");
    searchFilter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    RangerServiceDefList dbRangerServiceDefList = rangerServiceDefService.searchRangerServiceDefs(searchFilter);
    Assert.assertNotNull(dbRangerServiceDefList);
}
Also used : SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList) Test(org.junit.Test)

Aggregations

RangerServiceDefList (org.apache.ranger.view.RangerServiceDefList)12 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)8 Test (org.junit.Test)8 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)6 ArrayList (java.util.ArrayList)5 VXString (org.apache.ranger.view.VXString)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 PList (org.apache.ranger.plugin.store.PList)2 Date (java.util.Date)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 RangerPerfTracer (org.apache.ranger.plugin.util.RangerPerfTracer)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1