use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.
the class TestRangerServiceDefServiceBase method test8populateRangerAccessTypeDefToXXNullValue.
@Test
public void test8populateRangerAccessTypeDefToXXNullValue() {
RangerAccessTypeDef rangerAccessTypeDefObj = null;
XXAccessTypeDef accessTypeDefObj = null;
XXServiceDef serviceDefObj = null;
Mockito.when(restErrorUtil.createRESTException("RangerServiceDef cannot be null.", MessageEnums.DATA_NOT_FOUND)).thenThrow(new WebApplicationException());
thrown.expect(WebApplicationException.class);
XXAccessTypeDef dbAccessTypeDef = rangerServiceDefService.populateRangerAccessTypeDefToXX(rangerAccessTypeDefObj, accessTypeDefObj, serviceDefObj, 1);
Assert.assertNull(dbAccessTypeDef);
}
use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.
the class TestRangerServiceDefServiceBase method test17populateRangerEnumDefToXXnullValue.
@Test
public void test17populateRangerEnumDefToXXnullValue() {
RangerEnumDef rangerEnumDefObj = null;
XXEnumDef enumDefObj = null;
XXServiceDef serviceDefObj = null;
Mockito.when(restErrorUtil.createRESTException("RangerServiceDef cannot be null.", MessageEnums.DATA_NOT_FOUND)).thenThrow(new WebApplicationException());
thrown.expect(WebApplicationException.class);
XXEnumDef dbEnumDef = rangerServiceDefService.populateRangerEnumDefToXX(rangerEnumDefObj, enumDefObj, serviceDefObj, 1);
Assert.assertNull(dbEnumDef);
}
use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.
the class TestRangerServiceDefServiceBase method test13populateRangerContextEnricherDefToXX.
@Test
public void test13populateRangerContextEnricherDefToXX() {
RangerContextEnricherDef rangerContextEnricherDefObj = new RangerContextEnricherDef();
rangerContextEnricherDefObj.setName("country-provider");
rangerContextEnricherDefObj.setEnricher("RangerCountryProvider");
XXContextEnricherDef contextEnricherDefObj = new XXContextEnricherDef();
contextEnricherDefObj.setAddedByUserId(Id);
contextEnricherDefObj.setCreateTime(new Date());
contextEnricherDefObj.setDefid(Id);
contextEnricherDefObj.setId(Id);
contextEnricherDefObj.setName("country-provider");
contextEnricherDefObj.setEnricherOptions("contextName=COUNTRY;dataFile=/etc/ranger/data/userCountry.properties");
contextEnricherDefObj.setEnricher("RangerCountryProvider");
contextEnricherDefObj.setOrder(null);
contextEnricherDefObj.setUpdatedByUserId(Id);
contextEnricherDefObj.setUpdateTime(new Date());
XXServiceDef serviceDefObj = new XXServiceDef();
serviceDefObj.setAddedByUserId(Id);
serviceDefObj.setCreateTime(new Date());
serviceDefObj.setDescription("HDFS Repository");
serviceDefObj.setGuid("1427365526516_835_0");
serviceDefObj.setId(Id);
Mockito.when((XXContextEnricherDef) rangerAuditFields.populateAuditFields(contextEnricherDefObj, serviceDefObj)).thenReturn(contextEnricherDefObj);
XXContextEnricherDef dbContextEnricherDef = rangerServiceDefService.populateRangerContextEnricherDefToXX(rangerContextEnricherDefObj, contextEnricherDefObj, serviceDefObj, 1);
Assert.assertNotNull(dbContextEnricherDef);
Assert.assertEquals(dbContextEnricherDef.getEnricher(), contextEnricherDefObj.getEnricher());
Assert.assertEquals(dbContextEnricherDef.getEnricherOptions(), contextEnricherDefObj.getEnricherOptions());
Assert.assertEquals(dbContextEnricherDef.getName(), contextEnricherDefObj.getName());
Assert.assertEquals(dbContextEnricherDef.getCreateTime(), contextEnricherDefObj.getCreateTime());
Assert.assertEquals(dbContextEnricherDef.getId(), contextEnricherDefObj.getId());
Assert.assertEquals(dbContextEnricherDef.getOrder(), contextEnricherDefObj.getOrder());
Assert.assertEquals(dbContextEnricherDef.getUpdatedByUserId(), contextEnricherDefObj.getUpdatedByUserId());
Assert.assertEquals(dbContextEnricherDef.getUpdateTime(), contextEnricherDefObj.getUpdateTime());
}
use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.
the class TestRangerServiceService method test5GetAllServices.
@Test
public void test5GetAllServices() {
XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
XXPortalUserDao xPortalUserDao = Mockito.mock(XXPortalUserDao.class);
XXServiceConfigMapDao xServiceConfigMapDao = Mockito.mock(XXServiceConfigMapDao.class);
XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
String name = "fdfdfds";
List<XXServiceConfigMap> svcConfigMapList = new ArrayList<XXServiceConfigMap>();
XXServiceConfigMap xConfMap = new XXServiceConfigMap();
xConfMap.setAddedByUserId(null);
xConfMap.setConfigkey(name);
xConfMap.setConfigvalue(name);
xConfMap.setCreateTime(new Date());
xConfMap.setServiceId(null);
xConfMap.setUpdatedByUserId(null);
xConfMap.setUpdateTime(new Date());
svcConfigMapList.add(xConfMap);
List<XXService> xServiceList = new ArrayList<XXService>();
XXService xService = xService();
xServiceList.add(xService);
XXPortalUser tUser = new XXPortalUser();
tUser.setAddedByUserId(userId);
tUser.setCreateTime(new Date());
tUser.setEmailAddress("test@gmail.com");
tUser.setFirstName(name);
tUser.setId(userId);
tUser.setLastName(name);
XXServiceDef xServiceDef = new XXServiceDef();
xServiceDef.setAddedByUserId(userId);
xServiceDef.setCreateTime(new Date());
xServiceDef.setDescription("test");
xServiceDef.setGuid("1427365526516_835_0");
xServiceDef.setId(userId);
XXServiceVersionInfoDao xServiceVersionInfoDao = Mockito.mock(XXServiceVersionInfoDao.class);
XXServiceVersionInfo serviceVersionInfo = new XXServiceVersionInfo();
serviceVersionInfo.setServiceId(xService.getId());
serviceVersionInfo.setPolicyVersion(xService.getPolicyVersion());
serviceVersionInfo.setPolicyUpdateTime(xService.getPolicyUpdateTime());
serviceVersionInfo.setTagVersion(xService.getTagVersion());
serviceVersionInfo.setTagUpdateTime(xService.getTagUpdateTime());
Mockito.when(daoManager.getXXServiceVersionInfo()).thenReturn(xServiceVersionInfoDao);
Mockito.when(xServiceVersionInfoDao.findByServiceId(xService.getId())).thenReturn(serviceVersionInfo);
Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
Mockito.when(xServiceDao.getAll()).thenReturn(xServiceList);
Mockito.when(daoManager.getXXPortalUser()).thenReturn(xPortalUserDao);
Mockito.when(xPortalUserDao.getById(userId)).thenReturn(tUser);
Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
Mockito.when(xServiceDefDao.getById(xService.getType())).thenReturn(xServiceDef);
Mockito.when(daoManager.getXXServiceConfigMap()).thenReturn(xServiceConfigMapDao);
Mockito.when(xServiceConfigMapDao.findByServiceId(xService.getId())).thenReturn(svcConfigMapList);
List<RangerService> dbServiceList = serviceService.getAllServices();
Assert.assertNotNull(dbServiceList);
Mockito.verify(daoManager).getXXServiceDef();
Mockito.verify(daoManager).getXXServiceConfigMap();
}
use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.
the class TestRangerServiceService method test6GetTransactionLogCreate.
@Test
public void test6GetTransactionLogCreate() {
XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
XXServiceDef xServiceDef = Mockito.mock(XXServiceDef.class);
RangerService rangerService = rangerService();
Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
Mockito.when(xServiceDefDao.findByName(rangerService.getType())).thenReturn(xServiceDef);
List<XXTrxLog> dbXXTrxLogList = serviceService.getTransactionLog(rangerService, 1);
Assert.assertNotNull(dbXXTrxLogList);
}
Aggregations