use of org.pentaho.platform.api.scheduler2.SimpleJobTrigger in project pentaho-platform by pentaho.
the class SchedulerResourceUtilTest method testConvertScheduleRequestToJobTrigger_SimpleJobTrigger.
@Test
public void testConvertScheduleRequestToJobTrigger_SimpleJobTrigger() throws Exception {
IJobTrigger trigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger(scheduleRequest, scheduler);
assertNotNull(trigger);
assertTrue(trigger instanceof SimpleJobTrigger);
assertTrue(trigger.getStartTime().getTime() > System.currentTimeMillis());
}
use of org.pentaho.platform.api.scheduler2.SimpleJobTrigger in project pentaho-platform by pentaho.
the class GatherStatsListener method scheduleJob.
private void scheduleJob(int intervalInSeconds) throws Exception {
// $NON-NLS-1$
IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
JobTrigger trigger = new SimpleJobTrigger(new Date(), null, -1, intervalInSeconds);
jobMap.put("transFileName", getTransFileName());
scheduler.createJob(GatherStatsListener.JOB_NAME, GatherStatsAction.class, jobMap, trigger);
logger.info("Statistics gathering jop has been scheduled.");
}
use of org.pentaho.platform.api.scheduler2.SimpleJobTrigger in project pentaho-platform by pentaho.
the class SimpleTriggerTest method defaultParamsDatesTest.
@Test
public void defaultParamsDatesTest() {
Calendar now = Calendar.getInstance();
Calendar nextMonth = Calendar.getInstance();
nextMonth.add(Calendar.MONTH, 1);
SimpleJobTrigger trigger = new SimpleJobTrigger(now.getTime(), nextMonth.getTime(), 1, 1000);
Assert.assertEquals(trigger.toString(), "repeatCount=1, repeatInterval=1000, startTime=" + now.getTime().toString() + ", endTime=" + nextMonth.getTime().toString());
}
use of org.pentaho.platform.api.scheduler2.SimpleJobTrigger in project pentaho-platform by pentaho.
the class SimpleTriggerTest method defaultParamsNoDatesTest.
@Test
public void defaultParamsNoDatesTest() {
SimpleJobTrigger trigger = new SimpleJobTrigger();
Assert.assertEquals(trigger.toString(), "repeatCount=0, repeatInterval=0, startTime=null, endTime=null");
}
use of org.pentaho.platform.api.scheduler2.SimpleJobTrigger in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_StringStreamProvider.
@Test
public void testCreateJobScheduleRequest_StringStreamProvider() throws Exception {
String jobName = "JOB";
Job job = mock(Job.class);
SimpleJobTrigger trigger = mock(SimpleJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
Map<String, Serializable> params = new HashMap<>();
params.put(QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER, "import file = /home/admin/myJob.kjb:output file=/home/admin/myJob*");
when(job.getJobParams()).thenReturn(params);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
assertNotNull(jobScheduleRequest);
assertEquals(jobName, jobScheduleRequest.getJobName());
assertEquals(trigger, jobScheduleRequest.getSimpleJobTrigger());
assertEquals("/home/admin/myJob.kjb", jobScheduleRequest.getInputFile());
assertEquals("/home/admin/myJob*", jobScheduleRequest.getOutputFile());
}
Aggregations