use of org.motechproject.scheduler.contract.JobBasicInfo 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")));
}
}
use of org.motechproject.scheduler.contract.JobBasicInfo in project motech by motech.
the class TestEventListener method shouldDeleteJobIfItIsUiDefined.
@Test
public void shouldDeleteJobIfItIsUiDefined() 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);
schedulerService.deleteJob(info);
assertNull(scheduler.getTrigger(triggerKey("test_event-job_id", "default")));
}
use of org.motechproject.scheduler.contract.JobBasicInfo in project motech by motech.
the class TestEventListener method shouldNotPauseJobIfItIsNotUiDefined.
@Test(expected = MotechSchedulerException.class)
public void shouldNotPauseJobIfItIsNotUiDefined() 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_OK, "test_event-job_id", "default", "start-time", "nex-fire-time", "end-time", JobBasicInfo.JOBTYPE_CRON, "test-info", true);
schedulerService.scheduleJob(new CronSchedulableJob(new MotechEvent("test_event", params), "0 0 12 * * ?"));
assertEquals(NORMAL, scheduler.getTriggerState(triggerKey("test_event-job_id", "default")));
schedulerService.pauseJob(info);
} finally {
assertEquals(NORMAL, scheduler.getTriggerState(triggerKey("test_event-job_id", "default")));
}
}
use of org.motechproject.scheduler.contract.JobBasicInfo in project motech by motech.
the class MotechSchedulerDatabaseServiceImplBundleIT method shouldFilterJobsWithSortingAndPagination.
@Test
public void shouldFilterJobsWithSortingAndPagination() {
try {
fakeNow(newDateTime(CURRENT_YEAR + 1, 7, 13, 10, 0, 0));
addTestJobs();
JobsSearchSettings jobsSearchSettings = getGridSettings(1, 5, "name", "asc");
jobsSearchSettings.setName("event");
List<JobBasicInfo> jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(5, jobs.size());
assertEquals(6, databaseService.countJobs(jobsSearchSettings));
assertEquals(printJobNames(jobs), "test_event_1-job_id1", jobs.get(0).getName());
jobsSearchSettings.setPage(2);
jobsSearchSettings.setName("test");
jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(1, jobs.size());
assertEquals(6, databaseService.countJobs(jobsSearchSettings));
jobsSearchSettings.setPage(3);
jobsSearchSettings.setRows(2);
jobsSearchSettings.setSortDirection("desc");
jobsSearchSettings.setActivity(JobBasicInfo.ACTIVITY_NOTSTARTED);
jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(1, jobs.size());
assertEquals(JobBasicInfo.ACTIVITY_NOTSTARTED, jobs.get(0).getActivity());
assertEquals(5, databaseService.countJobs(jobsSearchSettings));
jobsSearchSettings = getGridSettings(1, 2, "name", "asc");
jobsSearchSettings.setTimeTo(format("%s-03-15 9:30:00", CURRENT_YEAR + 7));
jobsSearchSettings.setTimeFrom(format("%s-03-15 9:30:00", CURRENT_YEAR + 3));
jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertEquals(2, jobs.size());
assertEquals(printJobNames(jobs), "test_event_3-job_id3", jobs.get(0).getName());
assertEquals(3, databaseService.countJobs(jobsSearchSettings));
jobsSearchSettings.setSortDirection("desc");
jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertEquals(2, jobs.size());
assertEquals(printJobNames(jobs), "test_event_6-job_id6-repeat", jobs.get(0).getName());
assertEquals(3, databaseService.countJobs(jobsSearchSettings));
} finally {
stopFakingTime();
}
}
use of org.motechproject.scheduler.contract.JobBasicInfo in project motech by motech.
the class MotechSchedulerDatabaseServiceImplBundleIT method shouldFilterJobsByActivity.
@Test
public void shouldFilterJobsByActivity() {
try {
fakeNow(newDateTime(CURRENT_YEAR + 1, 7, 13, 5, 0, 0));
addTestJobs();
JobsSearchSettings jobsSearchSettings = getGridSettings(null, null, "name", "asc");
jobsSearchSettings.setActivity(JobBasicInfo.ACTIVITY_NOTSTARTED);
List<JobBasicInfo> jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(5, jobs.size());
jobsSearchSettings.setActivity(JobBasicInfo.ACTIVITY_ACTIVE);
jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertEquals(1, jobs.size());
} finally {
stopFakingTime();
}
}
Aggregations