use of org.motechproject.scheduler.contract.JobsSearchSettings in project motech by motech.
the class MotechSchedulerDatabaseServiceImplBundleIT method getGridSettings.
private JobsSearchSettings getGridSettings(Integer page, Integer rows, String sortColumn, String direction) {
JobsSearchSettings jobsSearchSettings = new JobsSearchSettings();
jobsSearchSettings.setActivity(format("%s,%s,%s", JobBasicInfo.ACTIVITY_ACTIVE, JobBasicInfo.ACTIVITY_FINISHED, JobBasicInfo.ACTIVITY_NOTSTARTED));
jobsSearchSettings.setName("");
jobsSearchSettings.setPage(page);
jobsSearchSettings.setRows(rows);
jobsSearchSettings.setSortColumn(sortColumn);
jobsSearchSettings.setStatus(format("%s,%s,%s,%s", JobBasicInfo.STATUS_BLOCKED, JobBasicInfo.STATUS_ERROR, JobBasicInfo.STATUS_OK, JobBasicInfo.STATUS_PAUSED));
jobsSearchSettings.setSortDirection(direction);
jobsSearchSettings.setTimeFrom("");
jobsSearchSettings.setTimeTo("");
return jobsSearchSettings;
}
use of org.motechproject.scheduler.contract.JobsSearchSettings in project motech by motech.
the class MotechSchedulerDatabaseServiceImplBundleIT method shouldGetScheduledJobsBasicInfoWithSortingAndPagination.
@Test
public void shouldGetScheduledJobsBasicInfoWithSortingAndPagination() throws SchedulerException, SQLException {
try {
fakeNow(newDateTime(CURRENT_YEAR + 6, 7, 15, 10, 0, 0));
Map<String, Object> params = new HashMap<>();
params.put(MotechSchedulerService.JOB_ID_KEY, "job_id");
schedulerService.scheduleJob(new CronSchedulableJob(new MotechEvent("test_event_2a", params), "0 0 12 * * ?"));
schedulerService.scheduleRunOnceJob(new RunOnceSchedulableJob(new MotechEvent("test_event_2b", params), newDateTime(CURRENT_YEAR + 6, 7, 15, 12, 0, 0)));
schedulerService.scheduleRepeatingJob(new RepeatingSchedulableJob(new MotechEvent("test_event_2c", params), DateTimeConstants.SECONDS_PER_DAY, newDateTime(CURRENT_YEAR + 6, 7, 15, 12, 0, 0), newDateTime(CURRENT_YEAR + 6, 7, 18, 12, 0, 0), false));
JobBasicInfo expected = new JobBasicInfo(JobBasicInfo.ACTIVITY_NOTSTARTED, JobBasicInfo.STATUS_OK, "test_event_2a-job_id", DEFAULT_GROUP, format("%s-07-15 10:00:00", CURRENT_YEAR + 6), format("%s-07-15 12:00:00", CURRENT_YEAR + 6), "-", JobBasicInfo.JOBTYPE_CRON, "", false);
List<JobBasicInfo> jobBasicInfos;
JobsSearchSettings jobsSearchSettings = getGridSettings(2, 2, "name", "desc");
jobBasicInfos = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertEquals(expected.getActivity(), jobBasicInfos.get(0).getActivity());
assertEquals(expected.getStatus(), jobBasicInfos.get(0).getStatus());
assertEquals(expected.getStartDate(), jobBasicInfos.get(0).getStartDate());
assertEquals(expected.getNextFireDate(), jobBasicInfos.get(0).getNextFireDate());
} finally {
stopFakingTime();
}
}
use of org.motechproject.scheduler.contract.JobsSearchSettings in project motech by motech.
the class MotechSchedulerDatabaseServiceImplBundleIT method shouldFilterJobsByDate.
@Test
public void shouldFilterJobsByDate() {
try {
fakeNow(newDateTime(CURRENT_YEAR + 1, 7, 13, 5, 0, 0));
addTestJobs();
JobsSearchSettings jobsSearchSettings = getGridSettings(null, null, "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));
List<JobBasicInfo> jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(3, jobs.size());
assertEquals("test_event_3-job_id3", jobs.get(0).getName());
assertEquals("test_event_5-job_id5-runonce", jobs.get(1).getName());
assertEquals("test_event_6-job_id6-repeat", jobs.get(2).getName());
jobsSearchSettings.setTimeTo(format("%s-03-15 9:30:00", CURRENT_YEAR + 5));
jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(2, jobs.size());
jobsSearchSettings.setTimeFrom("");
jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(5, jobs.size());
} finally {
stopFakingTime();
}
}
use of org.motechproject.scheduler.contract.JobsSearchSettings in project motech by motech.
the class MotechSchedulerDatabaseServiceImplBundleIT method shouldGetScheduledJobDetailedInfo.
@Test
public void shouldGetScheduledJobDetailedInfo() throws SchedulerException, SQLException {
try {
fakeNow(newDateTime(CURRENT_YEAR + 6, 7, 15, 10, 0, 0));
JobDetailedInfo jobDetailedInfo = null;
Map<String, Object> params = new HashMap<>();
params.put(MotechSchedulerService.JOB_ID_KEY, "job_id_2");
params.put("param1", "value1");
params.put("param2", "value2");
schedulerService.scheduleRunOnceJob(new RunOnceSchedulableJob(new MotechEvent("test_event_2", params), newDateTime(CURRENT_YEAR + 6, 7, 15, 12, 0, 0)));
JobsSearchSettings jobsSearchSettings = getGridSettings(0, 10, "name", "asc");
for (JobBasicInfo job : databaseService.getScheduledJobsBasicInfo(jobsSearchSettings)) {
if (job.getName().equals("test_event_2-job_id_2-runonce")) {
jobDetailedInfo = databaseService.getScheduledJobDetailedInfo(job);
}
}
assertNotNull(jobDetailedInfo);
assertEquals("test_event_2", jobDetailedInfo.getEventInfoList().get(0).getSubject());
assertEquals(4, jobDetailedInfo.getEventInfoList().get(0).getParameters().size());
} finally {
stopFakingTime();
}
}
use of org.motechproject.scheduler.contract.JobsSearchSettings in project motech by motech.
the class JobsControllerTest method getDefaultGridSettings.
private JobsSearchSettings getDefaultGridSettings() {
JobsSearchSettings jobsSearchSettings = new JobsSearchSettings();
jobsSearchSettings.setActivity(String.format("%s,%s,%s", JobBasicInfo.ACTIVITY_ACTIVE, JobBasicInfo.ACTIVITY_FINISHED, JobBasicInfo.ACTIVITY_NOTSTARTED));
jobsSearchSettings.setName("");
jobsSearchSettings.setPage(0);
jobsSearchSettings.setRows(10);
jobsSearchSettings.setSortColumn("");
jobsSearchSettings.setStatus(String.format("%s,%s,%s,%s", JobBasicInfo.STATUS_BLOCKED, JobBasicInfo.STATUS_ERROR, JobBasicInfo.STATUS_OK, JobBasicInfo.STATUS_PAUSED));
jobsSearchSettings.setSortDirection("asc");
jobsSearchSettings.setTimeFrom("");
jobsSearchSettings.setTimeTo("");
return jobsSearchSettings;
}
Aggregations