use of org.pentaho.platform.api.scheduler2.CronJobTrigger in project pentaho-platform by pentaho.
the class RepositoryCleanerSystemListenerTest method reschedulesJob_IfFoundDifferent.
@Test
public void reschedulesJob_IfFoundDifferent() throws Exception {
final String oldJobId = "oldJobId";
Job oldJob = new Job();
oldJob.setJobTrigger(new CronJobTrigger());
oldJob.setJobId(oldJobId);
when(scheduler.getJobs(any(IJobFilter.class))).thenReturn(Collections.singletonList(oldJob));
prepareMp();
listener.setExecute(Frequency.NOW.getValue());
assertTrue(listener.startup(null));
verifyJobRemoved(oldJobId);
verifyJobCreated(Frequency.NOW);
}
use of org.pentaho.platform.api.scheduler2.CronJobTrigger in project pentaho-platform by pentaho.
the class SchedulerResourceUtilTest method testConvertScheduleRequestToJobTrigger_CronString.
@Test
public void testConvertScheduleRequestToJobTrigger_CronString() throws Exception {
cron = new CronJobTrigger();
cron.setCronString("0 45 16 ? * 2#4,2L,6#4,6L *");
cron.setDuration(200000);
cron.setStartTime(now);
cron.setUiPassParam("param");
cron.setEndTime(now);
when(scheduleRequest.getCronJobTrigger()).thenReturn(cron);
IJobTrigger trigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger(scheduleRequest, scheduler);
assertTrue(trigger instanceof ComplexJobTrigger);
ComplexJobTrigger trig = (ComplexJobTrigger) trigger;
assertEquals(now, trig.getStartTime());
assertEquals(now, trig.getEndTime());
assertEquals(200000, trig.getDuration());
assertEquals("param", trig.getUiPassParam());
List<ITimeRecurrence> recurrences = trig.getDayOfWeekRecurrences().getRecurrences();
assertEquals(4, recurrences.size());
QualifiedDayOfWeek rec = (QualifiedDayOfWeek) recurrences.get(0);
assertEquals("MON", rec.getDayOfWeek().toString());
assertEquals("FOURTH", rec.getQualifier().toString());
rec = (QualifiedDayOfWeek) recurrences.get(1);
assertEquals("MON", rec.getDayOfWeek().toString());
assertEquals("LAST", rec.getQualifier().toString());
rec = (QualifiedDayOfWeek) recurrences.get(2);
assertEquals("FRI", rec.getDayOfWeek().toString());
assertEquals("FOURTH", rec.getQualifier().toString());
rec = (QualifiedDayOfWeek) recurrences.get(3);
assertEquals("FRI", rec.getDayOfWeek().toString());
assertEquals("LAST", rec.getQualifier().toString());
}
use of org.pentaho.platform.api.scheduler2.CronJobTrigger in project pentaho-platform by pentaho.
the class SchedulerResourceUtilTest method testUpdateStartDateForTimeZone_cron.
@Test
public void testUpdateStartDateForTimeZone_cron() throws Exception {
CronJobTrigger t = new CronJobTrigger();
t.setStartTime(now);
when(scheduleRequest.getCronJobTrigger()).thenReturn(t);
when(scheduleRequest.getTimeZone()).thenReturn("GMT");
long gmtTime = now.getTime() + TimeZone.getTimeZone("EST").getRawOffset();
SchedulerResourceUtil.updateStartDateForTimeZone(scheduleRequest);
assertEquals(gmtTime, scheduleRequest.getCronJobTrigger().getStartTime().getTime());
}
use of org.pentaho.platform.api.scheduler2.CronJobTrigger in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_MultipleTypesJobParam.
@Test
public void testCreateJobScheduleRequest_MultipleTypesJobParam() throws Exception {
String jobName = "JOB";
Long l = Long.MAX_VALUE;
Date d = new Date();
Boolean b = true;
Map<String, Serializable> params = new HashMap<>();
params.put("NumberValue", l);
params.put("DateValue", d);
params.put("BooleanValue", b);
Job job = mock(Job.class);
CronJobTrigger trigger = mock(CronJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
when(job.getJobParams()).thenReturn(params);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
for (JobScheduleParam jobScheduleParam : jobScheduleRequest.getJobParameters()) {
assertTrue(jobScheduleParam.getValue().equals(l) || jobScheduleParam.getValue().equals(d) || jobScheduleParam.getValue().equals(b));
}
}
use of org.pentaho.platform.api.scheduler2.CronJobTrigger in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_ActionClassJobParam.
@Test
public void testCreateJobScheduleRequest_ActionClassJobParam() throws Exception {
String jobName = "JOB";
String actionClass = "com.pentaho.Action";
Map<String, Serializable> params = new HashMap<>();
params.put(QuartzScheduler.RESERVEDMAPKEY_ACTIONCLASS, actionClass);
Job job = mock(Job.class);
CronJobTrigger trigger = mock(CronJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
when(job.getJobParams()).thenReturn(params);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
assertEquals(actionClass, jobScheduleRequest.getActionClass());
assertEquals(actionClass, jobScheduleRequest.getJobParameters().get(0).getValue());
}
Aggregations