Search in sources :

Example 11 with JobTrigger

use of org.pentaho.platform.api.scheduler2.JobTrigger in project pentaho-platform by pentaho.

the class PentahoPlatformExporterTest method testExportSchedules.

@Test
public void testExportSchedules() throws Exception {
    List<Job> jobs = new ArrayList<>();
    ComplexJobTrigger trigger = mock(ComplexJobTrigger.class);
    JobTrigger unknownTrigger = mock(JobTrigger.class);
    Job job1 = mock(Job.class);
    Job job2 = mock(Job.class);
    Job job3 = mock(Job.class);
    jobs.add(job1);
    jobs.add(job2);
    jobs.add(job3);
    when(scheduler.getJobs(null)).thenReturn(jobs);
    when(job1.getJobName()).thenReturn(EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME);
    when(job2.getJobName()).thenReturn("job 2");
    when(job2.getJobTrigger()).thenReturn(trigger);
    when(job3.getJobName()).thenReturn("job 3");
    when(job3.getJobTrigger()).thenReturn(unknownTrigger);
    exporterSpy.exportSchedules();
    verify(scheduler).getJobs(null);
    assertEquals(1, exporterSpy.getExportManifest().getScheduleList().size());
}
Also used : ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) ArrayList(java.util.ArrayList) Job(org.pentaho.platform.api.scheduler2.Job) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) Test(org.junit.Test)

Example 12 with JobTrigger

use of org.pentaho.platform.api.scheduler2.JobTrigger in project pentaho-platform by pentaho.

the class ScheduleExportUtilTest method testCreateJobScheduleRequest_unknownTrigger.

@Test(expected = IllegalArgumentException.class)
public void testCreateJobScheduleRequest_unknownTrigger() throws Exception {
    String jobName = "JOB";
    Job job = mock(Job.class);
    JobTrigger trigger = mock(JobTrigger.class);
    when(job.getJobTrigger()).thenReturn(trigger);
    JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) CronJobTrigger(org.pentaho.platform.api.scheduler2.CronJobTrigger) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) Test(org.junit.Test)

Example 13 with JobTrigger

use of org.pentaho.platform.api.scheduler2.JobTrigger in project pentaho-platform by pentaho.

the class SchedulerServiceTest method testGetBlockStatus.

@Test
public void testGetBlockStatus() throws Exception {
    JobScheduleRequest jobScheduleRequestMock = mock(JobScheduleRequest.class);
    BlockStatusProxy blockStatusProxyMock = mock(BlockStatusProxy.class);
    IJobTrigger jobTrigger = mock(IJobTrigger.class);
    doReturn(jobTrigger).when(schedulerService).convertScheduleRequestToJobTrigger(jobScheduleRequestMock);
    doReturn(true).when(schedulerService.blockoutManager).isPartiallyBlocked(jobTrigger);
    doReturn(true).when(schedulerService.blockoutManager).willFire(jobTrigger);
    doReturn(blockStatusProxyMock).when(schedulerService).getBlockStatusProxy(anyBoolean(), anyBoolean());
    // Test 1
    BlockStatusProxy blockStatusProxy = schedulerService.getBlockStatus(jobScheduleRequestMock);
    assertNotNull(blockStatusProxy);
    // Test 2
    doReturn(false).when(schedulerService.blockoutManager).isPartiallyBlocked(jobTrigger);
    blockStatusProxy = schedulerService.getBlockStatus(jobScheduleRequestMock);
    assertNotNull(blockStatusProxy);
    verify(schedulerService, times(2)).convertScheduleRequestToJobTrigger(jobScheduleRequestMock);
    verify(schedulerService.blockoutManager, times(2)).isPartiallyBlocked(jobTrigger);
    verify(schedulerService, times(2)).getBlockStatusProxy(anyBoolean(), anyBoolean());
    verify(schedulerService.blockoutManager, times(1)).willFire(jobTrigger);
}
Also used : BlockStatusProxy(org.pentaho.platform.web.http.api.resources.proxies.BlockStatusProxy) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) Test(org.junit.Test)

Example 14 with JobTrigger

use of org.pentaho.platform.api.scheduler2.JobTrigger in project pentaho-platform by pentaho.

the class SchedulerServiceTest method testWillFire.

@Test
public void testWillFire() {
    IJobTrigger jobTrigger = mock(IJobTrigger.class);
    // Test 1
    doReturn(true).when(schedulerService.blockoutManager).willFire(jobTrigger);
    boolean willFire = schedulerService.willFire(jobTrigger);
    assertTrue(willFire);
    // Test 2
    doReturn(false).when(schedulerService.blockoutManager).willFire(jobTrigger);
    willFire = schedulerService.willFire(jobTrigger);
    assertFalse(willFire);
    verify(schedulerService.blockoutManager, times(2)).willFire(jobTrigger);
}
Also used : IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Test(org.junit.Test)

Example 15 with JobTrigger

use of org.pentaho.platform.api.scheduler2.JobTrigger in project pentaho-platform by pentaho.

the class PentahoBlockoutManagerIT method addJob.

private Job addJob(IJobTrigger jobTrigger, String jobName, IAction action, Map<String, Serializable> jobParams) throws Exception {
    Job job = this.scheduler.createJob(jobName, action.getClass(), jobParams, jobTrigger);
    this.jobIdsToClear.add(job.getJobId());
    return job;
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)12 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)11 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)11 Test (org.junit.Test)9 Date (java.util.Date)8 Serializable (java.io.Serializable)7 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)7 JobTrigger (org.pentaho.platform.api.scheduler2.JobTrigger)7 HashMap (java.util.HashMap)5 IScheduler (org.pentaho.platform.api.scheduler2.IScheduler)5 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)5 ArrayList (java.util.ArrayList)3 Calendar (java.util.Calendar)3 CronJobTrigger (org.pentaho.platform.api.scheduler2.CronJobTrigger)3 QuartzScheduler (org.pentaho.platform.scheduler2.quartz.QuartzScheduler)3 IncrementalRecurrence (org.pentaho.platform.scheduler2.recur.IncrementalRecurrence)3 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)3 ListParamValue (org.pentaho.platform.scheduler2.ws.ListParamValue)2 MapParamValue (org.pentaho.platform.scheduler2.ws.MapParamValue)2 ParamValue (org.pentaho.platform.scheduler2.ws.ParamValue)2