use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class TestPublicAPIsv2 method test19searchPolicies.
@Test
public void test19searchPolicies() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
List<RangerPolicy> policiesList = new ArrayList<RangerPolicy>();
RangerService service = rangerService();
String serviceName = service.getName();
RangerPolicy rangerPolicy = rangerPolicy();
policiesList.add(rangerPolicy);
RangerPolicyList policyList = new RangerPolicyList(policiesList);
Mockito.when(serviceREST.getServicePoliciesByName(serviceName, request)).thenReturn(policyList);
List<RangerPolicy> dbRangerPolicyList = publicAPIsv2.searchPolicies(serviceName, request);
Assert.assertNotNull(dbRangerPolicyList);
Assert.assertEquals(dbRangerPolicyList.size(), policiesList.size());
Mockito.verify(serviceREST).getServicePoliciesByName(serviceName, request);
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class TestPublicAPIsv2 method test25deletePolicyByName.
@Test
public void test25deletePolicyByName() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
RangerPolicy rangerPolicy = rangerPolicy();
String policyName = rangerPolicy.getName();
RangerService rangerService = rangerService();
String serviceName = rangerService.getName();
List<RangerPolicy> policies = new ArrayList<RangerPolicy>();
policies.add(rangerPolicy);
Mockito.when(serviceREST.getPolicies((SearchFilter) Mockito.any())).thenReturn(policies);
Mockito.doNothing().when(serviceREST).deletePolicy(Id);
publicAPIsv2.deletePolicyByName(serviceName, policyName, request);
Mockito.verify(serviceREST).getPolicies((SearchFilter) Mockito.any());
Mockito.verify(serviceREST).deletePolicy(Id);
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class TestServiceREST method test11getServiceByName.
@Test
public void test11getServiceByName() throws Exception {
RangerService rangerService = rangerService();
Mockito.when(svcStore.getServiceByName(rangerService.getName())).thenReturn(rangerService);
RangerService dbRangerService = serviceREST.getServiceByName(rangerService.getName());
Assert.assertNotNull(dbRangerService);
Assert.assertEquals(dbRangerService.getName(), dbRangerService.getName());
Mockito.verify(svcStore).getServiceByName(dbRangerService.getName());
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class TestServiceREST method test34countServices.
@Test
public void test34countServices() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
PList<RangerService> ret = Mockito.mock(PList.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.getPaginatedServices(filter)).thenReturn(ret);
Long data = serviceREST.countServices(request);
Assert.assertNotNull(data);
Mockito.verify(searchUtil).getSearchFilter(request, policyService.sortFields);
Mockito.verify(svcStore).getPaginatedServices(filter);
}
use of org.apache.ranger.plugin.model.RangerService in project ranger by apache.
the class TestServiceREST method test6createService.
@Test
public void test6createService() throws Exception {
RangerService rangerService = rangerService();
XXServiceDef xServiceDef = serviceDef();
XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
Mockito.when(validatorFactory.getServiceValidator(svcStore)).thenReturn(serviceValidator);
Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
Mockito.when(xServiceDefDao.findByName(rangerService.getType())).thenReturn(xServiceDef);
Mockito.when(svcStore.createService((RangerService) Mockito.any())).thenReturn(rangerService);
RangerService dbRangerService = serviceREST.createService(rangerService);
Assert.assertNotNull(dbRangerService);
Assert.assertEquals(rangerService, dbRangerService);
Assert.assertEquals(rangerService.getId(), dbRangerService.getId());
Assert.assertEquals(rangerService.getConfigs(), dbRangerService.getConfigs());
Assert.assertEquals(rangerService.getDescription(), dbRangerService.getDescription());
Assert.assertEquals(rangerService.getGuid(), dbRangerService.getGuid());
Assert.assertEquals(rangerService.getName(), dbRangerService.getName());
Assert.assertEquals(rangerService.getPolicyVersion(), dbRangerService.getPolicyVersion());
Assert.assertEquals(rangerService.getType(), dbRangerService.getType());
Assert.assertEquals(rangerService.getVersion(), dbRangerService.getVersion());
Assert.assertEquals(rangerService.getCreateTime(), dbRangerService.getCreateTime());
Assert.assertEquals(rangerService.getUpdateTime(), dbRangerService.getUpdateTime());
Assert.assertEquals(rangerService.getUpdatedBy(), dbRangerService.getUpdatedBy());
Mockito.verify(validatorFactory).getServiceValidator(svcStore);
Mockito.verify(svcStore).createService(rangerService);
}
Aggregations