Search in sources :

Example 6 with DayOfWeekSchedulableJob

use of org.motechproject.scheduler.contract.DayOfWeekSchedulableJob in project motech by motech.

the class SchedulableJobValidatorTest method shouldValidateDayOfWeekSchedulableJob.

@Test
public void shouldValidateDayOfWeekSchedulableJob() {
    DayOfWeekSchedulableJob job = new DayOfWeekSchedulableJob(motechEvent, DateTime.now(), null, new ArrayList<>(), Time.valueOf("16:15"), false, true);
    SchedulableJobValidator.validateDayOfWeekSchedulableJob(job);
}
Also used : DayOfWeekSchedulableJob(org.motechproject.scheduler.contract.DayOfWeekSchedulableJob) Test(org.junit.Test)

Example 7 with DayOfWeekSchedulableJob

use of org.motechproject.scheduler.contract.DayOfWeekSchedulableJob in project motech by motech.

the class SchedulableJobValidatorTest method shouldThrowIllegalArgumentExceptionIfStartDateIsNullInDayOfWeekSchedulableJob.

@Test(expected = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionIfStartDateIsNullInDayOfWeekSchedulableJob() {
    DayOfWeekSchedulableJob job = new DayOfWeekSchedulableJob(motechEvent, null, null, new ArrayList<>(), Time.valueOf("16:15"), false, true);
    SchedulableJobValidator.validateDayOfWeekSchedulableJob(job);
}
Also used : DayOfWeekSchedulableJob(org.motechproject.scheduler.contract.DayOfWeekSchedulableJob) Test(org.junit.Test)

Example 8 with DayOfWeekSchedulableJob

use of org.motechproject.scheduler.contract.DayOfWeekSchedulableJob in project motech by motech.

the class SchedulableJobValidatorTest method shouldThrowIllegalArgumentExceptionIfMotechEventIsNullInDayOfWeekSchedulableJob.

@Test(expected = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionIfMotechEventIsNullInDayOfWeekSchedulableJob() {
    DayOfWeekSchedulableJob job = new DayOfWeekSchedulableJob(null, DateTime.now(), null, new ArrayList<>(), Time.valueOf("16:15"), false, true);
    SchedulableJobValidator.validateDayOfWeekSchedulableJob(job);
}
Also used : DayOfWeekSchedulableJob(org.motechproject.scheduler.contract.DayOfWeekSchedulableJob) Test(org.junit.Test)

Example 9 with DayOfWeekSchedulableJob

use of org.motechproject.scheduler.contract.DayOfWeekSchedulableJob in project motech by motech.

the class MotechSchedulerActionProxyServiceImpl method scheduleDayOfWeekJob.

@Override
public void scheduleDayOfWeekJob(String subject, Map<Object, Object> parameters, DateTime start, DateTime end, List<Object> days, DateTime time, Boolean ignorePastFiresAtStart) {
    MotechEvent motechEvent = new MotechEvent(subject, createMotechEventParameters(parameters));
    Time jobTime = new Time(time.getHourOfDay(), time.getMinuteOfHour());
    List<DayOfWeek> jobDayOfWeeks = createDayOfWeeks(days);
    DayOfWeekSchedulableJob job = new DayOfWeekSchedulableJob(motechEvent, start, end != null ? end : null, jobDayOfWeeks, jobTime, ignorePastFiresAtStart);
    scheduler.scheduleDayOfWeekJob(job);
}
Also used : DayOfWeek(org.motechproject.commons.date.model.DayOfWeek) DayOfWeekSchedulableJob(org.motechproject.scheduler.contract.DayOfWeekSchedulableJob) Time(org.motechproject.commons.date.model.Time) DateTime(org.joda.time.DateTime) MotechEvent(org.motechproject.event.MotechEvent)

Example 10 with DayOfWeekSchedulableJob

use of org.motechproject.scheduler.contract.DayOfWeekSchedulableJob in project motech by motech.

the class SchedulableJobBuilder method buildDayOfWeekSchedulableJob.

private static SchedulableJob buildDayOfWeekSchedulableJob(Trigger trigger, JobDataMap dataMap) {
    CronTrigger cronTrigger = (CronTrigger) trigger;
    DayOfWeekSchedulableJob job = new DayOfWeekSchedulableJob();
    job.setEndDate(getEndDate(trigger));
    job.setIgnorePastFiresAtStart(dataMap.getBoolean(IGNORE_PAST_FIRES_AT_START));
    CronExpressionUtil cronExpressionUtil = new CronExpressionUtil(cronTrigger.getCronExpression());
    job.setTime(cronExpressionUtil.getTime());
    job.setDays(cronExpressionUtil.getDaysOfWeek());
    return job;
}
Also used : CronExpressionUtil(org.motechproject.scheduler.util.CronExpressionUtil) CronTrigger(org.quartz.CronTrigger) DayOfWeekSchedulableJob(org.motechproject.scheduler.contract.DayOfWeekSchedulableJob)

Aggregations

DayOfWeekSchedulableJob (org.motechproject.scheduler.contract.DayOfWeekSchedulableJob)10 Test (org.junit.Test)7 DateTime (org.joda.time.DateTime)4 Time (org.motechproject.commons.date.model.Time)4 MotechEvent (org.motechproject.event.MotechEvent)4 HashMap (java.util.HashMap)3 DateUtil.newDateTime (org.motechproject.commons.date.util.DateUtil.newDateTime)3 TimeFaker.stopFakingTime (org.motechproject.testing.utils.TimeFaker.stopFakingTime)3 DayOfWeek (org.motechproject.commons.date.model.DayOfWeek)1 CronSchedulableJob (org.motechproject.scheduler.contract.CronSchedulableJob)1 RepeatingSchedulableJob (org.motechproject.scheduler.contract.RepeatingSchedulableJob)1 RunOnceSchedulableJob (org.motechproject.scheduler.contract.RunOnceSchedulableJob)1 CronExpressionUtil (org.motechproject.scheduler.util.CronExpressionUtil)1 CronTrigger (org.quartz.CronTrigger)1