@Test public void assertGetNextFireTimeWhenSchedulerExceptionOccur() throws NoSuchFieldException, SchedulerException { ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); ReflectionUtils.setFieldValue(jobScheduleController, "jobDetail", jobDetail); JobKey jobKey = new JobKey("testJob"); when(jobDetail.getKey()).thenReturn(jobKey); doThrow(SchedulerException.class).when(scheduler).getTriggersOfJob(jobKey); assertNull(jobScheduleController.getNextFireTime()); }
public Date getNextFireTime() { List<? extends Trigger> triggers; try { triggers = scheduler.getTriggersOfJob(jobDetail.getKey()); } catch (final SchedulerException ex) { return null; } Date result = null; for (Trigger each : triggers) { Date nextFireTime = each.getNextFireTime(); if (null == nextFireTime) { continue; } if (null == result) { result = nextFireTime; } else if (nextFireTime.getTime() < result.getTime()) { result = nextFireTime; } } return result; }
JobScheduleController { public Date getNextFireTime() { List<? extends Trigger> triggers; try { triggers = scheduler.getTriggersOfJob(jobDetail.getKey()); } catch (final SchedulerException ex) { return null; } Date result = null; for (Trigger each : triggers) { Date nextFireTime = each.getNextFireTime(); if (null == nextFireTime) { continue; } if (null == result) { result = nextFireTime; } else if (nextFireTime.getTime() < result.getTime()) { result = nextFireTime; } } return result; } }
JobScheduleController { public Date getNextFireTime() { List<? extends Trigger> triggers; try { triggers = scheduler.getTriggersOfJob(jobDetail.getKey()); } catch (final SchedulerException ex) { return null; } Date result = null; for (Trigger each : triggers) { Date nextFireTime = each.getNextFireTime(); if (null == nextFireTime) { continue; } if (null == result) { result = nextFireTime; } else if (nextFireTime.getTime() < result.getTime()) { result = nextFireTime; } } return result; }  }
JobScheduleController { public Date getNextFireTime() { List<? extends Trigger> triggers; try { triggers = scheduler.getTriggersOfJob(jobDetail.getKey()); } catch (final SchedulerException ex) { return null; } Date result = null; for (Trigger each : triggers) { Date nextFireTime = each.getNextFireTime(); if (null == nextFireTime) { continue; } if (null == result) { result = nextFireTime; } else if (nextFireTime.getTime() < result.getTime()) { result = nextFireTime; } } return result; }  void scheduleJob(final String cronExpression); void rescheduleJob(final String cronExpression); Date getNextFireTime(); void pauseJob(); void resumeJob(); void triggerJob(); void shutdown(); }
JobScheduleController { public Date getNextFireTime() { List<? extends Trigger> triggers; try { triggers = scheduler.getTriggersOfJob(jobDetail.getKey()); } catch (final SchedulerException ex) { return null; } Date result = null; for (Trigger each : triggers) { Date nextFireTime = each.getNextFireTime(); if (null == nextFireTime) { continue; } if (null == result) { result = nextFireTime; } else if (nextFireTime.getTime() < result.getTime()) { result = nextFireTime; } } return result; }  void scheduleJob(final String cronExpression); void rescheduleJob(final String cronExpression); Date getNextFireTime(); void pauseJob(); void resumeJob(); void triggerJob(); void shutdown();  }