use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestServiceDBStore method test16getServiceDefByNameNotNull.
@Test
public void test16getServiceDefByNameNotNull() throws Exception {
String name = "fdfdfds";
XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
XXServiceDef xServiceDef = Mockito.mock(XXServiceDef.class);
RangerServiceDef serviceDef = new RangerServiceDef();
Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
Mockito.when(xServiceDefDao.findByName(name)).thenReturn(xServiceDef);
Mockito.when(serviceDefService.getPopulatedViewObject(xServiceDef)).thenReturn(serviceDef);
RangerServiceDef dbServiceDef = serviceDBStore.getServiceDefByName(name);
Assert.assertNotNull(dbServiceDef);
Mockito.verify(daoManager).getXXServiceDef();
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestServiceDBStore method test15getServiceDefByName.
@Test
public void test15getServiceDefByName() throws Exception {
String name = "fdfdfds";
XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
XXServiceDef xServiceDef = Mockito.mock(XXServiceDef.class);
Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
Mockito.when(xServiceDefDao.findByName(name)).thenReturn(xServiceDef);
RangerServiceDef dbServiceDef = serviceDBStore.getServiceDefByName(name);
Assert.assertNull(dbServiceDef);
Mockito.verify(daoManager).getXXServiceDef();
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestServiceDBStore method test14getServiceDef.
@Test
public void test14getServiceDef() throws Exception {
RangerServiceDef rangerServiceDef = rangerServiceDef();
Mockito.when(serviceDefService.read(Id)).thenReturn(rangerServiceDef);
RangerServiceDef dbRangerServiceDef = serviceDBStore.getServiceDef(Id);
Assert.assertNotNull(dbRangerServiceDef);
Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
Assert.assertEquals(dbRangerServiceDef.getCreatedBy(), rangerServiceDef.getCreatedBy());
Assert.assertEquals(dbRangerServiceDef.getDescription(), rangerServiceDef.getDescription());
Assert.assertEquals(dbRangerServiceDef.getGuid(), rangerServiceDef.getGuid());
Assert.assertEquals(dbRangerServiceDef.getImplClass(), rangerServiceDef.getImplClass());
Assert.assertEquals(dbRangerServiceDef.getLabel(), rangerServiceDef.getLabel());
Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
Assert.assertEquals(dbRangerServiceDef.getRbKeyDescription(), rangerServiceDef.getRbKeyDescription());
Assert.assertEquals(dbRangerServiceDef.getConfigs(), rangerServiceDef.getConfigs());
Assert.assertEquals(dbRangerServiceDef.getVersion(), rangerServiceDef.getVersion());
Assert.assertEquals(dbRangerServiceDef.getResources(), rangerServiceDef.getResources());
Mockito.verify(serviceDefService).read(Id);
}
use of org.apache.ranger.plugin.model.RangerServiceDef 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);
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestServiceDBStore method test19createService.
@Test
public void test19createService() throws Exception {
XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
XXServiceConfigMapDao xServiceConfigMapDao = Mockito.mock(XXServiceConfigMapDao.class);
XXUserDao xUserDao = Mockito.mock(XXUserDao.class);
XXServiceConfigDefDao xServiceConfigDefDao = Mockito.mock(XXServiceConfigDefDao.class);
XXService xService = Mockito.mock(XXService.class);
RangerService rangerService = rangerService();
List<XXServiceConfigDef> svcConfDefList = new ArrayList<XXServiceConfigDef>();
XXServiceConfigDef serviceConfigDefObj = new XXServiceConfigDef();
serviceConfigDefObj.setId(Id);
serviceConfigDefObj.setType("1");
svcConfDefList.add(serviceConfigDefObj);
Mockito.when(daoManager.getXXServiceConfigDef()).thenReturn(xServiceConfigDefDao);
Mockito.when(svcService.create(rangerService)).thenReturn(rangerService);
Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
Mockito.when(xServiceDao.getById(rangerService.getId())).thenReturn(xService);
Mockito.when(daoManager.getXXServiceConfigMap()).thenReturn(xServiceConfigMapDao);
Mockito.when(daoManager.getXXUser()).thenReturn(xUserDao);
XXServiceConfigMap xConfMap = new XXServiceConfigMap();
Mockito.when(svcService.getPopulatedViewObject(xService)).thenReturn(rangerService);
Mockito.when(rangerAuditFields.populateAuditFields(Mockito.isA(XXServiceConfigMap.class), Mockito.isA(XXService.class))).thenReturn(xConfMap);
RangerServiceDef ran = new RangerServiceDef();
ran.setName("Test");
ServiceDBStore spy = Mockito.spy(serviceDBStore);
Mockito.doNothing().when(spy).createDefaultPolicies(rangerService);
spy.createService(rangerService);
Mockito.verify(daoManager, Mockito.atLeast(1)).getXXService();
Mockito.verify(daoManager).getXXServiceConfigMap();
}
Aggregations