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());
}
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);
}
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);
}
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);
}
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;
}
Aggregations