@Test(expected = IllegalArgumentException.class) public void shouldThrowIllegalArgumentExceptionIfMotechEventIsNullInCronSchedulableJob() { CronSchedulableJob job = new CronSchedulableJob(null, "0 0 0 * * ? *", DateTime.now().plusHours(1), null, false, true); SchedulableJobValidator.validateCronSchedulableJob(job); }
public static void validateCronSchedulableJob(CronSchedulableJob job) { notNull(job, JOB_CANNOT_BE_NULL); notEmpty(job.getCronExpression(), "Cron expression cannot be null or empty!"); notNull(job.getMotechEvent(), MOTECH_EVENT_CANNOT_BE_NULL); if (!CronExpression.isValidExpression(job.getCronExpression())) { throw new MotechSchedulerException(format("Can not schedule job. Invalid Cron expression: %s", job.getCronExpression()), "scheduler.error.invalidCronExpression", Arrays.asList(job.getCronExpression())); } validateEndDate(job); }
SchedulableJobValidator { public static void validateCronSchedulableJob(CronSchedulableJob job) { notNull(job, JOB_CANNOT_BE_NULL); notEmpty(job.getCronExpression(), "Cron expression cannot be null or empty!"); notNull(job.getMotechEvent(), MOTECH_EVENT_CANNOT_BE_NULL); if (!CronExpression.isValidExpression(job.getCronExpression())) { throw new MotechSchedulerException(format("Can not schedule job. Invalid Cron expression: %s", job.getCronExpression()), "scheduler.error.invalidCronExpression", Arrays.asList(job.getCronExpression())); } validateEndDate(job); } }
SchedulableJobValidator { public static void validateCronSchedulableJob(CronSchedulableJob job) { notNull(job, JOB_CANNOT_BE_NULL); notEmpty(job.getCronExpression(), "Cron expression cannot be null or empty!"); notNull(job.getMotechEvent(), MOTECH_EVENT_CANNOT_BE_NULL); if (!CronExpression.isValidExpression(job.getCronExpression())) { throw new MotechSchedulerException(format("Can not schedule job. Invalid Cron expression: %s", job.getCronExpression()), "scheduler.error.invalidCronExpression", Arrays.asList(job.getCronExpression())); } validateEndDate(job); } private  SchedulableJobValidator(); }
SchedulableJobValidator { public static void validateCronSchedulableJob(CronSchedulableJob job) { notNull(job, JOB_CANNOT_BE_NULL); notEmpty(job.getCronExpression(), "Cron expression cannot be null or empty!"); notNull(job.getMotechEvent(), MOTECH_EVENT_CANNOT_BE_NULL); if (!CronExpression.isValidExpression(job.getCronExpression())) { throw new MotechSchedulerException(format("Can not schedule job. Invalid Cron expression: %s", job.getCronExpression()), "scheduler.error.invalidCronExpression", Arrays.asList(job.getCronExpression())); } validateEndDate(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 validateCronSchedulableJob(CronSchedulableJob job) { notNull(job, JOB_CANNOT_BE_NULL); notEmpty(job.getCronExpression(), "Cron expression cannot be null or empty!"); notNull(job.getMotechEvent(), MOTECH_EVENT_CANNOT_BE_NULL); if (!CronExpression.isValidExpression(job.getCronExpression())) { throw new MotechSchedulerException(format("Can not schedule job. Invalid Cron expression: %s", job.getCronExpression()), "scheduler.error.invalidCronExpression", Arrays.asList(job.getCronExpression())); } validateEndDate(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);  }