Search in sources :

Example 16 with RangerPolicyList

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

the class TestServiceREST method test23getServicePoliciesByName.

@Test
public void test23getServicePoliciesByName() throws Exception {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    RangerPolicy rangerPolicy = rangerPolicy();
    List<RangerPolicy> ret = Mockito.mock(List.class);
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    Mockito.when(searchUtil.getSearchFilter(request, policyService.sortFields)).thenReturn(filter);
    Mockito.when(svcStore.getServicePolicies(rangerPolicy.getName(), filter)).thenReturn(ret);
    RangerPolicyList dbRangerPolicy = serviceREST.getServicePoliciesByName(rangerPolicy.getName(), request);
    Assert.assertNotNull(dbRangerPolicy);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerPolicyList(org.apache.ranger.view.RangerPolicyList) Test(org.junit.Test)

Example 17 with RangerPolicyList

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

the class TestServiceDBStore method test36getPaginatedServicePolicies.

@Test
public void test36getPaginatedServicePolicies() throws Exception {
    String serviceName = "HDFS_1";
    RangerPolicyList policyList = new RangerPolicyList();
    policyList.setPageSize(0);
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    PList<RangerPolicy> dbRangerPolicyList = serviceDBStore.getPaginatedServicePolicies(serviceName, filter);
    Assert.assertNotNull(dbRangerPolicyList);
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) VXString(org.apache.ranger.view.VXString) RangerPolicyList(org.apache.ranger.view.RangerPolicyList) Test(org.junit.Test)

Example 18 with RangerPolicyList

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

the class TestServiceDBStore method test30getPolicies.

@Test
public void test30getPolicies() throws Exception {
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    List<RangerPolicy> rangerPolicyLists = new ArrayList<RangerPolicy>();
    RangerPolicy rangerPolicy = rangerPolicy();
    rangerPolicyLists.add(rangerPolicy);
    RangerPolicyList policyListObj = new RangerPolicyList();
    policyListObj.setPageSize(0);
    policyListObj.setResultSize(1);
    policyListObj.setSortBy("asc");
    policyListObj.setSortType("1");
    policyListObj.setStartIndex(0);
    policyListObj.setTotalCount(10);
    List<RangerPolicy> dbRangerPolicy = serviceDBStore.getPolicies(filter);
    Assert.assertNotNull(dbRangerPolicy);
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) ArrayList(java.util.ArrayList) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerPolicyList(org.apache.ranger.view.RangerPolicyList) Test(org.junit.Test)

Aggregations

RangerPolicyList (org.apache.ranger.view.RangerPolicyList)18 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)14 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)10 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 VXString (org.apache.ranger.view.VXString)4 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 HashSet (java.util.HashSet)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 PList (org.apache.ranger.plugin.store.PList)2 RangerPerfTracer (org.apache.ranger.plugin.util.RangerPerfTracer)2 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 XXPolicy (org.apache.ranger.entity.XXPolicy)1