use of org.pentaho.platform.api.scheduler2.IJobTrigger in project pentaho-platform by pentaho.
the class SchedulerResourceUtilTest method testConvertScheduleRequestToJobTrigger_SimpleJobTrigger_basedOnExisting.
@Test
public void testConvertScheduleRequestToJobTrigger_SimpleJobTrigger_basedOnExisting() throws Exception {
when(scheduleRequest.getSimpleJobTrigger()).thenReturn(simple);
IJobTrigger trigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger(scheduleRequest, scheduler);
assertNotNull(trigger);
assertEquals(simple, trigger);
verify(simple).setStartTime(any(Date.class));
}
use of org.pentaho.platform.api.scheduler2.IJobTrigger in project pentaho-platform by pentaho.
the class SchedulerResourceUtilTest method testConvertScheduleRequestToJobTrigger_ComplexJobTrigger_daysOfWeek.
@Test
public void testConvertScheduleRequestToJobTrigger_ComplexJobTrigger_daysOfWeek() throws Exception {
complex.setDaysOfWeek(new int[] { 1, 5 });
when(scheduleRequest.getComplexJobTrigger()).thenReturn(complex);
IJobTrigger trigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger(scheduleRequest, scheduler);
assertNotNull(trigger);
assertTrue(trigger instanceof ComplexJobTrigger);
ComplexJobTrigger trig = (ComplexJobTrigger) trigger;
List<ITimeRecurrence> recurrences = trig.getDayOfWeekRecurrences().getRecurrences();
assertEquals(2, recurrences.size());
RecurrenceList rec = (RecurrenceList) recurrences.get(0);
assertEquals(2, rec.getValues().get(0).intValue());
rec = (RecurrenceList) recurrences.get(1);
assertEquals(6, rec.getValues().get(0).intValue());
}
use of org.pentaho.platform.api.scheduler2.IJobTrigger in project pentaho-platform by pentaho.
the class SchedulerResourceUtilTest method testConvertScheduleRequestToJobTrigger_ComplexJobTrigger_monthsOfYear.
@Test
public void testConvertScheduleRequestToJobTrigger_ComplexJobTrigger_monthsOfYear() throws Exception {
complex.setMonthsOfYear(new int[] { 1, 8 });
when(scheduleRequest.getComplexJobTrigger()).thenReturn(complex);
IJobTrigger trigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger(scheduleRequest, scheduler);
assertNotNull(trigger);
assertTrue(trigger instanceof ComplexJobTrigger);
ComplexJobTrigger trig = (ComplexJobTrigger) trigger;
List<ITimeRecurrence> recurrences = trig.getMonthlyRecurrences().getRecurrences();
assertEquals(2, recurrences.size());
RecurrenceList rec = (RecurrenceList) recurrences.get(0);
assertEquals(2, rec.getValues().get(0).intValue());
rec = (RecurrenceList) recurrences.get(1);
assertEquals(9, rec.getValues().get(0).intValue());
}
use of org.pentaho.platform.api.scheduler2.IJobTrigger 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.IJobTrigger in project pentaho-platform by pentaho.
the class QuartzScheduler method createJob.
/**
* {@inheritDoc}
*/
public Job createJob(String jobName, Class<? extends IAction> action, Map<String, Serializable> jobParams, IJobTrigger trigger, IBackgroundExecutionStreamProvider outputStreamProvider) throws SchedulerException {
if (action == null) {
// $NON-NLS-1$
throw new SchedulerException(Messages.getInstance().getString("QuartzScheduler.ERROR_0003_ACTION_IS_NULL"));
}
if (jobParams == null) {
jobParams = new HashMap<String, Serializable>();
}
jobParams.put(RESERVEDMAPKEY_ACTIONCLASS, action.getName());
Job ret = createJob(jobName, jobParams, trigger, outputStreamProvider);
ret.setSchedulableClass(action.getName());
return ret;
}
Aggregations