@Test public void test2mapEntityToViewBean() { XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class); XXServiceDef xServiceDef = Mockito.mock(XXServiceDef.class); RangerService rangerService = rangerService(); XXService service = service(); XXServiceVersionInfoDao xServiceVersionInfoDao = Mockito.mock(XXServiceVersionInfoDao.class); XXServiceVersionInfo serviceVersionInfo = new XXServiceVersionInfo(); serviceVersionInfo.setServiceId(service.getId()); serviceVersionInfo.setPolicyVersion(service.getPolicyVersion()); serviceVersionInfo.setPolicyUpdateTime(service.getPolicyUpdateTime()); serviceVersionInfo.setTagVersion(service.getTagVersion()); serviceVersionInfo.setPolicyUpdateTime(service.getTagUpdateTime()); Mockito.when(daoManager.getXXServiceVersionInfo()).thenReturn(xServiceVersionInfoDao); Mockito.when(xServiceVersionInfoDao.findByServiceId(service.getId())).thenReturn( serviceVersionInfo); Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao); Mockito.when(xServiceDefDao.getById(service.getType())).thenReturn( xServiceDef); RangerService dbRangerService = rangerServiceService .mapEntityToViewBean(rangerService, service); Assert.assertNotNull(dbRangerService); Assert.assertEquals(dbRangerService, rangerService); Assert.assertEquals(dbRangerService.getDescription(), rangerService.getDescription()); Assert.assertEquals(dbRangerService.getGuid(), rangerService.getGuid()); Assert.assertEquals(dbRangerService.getName(), rangerService.getName()); Assert.assertEquals(dbRangerService.getId(), rangerService.getId()); Assert.assertEquals(dbRangerService.getVersion(), rangerService.getVersion()); Assert.assertEquals(dbRangerService.getType(), rangerService.getType()); Mockito.verify(daoManager).getXXServiceDef(); }
@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.setDisplayName(xObj.getDisplayName()); 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; }
RangerServiceServiceBase extends RangerBaseModelService<T, V> { @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.setDisplayName(xObj.getDisplayName()); 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; } }
RangerServiceServiceBase extends RangerBaseModelService<T, V> { @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.setDisplayName(xObj.getDisplayName()); 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; } RangerServiceServiceBase(); }
RangerServiceServiceBase extends RangerBaseModelService<T, V> { @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.setDisplayName(xObj.getDisplayName()); 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; } RangerServiceServiceBase(); RangerServiceList searchRangerServices(SearchFilter searchFilter); }
RangerServiceServiceBase extends RangerBaseModelService<T, V> { @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.setDisplayName(xObj.getDisplayName()); 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; } RangerServiceServiceBase(); RangerServiceList searchRangerServices(SearchFilter searchFilter);  }