Search in sources :

Example 41 with Job

use of com.google.cloud.talent.v4.Job 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));
    }
}
Also used : JobScheduleParam(org.pentaho.platform.web.http.api.resources.JobScheduleParam) Serializable(java.io.Serializable) HashMap(java.util.HashMap) Job(org.pentaho.platform.api.scheduler2.Job) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) Date(java.util.Date) CronJobTrigger(org.pentaho.platform.api.scheduler2.CronJobTrigger) Test(org.junit.Test)

Example 42 with Job

use of com.google.cloud.talent.v4.Job 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)

Example 43 with Job

use of com.google.cloud.talent.v4.Job 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());
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) 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 44 with Job

use of com.google.cloud.talent.v4.Job in project pentaho-platform by pentaho.

the class SchedulerResourceTest method testTriggerNow.

@Test
public void testTriggerNow() throws Exception {
    JobRequest mockJobRequest = mock(JobRequest.class);
    String jobId = "jobId";
    doReturn(jobId).when(mockJobRequest).getJobId();
    Job mockJob = mock(Job.class);
    doReturn(mockJob).when(schedulerResource.schedulerService).triggerNow(jobId);
    Job.JobState mockJobState = Job.JobState.BLOCKED;
    doReturn(mockJobState).when(mockJob).getState();
    Response mockResponse = mock(Response.class);
    doReturn(mockResponse).when(schedulerResource).buildPlainTextOkResponse(mockJobState.name());
    Response testResponse = schedulerResource.triggerNow(mockJobRequest);
    assertEquals(mockResponse, testResponse);
    verify(mockJobRequest, times(1)).getJobId();
    verify(schedulerResource.schedulerService, times(1)).triggerNow(jobId);
    verify(mockJob, times(1)).getState();
    verify(schedulerResource, times(1)).buildPlainTextOkResponse(mockJobState.name());
}
Also used : Response(javax.ws.rs.core.Response) Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 45 with Job

use of com.google.cloud.talent.v4.Job in project pentaho-platform by pentaho.

the class SchedulerResourceTest method testRemoveJob.

@Test
public void testRemoveJob() throws Exception {
    JobRequest mockJobRequest = mock(JobRequest.class);
    String jobId = "jobId";
    doReturn(jobId).when(mockJobRequest).getJobId();
    Job mockJob = mock(Job.class);
    doReturn(mockJob).when(schedulerResource.schedulerService).getJob(jobId);
    Job.JobState mockJobState = Job.JobState.BLOCKED;
    doReturn(mockJobState).when(mockJob).getState();
    Response mockRemovedResponse = mock(Response.class);
    doReturn(mockRemovedResponse).when(schedulerResource).buildPlainTextOkResponse("REMOVED");
    Response mockJobStateResponse = mock(Response.class);
    doReturn(mockJobStateResponse).when(schedulerResource).buildPlainTextOkResponse(mockJobState.name());
    // Test 1
    doReturn(true).when(schedulerResource.schedulerService).removeJob(jobId);
    Response testResponse = schedulerResource.removeJob(mockJobRequest);
    assertEquals(mockRemovedResponse, testResponse);
    // Test 2
    doReturn(false).when(schedulerResource.schedulerService).removeJob(jobId);
    testResponse = schedulerResource.removeJob(mockJobRequest);
    assertEquals(mockJobStateResponse, testResponse);
    verify(mockJobRequest, times(3)).getJobId();
    verify(schedulerResource.schedulerService, times(1)).getJob(jobId);
    verify(mockJob, times(1)).getState();
    verify(schedulerResource, times(1)).buildPlainTextOkResponse("REMOVED");
    verify(schedulerResource, times(1)).buildPlainTextOkResponse(mockJobState.name());
}
Also used : Response(javax.ws.rs.core.Response) Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)89 Job (io.fabric8.kubernetes.api.model.batch.v1.Job)38 Serializable (java.io.Serializable)25 ArrayList (java.util.ArrayList)24 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)21 Job (com.google.cloud.talent.v4beta1.Job)20 HashMap (java.util.HashMap)20 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 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)16 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 JobBuilder (io.fabric8.kubernetes.api.model.batch.v1.JobBuilder)13 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 Map (java.util.Map)11 Test (org.junit.jupiter.api.Test)10