Search in sources :

Example 11 with JobsSearchSettings

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();
    }
}
Also used : JobBasicInfo(org.motechproject.scheduler.contract.JobBasicInfo) JobsSearchSettings(org.motechproject.scheduler.contract.JobsSearchSettings) Test(org.junit.Test)

Example 12 with JobsSearchSettings

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();
    }
}
Also used : JobBasicInfo(org.motechproject.scheduler.contract.JobBasicInfo) JobsSearchSettings(org.motechproject.scheduler.contract.JobsSearchSettings) Test(org.junit.Test)

Example 13 with JobsSearchSettings

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);
}
Also used : JobsRecords(org.motechproject.scheduler.web.domain.JobsRecords) JobBasicInfo(org.motechproject.scheduler.contract.JobBasicInfo) JobsSearchSettings(org.motechproject.scheduler.contract.JobsSearchSettings) Test(org.junit.Test)

Aggregations

JobsSearchSettings (org.motechproject.scheduler.contract.JobsSearchSettings)13 Test (org.junit.Test)11 JobBasicInfo (org.motechproject.scheduler.contract.JobBasicInfo)11 HashMap (java.util.HashMap)3 MotechEvent (org.motechproject.event.MotechEvent)3 RunOnceSchedulableJob (org.motechproject.scheduler.contract.RunOnceSchedulableJob)3 CronSchedulableJob (org.motechproject.scheduler.contract.CronSchedulableJob)2 RepeatingSchedulableJob (org.motechproject.scheduler.contract.RepeatingSchedulableJob)2 JobsRecords (org.motechproject.scheduler.web.domain.JobsRecords)2 ArrayList (java.util.ArrayList)1 Period (org.joda.time.Period)1 JobDetailedInfo (org.motechproject.scheduler.contract.JobDetailedInfo)1 RepeatingPeriodSchedulableJob (org.motechproject.scheduler.contract.RepeatingPeriodSchedulableJob)1 JobKey (org.quartz.JobKey)1