@Test public void testNullCommandObjectId() { StatisticsReportCommand command = new StatisticsReportCommand(); BindException errors = new BindException(command, ""); ThrowableAnticipator ta = new ThrowableAnticipator(); ta.anticipate(new IllegalArgumentException("id property on command object cannot be null")); m_mocks.replayAll(); try { m_service.getReport(command , errors); } catch (Throwable t) { ta.throwableReceived(t); } ta.verifyAnticipated(); }
public StatisticsReportModel getReport(StatisticsReportCommand command, BindException errors) { StatisticsReportModel model = new StatisticsReportModel(); model.setErrors(errors); if (errors.hasErrors()) { return model; } Assert.notNull(command.getId(), "id property on command object cannot be null"); StatisticsReport report = m_statisticsReportDao.load(command.getId()); model.setReport(report); m_statisticsReportDao.initialize(report); final Set<StatisticsReportData> data = report.getData(); m_statisticsReportDao.initialize(data); for (StatisticsReportData reportDatum : data) { Datum d = new Datum(); d.setValue(reportDatum.getValue()); OnmsResource resource = m_resourceDao.getResourceById(reportDatum.getResourceId()); if (resource == null) { ThreadCategory.getInstance(getClass()).warn("Could not find resource for statistics report: " + reportDatum.getResourceId()); } else { d.setResource(resource); } model.addData(d); } return model; }
DefaultStatisticsReportService implements StatisticsReportService, InitializingBean { public StatisticsReportModel getReport(StatisticsReportCommand command, BindException errors) { StatisticsReportModel model = new StatisticsReportModel(); model.setErrors(errors); if (errors.hasErrors()) { return model; } Assert.notNull(command.getId(), "id property on command object cannot be null"); StatisticsReport report = m_statisticsReportDao.load(command.getId()); model.setReport(report); m_statisticsReportDao.initialize(report); final Set<StatisticsReportData> data = report.getData(); m_statisticsReportDao.initialize(data); for (StatisticsReportData reportDatum : data) { Datum d = new Datum(); d.setValue(reportDatum.getValue()); OnmsResource resource = m_resourceDao.getResourceById(reportDatum.getResourceId()); if (resource == null) { ThreadCategory.getInstance(getClass()).warn("Could not find resource for statistics report: " + reportDatum.getResourceId()); } else { d.setResource(resource); } model.addData(d); } return model; } }
DefaultStatisticsReportService implements StatisticsReportService, InitializingBean { public StatisticsReportModel getReport(StatisticsReportCommand command, BindException errors) { StatisticsReportModel model = new StatisticsReportModel(); model.setErrors(errors); if (errors.hasErrors()) { return model; } Assert.notNull(command.getId(), "id property on command object cannot be null"); StatisticsReport report = m_statisticsReportDao.load(command.getId()); model.setReport(report); m_statisticsReportDao.initialize(report); final Set<StatisticsReportData> data = report.getData(); m_statisticsReportDao.initialize(data); for (StatisticsReportData reportDatum : data) { Datum d = new Datum(); d.setValue(reportDatum.getValue()); OnmsResource resource = m_resourceDao.getResourceById(reportDatum.getResourceId()); if (resource == null) { ThreadCategory.getInstance(getClass()).warn("Could not find resource for statistics report: " + reportDatum.getResourceId()); } else { d.setResource(resource); } model.addData(d); } return model; }  }
DefaultStatisticsReportService implements StatisticsReportService, InitializingBean { public StatisticsReportModel getReport(StatisticsReportCommand command, BindException errors) { StatisticsReportModel model = new StatisticsReportModel(); model.setErrors(errors); if (errors.hasErrors()) { return model; } Assert.notNull(command.getId(), "id property on command object cannot be null"); StatisticsReport report = m_statisticsReportDao.load(command.getId()); model.setReport(report); m_statisticsReportDao.initialize(report); final Set<StatisticsReportData> data = report.getData(); m_statisticsReportDao.initialize(data); for (StatisticsReportData reportDatum : data) { Datum d = new Datum(); d.setValue(reportDatum.getValue()); OnmsResource resource = m_resourceDao.getResourceById(reportDatum.getResourceId()); if (resource == null) { ThreadCategory.getInstance(getClass()).warn("Could not find resource for statistics report: " + reportDatum.getResourceId()); } else { d.setResource(resource); } model.addData(d); } return model; }  List<StatisticsReport> getStatisticsReports(); StatisticsReportModel getReport(StatisticsReportCommand command, BindException errors); @Override void afterPropertiesSet(); StatisticsReportDao getStatisticsReportDao(); void setStatisticsReportDao(StatisticsReportDao statisticsReportDao); ResourceDao getResourceDao(); void setResourceDao(ResourceDao resourceDao); }
DefaultStatisticsReportService implements StatisticsReportService, InitializingBean { public StatisticsReportModel getReport(StatisticsReportCommand command, BindException errors) { StatisticsReportModel model = new StatisticsReportModel(); model.setErrors(errors); if (errors.hasErrors()) { return model; } Assert.notNull(command.getId(), "id property on command object cannot be null"); StatisticsReport report = m_statisticsReportDao.load(command.getId()); model.setReport(report); m_statisticsReportDao.initialize(report); final Set<StatisticsReportData> data = report.getData(); m_statisticsReportDao.initialize(data); for (StatisticsReportData reportDatum : data) { Datum d = new Datum(); d.setValue(reportDatum.getValue()); OnmsResource resource = m_resourceDao.getResourceById(reportDatum.getResourceId()); if (resource == null) { ThreadCategory.getInstance(getClass()).warn("Could not find resource for statistics report: " + reportDatum.getResourceId()); } else { d.setResource(resource); } model.addData(d); } return model; }  List<StatisticsReport> getStatisticsReports(); StatisticsReportModel getReport(StatisticsReportCommand command, BindException errors); @Override void afterPropertiesSet(); StatisticsReportDao getStatisticsReportDao(); void setStatisticsReportDao(StatisticsReportDao statisticsReportDao); ResourceDao getResourceDao(); void setResourceDao(ResourceDao resourceDao);  }