use of org.motechproject.scheduler.contract.JobsSearchSettings in project motech by motech.
the class MotechSchedulerDatabaseServiceImplBundleIT method shouldReturnAllJobsWhenNoFiltersSet.
@Test
public void shouldReturnAllJobsWhenNoFiltersSet() {
try {
fakeNow(newDateTime(CURRENT_YEAR + 1, 7, 13, 5, 0, 0));
addTestJobs();
JobsSearchSettings jobsSearchSettings = new JobsSearchSettings();
List<JobBasicInfo> jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(6, jobs.size());
} finally {
stopFakingTime();
}
}
use of org.motechproject.scheduler.contract.JobsSearchSettings in project motech by motech.
the class MotechSchedulerDatabaseServiceImplBundleIT method shouldFilterJobsByName.
@Test
public void shouldFilterJobsByName() {
try {
fakeNow(newDateTime(CURRENT_YEAR + 1, 7, 13, 5, 0, 0));
addTestJobs();
JobsSearchSettings jobsSearchSettings = getGridSettings(null, null, "name", "asc");
jobsSearchSettings.setName("id1");
List<JobBasicInfo> jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(1, jobs.size());
assertEquals(jobs.get(0).getName(), "test_event_1-job_id1");
int rowCount = databaseService.countJobs(jobsSearchSettings);
assertEquals(1, rowCount);
jobsSearchSettings.setName("test_ev");
jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(6, jobs.size());
rowCount = databaseService.countJobs(jobsSearchSettings);
assertEquals(6, rowCount);
jobsSearchSettings.setName("test_event_2-job_id2");
jobs = databaseService.getScheduledJobsBasicInfo(jobsSearchSettings);
assertNotNull(jobs);
assertEquals(1, jobs.size());
assertEquals(jobs.get(0).getName(), "test_event_2-job_id2");
rowCount = databaseService.countJobs(jobsSearchSettings);
assertEquals(1, rowCount);
} finally {
stopFakingTime();
}
}
use of org.motechproject.scheduler.contract.JobsSearchSettings in project motech by motech.
the class JobsControllerTest method shouldGetAllJobsRecordsWhenNoFiltersSet.
@Test
public void shouldGetAllJobsRecordsWhenNoFiltersSet() throws SchedulerException, SQLException {
List<JobBasicInfo> jobBasicInfos = getTestJobBasicInfos();
JobsSearchSettings jobsSearchSettings = new JobsSearchSettings();
when(motechSchedulerDatabaseService.getScheduledJobsBasicInfo(jobsSearchSettings)).thenReturn(jobBasicInfos);
JobsRecords result = jobsController.retrieveJobInfo(jobsSearchSettings);
assertEquals(jobBasicInfos, result.getRows());
verify(motechSchedulerDatabaseService).getScheduledJobsBasicInfo(jobsSearchSettings);
}
Aggregations