Search in sources :

Example 71 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class ScheduleExportUtilTest method testCreateJobScheduleRequest_SimpleJobTrigger.

@Test
public void testCreateJobScheduleRequest_SimpleJobTrigger() 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);
    JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
    assertNotNull(jobScheduleRequest);
    assertEquals(jobName, jobScheduleRequest.getJobName());
    assertEquals(trigger, jobScheduleRequest.getSimpleJobTrigger());
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) Job(org.pentaho.platform.api.scheduler2.Job) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) Test(org.junit.Test)

Example 72 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class ScheduleExportUtilTest method testCreateJobScheduleRequest_CronJobTrigger.

@Test
public void testCreateJobScheduleRequest_CronJobTrigger() throws Exception {
    String jobName = "JOB";
    Job job = mock(Job.class);
    CronJobTrigger trigger = mock(CronJobTrigger.class);
    when(job.getJobTrigger()).thenReturn(trigger);
    when(job.getJobName()).thenReturn(jobName);
    JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
    assertNotNull(jobScheduleRequest);
    assertEquals(jobName, jobScheduleRequest.getJobName());
    assertEquals(trigger, jobScheduleRequest.getCronJobTrigger());
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) CronJobTrigger(org.pentaho.platform.api.scheduler2.CronJobTrigger) Test(org.junit.Test)

Example 73 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class ScheduleExportUtilTest method testCreateJobScheduleRequest_StreamProviderJobParam.

@Test
public void testCreateJobScheduleRequest_StreamProviderJobParam() throws Exception {
    String jobName = "JOB";
    String inputPath = "/input/path/to/file.ext";
    String outputPath = "/output/path/location.*";
    Map<String, Serializable> params = new HashMap<>();
    RepositoryFileStreamProvider streamProvider = mock(RepositoryFileStreamProvider.class);
    params.put(QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER, streamProvider);
    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);
    when(streamProvider.getInputFilePath()).thenReturn(inputPath);
    when(streamProvider.getOutputFilePath()).thenReturn(outputPath);
    JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
    assertEquals(inputPath, jobScheduleRequest.getInputFile());
    assertEquals(outputPath, jobScheduleRequest.getOutputFile());
    assertEquals(0, jobScheduleRequest.getJobParameters().size());
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) RepositoryFileStreamProvider(org.pentaho.platform.web.http.api.resources.RepositoryFileStreamProvider) Job(org.pentaho.platform.api.scheduler2.Job) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) CronJobTrigger(org.pentaho.platform.api.scheduler2.CronJobTrigger) Test(org.junit.Test)

Example 74 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class GatherStatsListenerTest method testStartUp.

@Test
public void testStartUp() throws Exception {
    PentahoSystem.registerObject(scheduler);
    Job job = mock(Job.class);
    when(scheduler.createJob(eq("Gather Stats"), eq(GatherStatsAction.class), eq(gatherStatsListener.jobMap), any(JobTrigger.class))).thenReturn(job);
    boolean startup = gatherStatsListener.startup(session);
    assertTrue(startup);
    assertEquals(1, gatherStatsListener.jobMap.size());
    assertEquals(gatherStatsListener.getTransFileName(), gatherStatsListener.jobMap.get("transFileName"));
    assertEquals(101, gatherStatsListener.getIntervalInSeconds());
    verify(scheduler).createJob(eq("Gather Stats"), eq(GatherStatsAction.class), eq(gatherStatsListener.jobMap), any(JobTrigger.class));
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) Test(org.junit.Test)

Example 75 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class QuartzSchedulerTest method testSetJobNextRunToNullDate.

@Test
public void testSetJobNextRunToNullDate() {
    Trigger trigger = Mockito.mock(Trigger.class);
    Job job = new Job();
    QuartzScheduler quartzScheduler = new QuartzScheduler();
    long nowDate = new Date().getTime();
    Mockito.when(trigger.getNextFireTime()).thenReturn(null);
    Mockito.when(trigger.getFireTimeAfter(any())).thenReturn(new Date(nowDate));
    quartzScheduler.setJobNextRun(job, trigger);
    assertEquals(null, job.getNextRun());
}
Also used : Trigger(org.quartz.Trigger) CronTrigger(org.quartz.CronTrigger) Job(org.pentaho.platform.api.scheduler2.Job) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)69 Serializable (java.io.Serializable)25 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)21 HashMap (java.util.HashMap)20 ArrayList (java.util.ArrayList)19 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)19 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)17 Date (java.util.Date)14 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)14 Job (com.google.cloud.video.transcoder.v1.Job)13 TranscoderServiceClient (com.google.cloud.video.transcoder.v1.TranscoderServiceClient)13 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)12 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 AudioStream (com.google.cloud.video.transcoder.v1.AudioStream)8 JobConfig (com.google.cloud.video.transcoder.v1.JobConfig)8 VideoStream (com.google.cloud.video.transcoder.v1.VideoStream)8 Map (java.util.Map)8 CronJobTrigger (org.pentaho.platform.api.scheduler2.CronJobTrigger)8