@Test public void testExecuteFailure() throws InterruptedException { expect(m_reportWrapperService.validate(m_criteria, REPORT_ID)).andReturn(false); replay(m_reportWrapperService); MockRequestContext context = new MockRequestContext(); DeliveryOptions deliveryOptions = new DeliveryOptions(); deliveryOptions.setInstanceId("testExecuteFailureTrigger"); assertEquals("error",m_schedulerService.execute(REPORT_ID, m_criteria, deliveryOptions, context)); Thread.sleep(1000); verify(m_reportWrapperService); }
public String execute(String id, ReportParameters criteria, DeliveryOptions deliveryOptions, RequestContext context) { try { if (m_reportWrapperService.validate(criteria,id) == false ) { context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(PARAMETER_ERROR).build()); return ERROR; } else { SimpleTrigger trigger = new SimpleTrigger(deliveryOptions.getInstanceId(), m_triggerGroup, new Date(), null, 0, 0L); trigger.setJobName(m_jobDetail.getName()); trigger.getJobDataMap().put("criteria", (ReportParameters) criteria); trigger.getJobDataMap().put("reportId", id); trigger.getJobDataMap().put("mode", ReportMode.IMMEDIATE); trigger.getJobDataMap().put("deliveryOptions", (DeliveryOptions) deliveryOptions); try { m_scheduler.scheduleJob(trigger); } catch (SchedulerException e) { LogUtils.warnf(this, e, SCHEDULER_ERROR); context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(SCHEDULER_ERROR).build()); return ERROR; } return SUCCESS; } } catch (ReportServiceLocatorException e) { LogUtils.errorf(this, e, REPORTID_ERROR); context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(REPORTID_ERROR).build()); return ERROR; } }
DefaultSchedulerService implements InitializingBean, SchedulerService { public String execute(String id, ReportParameters criteria, DeliveryOptions deliveryOptions, RequestContext context) { try { if (m_reportWrapperService.validate(criteria,id) == false ) { context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(PARAMETER_ERROR).build()); return ERROR; } else { SimpleTrigger trigger = new SimpleTrigger(deliveryOptions.getInstanceId(), m_triggerGroup, new Date(), null, 0, 0L); trigger.setJobName(m_jobDetail.getName()); trigger.getJobDataMap().put("criteria", (ReportParameters) criteria); trigger.getJobDataMap().put("reportId", id); trigger.getJobDataMap().put("mode", ReportMode.IMMEDIATE); trigger.getJobDataMap().put("deliveryOptions", (DeliveryOptions) deliveryOptions); try { m_scheduler.scheduleJob(trigger); } catch (SchedulerException e) { LogUtils.warnf(this, e, SCHEDULER_ERROR); context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(SCHEDULER_ERROR).build()); return ERROR; } return SUCCESS; } } catch (ReportServiceLocatorException e) { LogUtils.errorf(this, e, REPORTID_ERROR); context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(REPORTID_ERROR).build()); return ERROR; } } }
DefaultSchedulerService implements InitializingBean, SchedulerService { public String execute(String id, ReportParameters criteria, DeliveryOptions deliveryOptions, RequestContext context) { try { if (m_reportWrapperService.validate(criteria,id) == false ) { context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(PARAMETER_ERROR).build()); return ERROR; } else { SimpleTrigger trigger = new SimpleTrigger(deliveryOptions.getInstanceId(), m_triggerGroup, new Date(), null, 0, 0L); trigger.setJobName(m_jobDetail.getName()); trigger.getJobDataMap().put("criteria", (ReportParameters) criteria); trigger.getJobDataMap().put("reportId", id); trigger.getJobDataMap().put("mode", ReportMode.IMMEDIATE); trigger.getJobDataMap().put("deliveryOptions", (DeliveryOptions) deliveryOptions); try { m_scheduler.scheduleJob(trigger); } catch (SchedulerException e) { LogUtils.warnf(this, e, SCHEDULER_ERROR); context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(SCHEDULER_ERROR).build()); return ERROR; } return SUCCESS; } } catch (ReportServiceLocatorException e) { LogUtils.errorf(this, e, REPORTID_ERROR); context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(REPORTID_ERROR).build()); return ERROR; } }  }
DefaultSchedulerService implements InitializingBean, SchedulerService { public String execute(String id, ReportParameters criteria, DeliveryOptions deliveryOptions, RequestContext context) { try { if (m_reportWrapperService.validate(criteria,id) == false ) { context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(PARAMETER_ERROR).build()); return ERROR; } else { SimpleTrigger trigger = new SimpleTrigger(deliveryOptions.getInstanceId(), m_triggerGroup, new Date(), null, 0, 0L); trigger.setJobName(m_jobDetail.getName()); trigger.getJobDataMap().put("criteria", (ReportParameters) criteria); trigger.getJobDataMap().put("reportId", id); trigger.getJobDataMap().put("mode", ReportMode.IMMEDIATE); trigger.getJobDataMap().put("deliveryOptions", (DeliveryOptions) deliveryOptions); try { m_scheduler.scheduleJob(trigger); } catch (SchedulerException e) { LogUtils.warnf(this, e, SCHEDULER_ERROR); context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(SCHEDULER_ERROR).build()); return ERROR; } return SUCCESS; } } catch (ReportServiceLocatorException e) { LogUtils.errorf(this, e, REPORTID_ERROR); context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(REPORTID_ERROR).build()); return ERROR; } }  @Override void afterPropertiesSet(); List<TriggerDescription> getTriggerDescriptions(); Boolean exists(String triggerName); void removeTrigger(String triggerName); void removeTriggers(String[] triggerNames); String addCronTrigger(String id, ReportParameters criteria,
            DeliveryOptions deliveryOptions,
            String cronExpression, RequestContext context); String execute(String id, ReportParameters criteria,
            DeliveryOptions deliveryOptions, RequestContext context); void setScheduler(Scheduler scheduler); void setJobDetail(JobDetail reportJob); void setTriggerGroup(String triggerGroup); void setReportWrapperService(ReportWrapperService reportWrapperService); }
DefaultSchedulerService implements InitializingBean, SchedulerService { public String execute(String id, ReportParameters criteria, DeliveryOptions deliveryOptions, RequestContext context) { try { if (m_reportWrapperService.validate(criteria,id) == false ) { context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(PARAMETER_ERROR).build()); return ERROR; } else { SimpleTrigger trigger = new SimpleTrigger(deliveryOptions.getInstanceId(), m_triggerGroup, new Date(), null, 0, 0L); trigger.setJobName(m_jobDetail.getName()); trigger.getJobDataMap().put("criteria", (ReportParameters) criteria); trigger.getJobDataMap().put("reportId", id); trigger.getJobDataMap().put("mode", ReportMode.IMMEDIATE); trigger.getJobDataMap().put("deliveryOptions", (DeliveryOptions) deliveryOptions); try { m_scheduler.scheduleJob(trigger); } catch (SchedulerException e) { LogUtils.warnf(this, e, SCHEDULER_ERROR); context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(SCHEDULER_ERROR).build()); return ERROR; } return SUCCESS; } } catch (ReportServiceLocatorException e) { LogUtils.errorf(this, e, REPORTID_ERROR); context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(REPORTID_ERROR).build()); return ERROR; } }  @Override void afterPropertiesSet(); List<TriggerDescription> getTriggerDescriptions(); Boolean exists(String triggerName); void removeTrigger(String triggerName); void removeTriggers(String[] triggerNames); String addCronTrigger(String id, ReportParameters criteria,
            DeliveryOptions deliveryOptions,
            String cronExpression, RequestContext context); String execute(String id, ReportParameters criteria,
            DeliveryOptions deliveryOptions, RequestContext context); void setScheduler(Scheduler scheduler); void setJobDetail(JobDetail reportJob); void setTriggerGroup(String triggerGroup); void setReportWrapperService(ReportWrapperService reportWrapperService);  }