use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.
the class TestRangerServiceDefServiceBase method test14populateRangerContextEnricherDefToXXnullValue.
@Test
public void test14populateRangerContextEnricherDefToXXnullValue() {
RangerContextEnricherDef rangerContextEnricherDefObj = null;
XXContextEnricherDef contextEnricherDefObj = null;
XXServiceDef serviceDefObj = null;
Mockito.when(restErrorUtil.createRESTException("RangerServiceDef cannot be null.", MessageEnums.DATA_NOT_FOUND)).thenThrow(new WebApplicationException());
thrown.expect(WebApplicationException.class);
XXContextEnricherDef dbContextEnricherDef = rangerServiceDefService.populateRangerContextEnricherDefToXX(rangerContextEnricherDefObj, contextEnricherDefObj, serviceDefObj, 1);
Assert.assertNull(dbContextEnricherDef);
}
use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.
the class TestRangerServiceDefServiceBase method serviceDef.
private XXServiceDef serviceDef() {
XXServiceDef xServiceDef = new XXServiceDef();
xServiceDef.setAddedByUserId(Id);
xServiceDef.setCreateTime(new Date());
xServiceDef.setDescription("HDFS Repository");
xServiceDef.setGuid("0d047247-bafe-4cf8-8e9b-d5d377284b2d");
xServiceDef.setId(Id);
xServiceDef.setImplclassname("RangerServiceHdfs");
xServiceDef.setIsEnabled(true);
xServiceDef.setLabel("HDFS Repository");
xServiceDef.setName("hdfs");
xServiceDef.setRbkeydescription(null);
xServiceDef.setRbkeylabel(null);
xServiceDef.setUpdatedByUserId(Id);
xServiceDef.setUpdateTime(new Date());
return xServiceDef;
}
use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.
the class TestRangerServiceDefServiceBase method test10populateRangerPolicyConditionDefToXX.
@Test
public void test10populateRangerPolicyConditionDefToXX() {
RangerPolicyConditionDef rangerConditionDefvObj = new RangerPolicyConditionDef();
rangerConditionDefvObj.setDescription("Countries");
rangerConditionDefvObj.setEvaluator("COUNTRY");
rangerConditionDefvObj.setLabel("Countries");
rangerConditionDefvObj.setName("country");
rangerConditionDefvObj.setRbKeyDescription(null);
rangerConditionDefvObj.setRbKeyLabel(null);
XXPolicyConditionDef policyConditionDefObj = new XXPolicyConditionDef();
policyConditionDefObj.setAddedByUserId(Id);
policyConditionDefObj.setCreateTime(new Date());
policyConditionDefObj.setDefid(Id);
policyConditionDefObj.setDescription("policy");
policyConditionDefObj.setId(Id);
policyConditionDefObj.setName("country");
policyConditionDefObj.setOrder(0);
policyConditionDefObj.setUpdatedByUserId(Id);
policyConditionDefObj.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((XXPolicyConditionDef) rangerAuditFields.populateAuditFields(policyConditionDefObj, serviceDefObj)).thenReturn(policyConditionDefObj);
XXPolicyConditionDef dbPolicyConditionDef = rangerServiceDefService.populateRangerPolicyConditionDefToXX(rangerConditionDefvObj, policyConditionDefObj, serviceDefObj, 1);
Assert.assertNotNull(dbPolicyConditionDef);
Assert.assertEquals(dbPolicyConditionDef.getName(), policyConditionDefObj.getName());
Assert.assertEquals(dbPolicyConditionDef.getDescription(), policyConditionDefObj.getDescription());
Assert.assertEquals(dbPolicyConditionDef.getEvaluator(), policyConditionDefObj.getEvaluator());
Assert.assertEquals(dbPolicyConditionDef.getLabel(), policyConditionDefObj.getLabel());
Assert.assertEquals(dbPolicyConditionDef.getId(), policyConditionDefObj.getId());
Assert.assertEquals(dbPolicyConditionDef.getRbkeydescription(), policyConditionDefObj.getRbkeydescription());
Assert.assertEquals(dbPolicyConditionDef.getOrder(), policyConditionDefObj.getOrder());
Assert.assertEquals(dbPolicyConditionDef.getUpdatedByUserId(), policyConditionDefObj.getUpdatedByUserId());
Assert.assertEquals(dbPolicyConditionDef.getUpdateTime(), policyConditionDefObj.getUpdateTime());
}
use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.
the class TestRangerServiceService method test8GetTransactionLogDelete.
@Test
public void test8GetTransactionLogDelete() {
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, 3);
Assert.assertNotNull(dbXXTrxLogList);
}
use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.
the class TestRangerServiceService method test4GetPopulatedViewObject.
@Test
public void test4GetPopulatedViewObject() {
XXServiceConfigMapDao xServiceConfigMapDao = Mockito.mock(XXServiceConfigMapDao.class);
XXPortalUserDao xPortalUserDao = Mockito.mock(XXPortalUserDao.class);
XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
XXService xService = xService();
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);
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.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);
RangerService dbService = serviceService.getPopulatedViewObject(xService);
Assert.assertNotNull(dbService);
Assert.assertEquals(userId, dbService.getId());
Assert.assertEquals(xService.getAddedByUserId(), dbService.getId());
Assert.assertEquals(xService.getId(), dbService.getId());
Assert.assertEquals(xService.getDescription(), dbService.getDescription());
Assert.assertEquals(xService.getGuid(), dbService.getGuid());
Assert.assertEquals(xService.getName(), dbService.getName());
Assert.assertEquals(xService.getPolicyUpdateTime(), dbService.getPolicyUpdateTime());
Assert.assertEquals(xService.getPolicyVersion(), dbService.getPolicyVersion());
Assert.assertEquals(xService.getVersion(), dbService.getVersion());
Mockito.verify(daoManager).getXXServiceDef();
Mockito.verify(daoManager).getXXServiceConfigMap();
}
Aggregations