use of org.motechproject.scheduler.contract.JobBasicInfo in project motech by motech.
the class JobsControllerTest method shouldGetJobsRecords.
@Test
public void shouldGetJobsRecords() throws SchedulerException, SQLException {
List<JobBasicInfo> jobBasicInfos = getTestJobBasicInfos();
JobsSearchSettings jobsSearchSettings = getDefaultGridSettings();
when(motechSchedulerDatabaseService.getScheduledJobsBasicInfo(jobsSearchSettings)).thenReturn(jobBasicInfos);
JobsRecords result = jobsController.retrieveJobInfo(jobsSearchSettings);
assertEquals(jobBasicInfos, result.getRows());
verify(motechSchedulerDatabaseService).getScheduledJobsBasicInfo(jobsSearchSettings);
}
use of org.motechproject.scheduler.contract.JobBasicInfo in project motech by motech.
the class JobsController method retrieveJobInfo.
/**
* Returns job information sorted and filtered as defined in {@code jobsGridSettings}.
*
* @param jobsSearchSettings the setting by which returned records are sorted and filtered
* @return sorted and filtered job records
*/
@RequestMapping(value = "/jobs", method = RequestMethod.GET)
@ResponseBody
public JobsRecords retrieveJobInfo(JobsSearchSettings jobsSearchSettings) throws SchedulerException, SQLException {
List<JobBasicInfo> jobs = motechSchedulerDatabaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
int rowCount = jobs.size() == 0 ? 0 : motechSchedulerDatabaseService.countJobs(jobsSearchSettings);
if (jobsSearchSettings.getRows() == null) {
int defaultRowsNumber = 10;
jobsSearchSettings.setRows(defaultRowsNumber);
}
if (jobsSearchSettings.getPage() == null) {
int defaultPage = 1;
jobsSearchSettings.setPage(defaultPage);
}
previousJobsRecords = new JobsRecords(jobsSearchSettings.getPage(), jobsSearchSettings.getRows(), rowCount, jobs);
return previousJobsRecords;
}
use of org.motechproject.scheduler.contract.JobBasicInfo in project motech by motech.
the class TestEventListener method shouldNotResumeJobIfJobDoesNotExist.
@Test(expected = MotechSchedulerException.class)
public void shouldNotResumeJobIfJobDoesNotExist() throws Exception {
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.resumeJob(info);
}
use of org.motechproject.scheduler.contract.JobBasicInfo 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.scheduler.contract.JobBasicInfo in project motech by motech.
the class TestEventListener method shouldNotPauseJobIfJobDoesNotExist.
@Test(expected = MotechSchedulerException.class)
public void shouldNotPauseJobIfJobDoesNotExist() throws Exception {
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.pauseJob(info);
}
Aggregations