use of org.apache.ranger.entity.XXService in project ranger by apache.
the class RangerServiceService method preDelete.
protected XXService preDelete(Long id) {
XXService ret = super.preDelete(id);
if (ret != null) {
XXServiceVersionInfoDao serviceVersionInfoDao = daoMgr.getXXServiceVersionInfo();
XXServiceVersionInfo serviceVersionInfo = serviceVersionInfoDao.findByServiceId(id);
if (serviceVersionInfo != null) {
serviceVersionInfoDao.remove(serviceVersionInfo.getId());
}
}
return ret;
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class RangerServiceServiceBase method mapEntityToViewBean.
@Override
protected V mapEntityToViewBean(V vObj, T xObj) {
XXServiceDef xServiceDef = daoMgr.getXXServiceDef().getById(xObj.getType());
XXService xTagService = xObj.getTagService() != null ? daoMgr.getXXService().getById(xObj.getTagService()) : null;
vObj.setType(xServiceDef.getName());
vObj.setGuid(xObj.getGuid());
vObj.setVersion(xObj.getVersion());
vObj.setName(xObj.getName());
vObj.setDescription(xObj.getDescription());
vObj.setTagService(xTagService != null ? xTagService.getName() : null);
XXServiceVersionInfo versionInfoObj = daoMgr.getXXServiceVersionInfo().findByServiceId(xObj.getId());
if (versionInfoObj != null) {
vObj.setPolicyVersion(versionInfoObj.getPolicyVersion());
vObj.setTagVersion(versionInfoObj.getTagVersion());
vObj.setPolicyUpdateTime(versionInfoObj.getPolicyUpdateTime());
vObj.setTagUpdateTime(versionInfoObj.getTagUpdateTime());
} else {
vObj.setPolicyVersion(xObj.getPolicyVersion());
vObj.setTagVersion(xObj.getTagVersion());
vObj.setPolicyUpdateTime(xObj.getPolicyUpdateTime());
vObj.setTagUpdateTime(xObj.getTagUpdateTime());
}
vObj.setIsEnabled(xObj.getIsenabled());
return vObj;
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class TestRangerPolicyService method test8getTransactionLog.
@Test
public void test8getTransactionLog() {
XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
RangerPolicy rangerPolicy = rangerPolicy();
XXService xService = xService();
Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
Mockito.when(xServiceDao.findByName(rangerPolicy.getService())).thenReturn(xService);
List<XXTrxLog> dbXXTrxLogList = policyService.getTransactionLog(rangerPolicy, 1);
Assert.assertNotNull(dbXXTrxLogList);
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class TestRangerPolicyServiceBase method test1mapViewToEntityBean.
@Test
public void test1mapViewToEntityBean() {
XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
XXService xService = Mockito.mock(XXService.class);
RangerPolicy rangerPolicy = rangerPolicy();
XXPolicy policy = policy();
int OPERATION_CONTEXT = 0;
Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
Mockito.when(xServiceDao.findByName(rangerPolicy.getService())).thenReturn(xService);
XXPolicy dbPolicy = policyService.mapViewToEntityBean(rangerPolicy, policy, OPERATION_CONTEXT);
Assert.assertNotNull(dbPolicy);
Assert.assertEquals(dbPolicy.getId(), policy.getId());
Assert.assertEquals(dbPolicy.getGuid(), policy.getGuid());
Assert.assertEquals(dbPolicy.getName(), policy.getName());
Assert.assertEquals(dbPolicy.getAddedByUserId(), policy.getAddedByUserId());
Assert.assertEquals(dbPolicy.getIsEnabled(), policy.getIsEnabled());
Assert.assertEquals(dbPolicy.getVersion(), policy.getVersion());
Assert.assertEquals(dbPolicy.getDescription(), policy.getDescription());
Mockito.verify(daoManager).getXXService();
}
use of org.apache.ranger.entity.XXService 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