@Test public void test3PopulateViewBean() { 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.populateViewBean(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(); }
@Override protected RangerService populateViewBean(XXService xService) { RangerService vService = super.populateViewBean(xService); HashMap<String, String> configs = new HashMap<String, String>(); List<XXServiceConfigMap> svcConfigMapList = daoMgr.getXXServiceConfigMap() .findByServiceId(xService.getId()); for(XXServiceConfigMap svcConfMap : svcConfigMapList) { String configValue = svcConfMap.getConfigvalue(); if(StringUtils.equalsIgnoreCase(svcConfMap.getConfigkey(), ServiceDBStore.CONFIG_KEY_PASSWORD)) { configValue = ServiceDBStore.HIDDEN_PASSWORD_STR; } configs.put(svcConfMap.getConfigkey(), configValue); } vService.setConfigs(configs); return vService; }
RangerServiceService extends RangerServiceServiceBase<XXService, RangerService> { @Override protected RangerService populateViewBean(XXService xService) { RangerService vService = super.populateViewBean(xService); HashMap<String, String> configs = new HashMap<String, String>(); List<XXServiceConfigMap> svcConfigMapList = daoMgr.getXXServiceConfigMap() .findByServiceId(xService.getId()); for(XXServiceConfigMap svcConfMap : svcConfigMapList) { String configValue = svcConfMap.getConfigvalue(); if(StringUtils.equalsIgnoreCase(svcConfMap.getConfigkey(), ServiceDBStore.CONFIG_KEY_PASSWORD)) { configValue = ServiceDBStore.HIDDEN_PASSWORD_STR; } configs.put(svcConfMap.getConfigkey(), configValue); } vService.setConfigs(configs); return vService; } }
RangerServiceService extends RangerServiceServiceBase<XXService, RangerService> { @Override protected RangerService populateViewBean(XXService xService) { RangerService vService = super.populateViewBean(xService); HashMap<String, String> configs = new HashMap<String, String>(); List<XXServiceConfigMap> svcConfigMapList = daoMgr.getXXServiceConfigMap() .findByServiceId(xService.getId()); for(XXServiceConfigMap svcConfMap : svcConfigMapList) { String configValue = svcConfMap.getConfigvalue(); if(StringUtils.equalsIgnoreCase(svcConfMap.getConfigkey(), ServiceDBStore.CONFIG_KEY_PASSWORD)) { configValue = ServiceDBStore.HIDDEN_PASSWORD_STR; } configs.put(svcConfMap.getConfigkey(), configValue); } vService.setConfigs(configs); return vService; } RangerServiceService(); }
RangerServiceService extends RangerServiceServiceBase<XXService, RangerService> { @Override protected RangerService populateViewBean(XXService xService) { RangerService vService = super.populateViewBean(xService); HashMap<String, String> configs = new HashMap<String, String>(); List<XXServiceConfigMap> svcConfigMapList = daoMgr.getXXServiceConfigMap() .findByServiceId(xService.getId()); for(XXServiceConfigMap svcConfMap : svcConfigMapList) { String configValue = svcConfMap.getConfigvalue(); if(StringUtils.equalsIgnoreCase(svcConfMap.getConfigkey(), ServiceDBStore.CONFIG_KEY_PASSWORD)) { configValue = ServiceDBStore.HIDDEN_PASSWORD_STR; } configs.put(svcConfMap.getConfigkey(), configValue); } vService.setConfigs(configs); return vService; } RangerServiceService(); RangerService getPopulatedViewObject(XXService xService); List<RangerService> getAllServices(); List<XXTrxLog> getTransactionLog(RangerService vService, int action); List<XXTrxLog> getTransactionLog(RangerService vObj, XXService mObj, int action); Map<String, String> getConfigsWithDecryptedPassword(RangerService service); RangerService postCreate(XXService xObj); }
RangerServiceService extends RangerServiceServiceBase<XXService, RangerService> { @Override protected RangerService populateViewBean(XXService xService) { RangerService vService = super.populateViewBean(xService); HashMap<String, String> configs = new HashMap<String, String>(); List<XXServiceConfigMap> svcConfigMapList = daoMgr.getXXServiceConfigMap() .findByServiceId(xService.getId()); for(XXServiceConfigMap svcConfMap : svcConfigMapList) { String configValue = svcConfMap.getConfigvalue(); if(StringUtils.equalsIgnoreCase(svcConfMap.getConfigkey(), ServiceDBStore.CONFIG_KEY_PASSWORD)) { configValue = ServiceDBStore.HIDDEN_PASSWORD_STR; } configs.put(svcConfMap.getConfigkey(), configValue); } vService.setConfigs(configs); return vService; } RangerServiceService(); RangerService getPopulatedViewObject(XXService xService); List<RangerService> getAllServices(); List<XXTrxLog> getTransactionLog(RangerService vService, int action); List<XXTrxLog> getTransactionLog(RangerService vObj, XXService mObj, int action); Map<String, String> getConfigsWithDecryptedPassword(RangerService service); RangerService postCreate(XXService xObj);  }