Search in sources :

Example 51 with SearchFilter

use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.

the class TestServiceDBStore method test18getPaginatedServiceDefs.

@Test
public void test18getPaginatedServiceDefs() throws Exception {
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    List<RangerServiceDef> serviceDefsList = new ArrayList<RangerServiceDef>();
    RangerServiceDef serviceDef = rangerServiceDef();
    serviceDefsList.add(serviceDef);
    RangerServiceDefList serviceDefList = new RangerServiceDefList();
    serviceDefList.setPageSize(0);
    serviceDefList.setResultSize(1);
    serviceDefList.setSortBy("asc");
    serviceDefList.setSortType("1");
    serviceDefList.setStartIndex(0);
    serviceDefList.setTotalCount(10);
    serviceDefList.setServiceDefs(serviceDefsList);
    Mockito.when(serviceDefService.searchRangerServiceDefs(filter)).thenReturn(serviceDefList);
    PList<RangerServiceDef> dbServiceDefList = serviceDBStore.getPaginatedServiceDefs(filter);
    Assert.assertNotNull(dbServiceDefList);
    Assert.assertEquals(dbServiceDefList.getList(), serviceDefList.getServiceDefs());
    Mockito.verify(serviceDefService).searchRangerServiceDefs(filter);
}
Also used : RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) ArrayList(java.util.ArrayList) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList) Test(org.junit.Test)

Example 52 with SearchFilter

use of org.apache.ranger.plugin.util.SearchFilter 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 53 with SearchFilter

use of org.apache.ranger.plugin.util.SearchFilter 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)

Example 54 with SearchFilter

use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.

the class TestServiceDBStore method test17getServiceDefs.

@Test
public void test17getServiceDefs() throws Exception {
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    List<RangerServiceDef> serviceDefsList = new ArrayList<RangerServiceDef>();
    RangerServiceDef serviceDef = rangerServiceDef();
    serviceDefsList.add(serviceDef);
    RangerServiceDefList serviceDefList = new RangerServiceDefList();
    serviceDefList.setPageSize(0);
    serviceDefList.setResultSize(1);
    serviceDefList.setSortBy("asc");
    serviceDefList.setSortType("1");
    serviceDefList.setStartIndex(0);
    serviceDefList.setTotalCount(10);
    serviceDefList.setServiceDefs(serviceDefsList);
    Mockito.when(serviceDefService.searchRangerServiceDefs(filter)).thenReturn(serviceDefList);
    List<RangerServiceDef> dbServiceDef = serviceDBStore.getServiceDefs(filter);
    Assert.assertNotNull(dbServiceDef);
    Assert.assertEquals(dbServiceDef, serviceDefsList);
    Assert.assertEquals(dbServiceDef.get(0), serviceDefsList.get(0));
    Mockito.verify(serviceDefService).searchRangerServiceDefs(filter);
}
Also used : RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) ArrayList(java.util.ArrayList) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList) Test(org.junit.Test)

Example 55 with SearchFilter

use of org.apache.ranger.plugin.util.SearchFilter 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)

Aggregations

SearchFilter (org.apache.ranger.plugin.util.SearchFilter)61 Test (org.junit.Test)32 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)30 ArrayList (java.util.ArrayList)27 RangerService (org.apache.ranger.plugin.model.RangerService)24 Path (javax.ws.rs.Path)13 Produces (javax.ws.rs.Produces)13 HttpServletRequest (javax.servlet.http.HttpServletRequest)12 GET (javax.ws.rs.GET)12 WebApplicationException (javax.ws.rs.WebApplicationException)11 RangerPolicyList (org.apache.ranger.view.RangerPolicyList)11 VXString (org.apache.ranger.view.VXString)10 RangerPerfTracer (org.apache.ranger.plugin.util.RangerPerfTracer)9 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)7 RangerServiceDefList (org.apache.ranger.view.RangerServiceDefList)6 RangerServiceList (org.apache.ranger.view.RangerServiceList)6 HashMap (java.util.HashMap)5 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)5 XXTrxLog (org.apache.ranger.entity.XXTrxLog)4 RangerExportPolicyList (org.apache.ranger.view.RangerExportPolicyList)4