Search in sources :

Example 6 with SimpleJobTrigger

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());
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Test(org.junit.Test)

Example 7 with SimpleJobTrigger

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.");
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) Date(java.util.Date)

Example 8 with SimpleJobTrigger

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());
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) Calendar(java.util.Calendar) Test(org.junit.Test)

Example 9 with SimpleJobTrigger

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");
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) Test(org.junit.Test)

Example 10 with SimpleJobTrigger

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());
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) Serializable(java.io.Serializable) HashMap(java.util.HashMap) Job(org.pentaho.platform.api.scheduler2.Job) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) Test(org.junit.Test)

Aggregations

SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)29 Test (org.junit.Test)23 Date (java.util.Date)14 Job (org.pentaho.platform.api.scheduler2.Job)14 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 Serializable (java.io.Serializable)10 Calendar (java.util.Calendar)7 HashMap (java.util.HashMap)7 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)7 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)6 GregorianCalendar (java.util.GregorianCalendar)4 CronJobTrigger (org.pentaho.platform.api.scheduler2.CronJobTrigger)3 IBackgroundExecutionStreamProvider (org.pentaho.platform.api.scheduler2.IBackgroundExecutionStreamProvider)3 IScheduler (org.pentaho.platform.api.scheduler2.IScheduler)3 JobScheduleParam (org.pentaho.platform.web.http.api.resources.JobScheduleParam)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Matchers.anyString (org.mockito.Matchers.anyString)2 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 JobTrigger (org.pentaho.platform.api.scheduler2.JobTrigger)2