use of org.motechproject.scheduler.web.domain.JobsRecords 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.web.domain.JobsRecords 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.web.domain.JobsRecords 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