@Test(expected = MotechSchedulerException.class) public void shouldThrowMotechSchedulerExceptionIfRepeatIntervalIsZero() { RepeatingSchedulableJob job = new RepeatingSchedulableJob(motechEvent, 10, 0, DateTime.now().plusHours(1), null, true, true, false); SchedulableJobValidator.validateRepeatingSchedulableJob(job); }
public static void validateRepeatingSchedulableJob(RepeatingSchedulableJob job) { notNull(job, JOB_CANNOT_BE_NULL); notNull(job.getRepeatIntervalInSeconds(), "Repeat interval cannot be null!"); if (job.getRepeatIntervalInSeconds() == 0) { throw new MotechSchedulerException( "Invalid RepeatingSchedulableJob. The job repeat interval in seconds can not be 0 ", "scheduler.error.repeatIntervalIsZero", new ArrayList<>()); } validateEndingSchedulableJob(job); }
SchedulableJobValidator { public static void validateRepeatingSchedulableJob(RepeatingSchedulableJob job) { notNull(job, JOB_CANNOT_BE_NULL); notNull(job.getRepeatIntervalInSeconds(), "Repeat interval cannot be null!"); if (job.getRepeatIntervalInSeconds() == 0) { throw new MotechSchedulerException( "Invalid RepeatingSchedulableJob. The job repeat interval in seconds can not be 0 ", "scheduler.error.repeatIntervalIsZero", new ArrayList<>()); } validateEndingSchedulableJob(job); } }
SchedulableJobValidator { public static void validateRepeatingSchedulableJob(RepeatingSchedulableJob job) { notNull(job, JOB_CANNOT_BE_NULL); notNull(job.getRepeatIntervalInSeconds(), "Repeat interval cannot be null!"); if (job.getRepeatIntervalInSeconds() == 0) { throw new MotechSchedulerException( "Invalid RepeatingSchedulableJob. The job repeat interval in seconds can not be 0 ", "scheduler.error.repeatIntervalIsZero", new ArrayList<>()); } validateEndingSchedulableJob(job); } private  SchedulableJobValidator(); }
SchedulableJobValidator { public static void validateRepeatingSchedulableJob(RepeatingSchedulableJob job) { notNull(job, JOB_CANNOT_BE_NULL); notNull(job.getRepeatIntervalInSeconds(), "Repeat interval cannot be null!"); if (job.getRepeatIntervalInSeconds() == 0) { throw new MotechSchedulerException( "Invalid RepeatingSchedulableJob. The job repeat interval in seconds can not be 0 ", "scheduler.error.repeatIntervalIsZero", new ArrayList<>()); } validateEndingSchedulableJob(job); } private  SchedulableJobValidator(); static void validateCronSchedulableJob(CronSchedulableJob job); static void validateRepeatingSchedulableJob(RepeatingSchedulableJob job); static void validateRepeatingPeriodSchedulableJob(RepeatingPeriodSchedulableJob job); static void validateRunOnceSchedulableJob(RunOnceSchedulableJob job); static void validateDayOfWeekSchedulableJob(DayOfWeekSchedulableJob job); }
SchedulableJobValidator { public static void validateRepeatingSchedulableJob(RepeatingSchedulableJob job) { notNull(job, JOB_CANNOT_BE_NULL); notNull(job.getRepeatIntervalInSeconds(), "Repeat interval cannot be null!"); if (job.getRepeatIntervalInSeconds() == 0) { throw new MotechSchedulerException( "Invalid RepeatingSchedulableJob. The job repeat interval in seconds can not be 0 ", "scheduler.error.repeatIntervalIsZero", new ArrayList<>()); } validateEndingSchedulableJob(job); } private  SchedulableJobValidator(); static void validateCronSchedulableJob(CronSchedulableJob job); static void validateRepeatingSchedulableJob(RepeatingSchedulableJob job); static void validateRepeatingPeriodSchedulableJob(RepeatingPeriodSchedulableJob job); static void validateRunOnceSchedulableJob(RunOnceSchedulableJob job); static void validateDayOfWeekSchedulableJob(DayOfWeekSchedulableJob job);  }