use of org.motechproject.event.MotechEvent in project motech by motech.
the class TestRunOnceSchedulableJob method setUp.
@Before
public void setUp() {
Map<String, Object> params = new HashMap<>();
params.put("JobID", uuidStr);
motechEvent1 = new MotechEvent("TestEvent", params);
params = new HashMap<>();
params.put("JobID", uuidStr2);
motechEvent2 = new MotechEvent("TestEvent", params);
currentDate = DateUtil.now();
currentDate = currentDate.minusDays(1);
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class TestEventListener method shouldThrowExceptionForInvalidCronExpressionWhenreschedulingJob.
@Test(expected = MotechSchedulerException.class)
public void shouldThrowExceptionForInvalidCronExpressionWhenreschedulingJob() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put(MotechSchedulerService.JOB_ID_KEY, "job_id");
schedulerService.scheduleJob(new CronSchedulableJob(new MotechEvent("test_event", params), "0 0 10 * * ?"));
schedulerService.rescheduleJob("test_event", "job_id", "invalidCronExpression");
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class TestEventListener method shouldPauseJobIfItIsUiDefined.
@Test
public void shouldPauseJobIfItIsUiDefined() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put(MotechSchedulerService.JOB_ID_KEY, "job_id");
JobBasicInfo info = new JobBasicInfo(JobBasicInfo.ACTIVITY_ACTIVE, JobBasicInfo.STATUS_OK, "test_event-job_id", "default", "start-time", "nex-fire-time", "end-time", JobBasicInfo.JOBTYPE_CRON, "test-info", false);
CronSchedulableJob job = new CronSchedulableJob(new MotechEvent("test_event", params), "0 0 12 * * ?");
job.setUiDefined(true);
schedulerService.scheduleJob(job);
assertEquals(NORMAL, scheduler.getTriggerState(triggerKey("test_event-job_id", "default")));
schedulerService.pauseJob(info);
assertEquals(PAUSED, scheduler.getTriggerState(triggerKey("test_event-job_id", "default")));
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class TestEventListener method shouldThrowExceptionForInvalidCronExpression.
@Test(expected = MotechSchedulerException.class)
public void shouldThrowExceptionForInvalidCronExpression() throws SchedulerException {
Map<String, Object> params = new HashMap<>();
params.put(MotechSchedulerService.JOB_ID_KEY, "job_id");
schedulerService.scheduleJob(new CronSchedulableJob(new MotechEvent("test_event", params), "invalidCronExpression"));
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class TestEventListener method shouldNotResumeJobIfItIsNotUiDefined.
@Test(expected = MotechSchedulerException.class)
public void shouldNotResumeJobIfItIsNotUiDefined() throws Exception {
try {
Map<String, Object> params = new HashMap<>();
params.put(MotechSchedulerService.JOB_ID_KEY, "job_id");
JobBasicInfo info = new JobBasicInfo(JobBasicInfo.ACTIVITY_ACTIVE, JobBasicInfo.STATUS_PAUSED, "test_event-job_id", "default", "start-time", "nex-fire-time", "end-time", JobBasicInfo.JOBTYPE_CRON, "test-info", false);
schedulerService.scheduleJob(new CronSchedulableJob(new MotechEvent("test_event", params), "0 0 12 * * ?"));
scheduler.pauseJob(new JobKey(info.getName(), info.getGroup()));
assertEquals(PAUSED, scheduler.getTriggerState(triggerKey("test_event-job_id", "default")));
schedulerService.resumeJob(info);
} finally {
assertEquals(PAUSED, scheduler.getTriggerState(triggerKey("test_event-job_id", "default")));
}
}
Aggregations