Search in sources :

Example 56 with Job

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

the class SchedulerServiceTest method testAddBlockout.

@Test
public void testAddBlockout() throws Exception {
    JobScheduleRequest jobScheduleRequest = mock(JobScheduleRequest.class);
    Job jobMock = mock(Job.class);
    JobScheduleParam jobScheduleParamMock1 = mock(JobScheduleParam.class);
    JobScheduleParam jobScheduleParamMock2 = mock(JobScheduleParam.class);
    List<JobScheduleParam> jobScheduleParams = new ArrayList<>();
    doReturn(true).when(schedulerService).canAdminister();
    doNothing().when(jobScheduleRequest).setActionClass(nullable(String.class));
    doReturn(jobScheduleParams).when(jobScheduleRequest).getJobParameters();
    doReturn(jobScheduleParamMock1).when(schedulerService).getJobScheduleParam(nullable(String.class), nullable(String.class));
    doReturn(jobScheduleParamMock2).when(schedulerService).getJobScheduleParam(nullable(String.class), anyLong());
    doReturn(jobMock).when(schedulerService).createJob(any(JobScheduleRequest.class));
    Job job = schedulerService.addBlockout(jobScheduleRequest);
    assertNotNull(job);
    assertEquals(2, jobScheduleParams.size());
    verify(schedulerService).canAdminister();
    verify(jobScheduleRequest).setActionClass(nullable(String.class));
    verify(jobScheduleRequest, times(2)).getJobParameters();
    verify(schedulerService).createJob(any(JobScheduleRequest.class));
}
Also used : JobScheduleParam(org.pentaho.platform.web.http.api.resources.JobScheduleParam) ArrayList(java.util.ArrayList) Job(org.pentaho.platform.api.scheduler2.Job) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) Test(org.junit.Test)

Example 57 with Job

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

the class SchedulerServiceTest method testGetJobState.

@Test
public void testGetJobState() throws Exception {
    JobRequest mockJobRequest = mock(JobRequest.class);
    String jobId = "jobId";
    doReturn(jobId).when(mockJobRequest).getJobId();
    IPentahoSession mockSession = mock(IPentahoSession.class);
    doReturn(mockSession).when(schedulerService).getSession();
    Job mockJob = mock(Job.class);
    doReturn(mockJob).when(schedulerService).getJob(jobId);
    doReturn(Job.JobState.BLOCKED).when(mockJob).getState();
    String username = "username";
    doReturn(username).when(mockJob).getUserName();
    doReturn(username).when(mockSession).getName();
    // Test 1
    doReturn(true).when(schedulerService).isScheduleAllowed();
    Job.JobState testState = schedulerService.getJobState(mockJobRequest);
    assertEquals(Job.JobState.BLOCKED, testState);
    // Test 2
    doReturn(false).when(schedulerService).isScheduleAllowed();
    testState = schedulerService.getJobState(mockJobRequest);
    assertEquals(Job.JobState.BLOCKED, testState);
    verify(mockJobRequest, times(2)).getJobId();
    verify(schedulerService, times(1)).getSession();
    verify(schedulerService, times(2)).getJob(jobId);
    verify(mockJob, times(2)).getState();
    verify(mockJob, times(1)).getUserName();
    verify(mockSession, times(1)).getName();
}
Also used : JobRequest(org.pentaho.platform.web.http.api.resources.JobRequest) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 58 with Job

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

the class SchedulerServiceTest method testRemoveJobException.

@Test
public void testRemoveJobException() throws SchedulerException {
    Job job = mock(Job.class);
    doReturn(job).when(schedulerService).getJob(nullable(String.class));
    doReturn(true).when(schedulerService).isScheduleAllowed();
    doThrow(new SchedulerException("pause-exception")).when(schedulerService.scheduler).removeJob(nullable(String.class));
    try {
        schedulerService.removeJob("job-id");
    } catch (SchedulerException e) {
        assertEquals("pause-exception", e.getMessage());
    }
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 59 with Job

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

the class QuartzSchedulerIT method getJobTest.

@Test
public void getJobTest() throws Exception {
    final CronTrigger cronTrigger = mock(CronTrigger.class);
    when(cronTrigger.getCronExpression()).thenReturn(CRON_EXPRESSION);
    when(quartzScheduler.getTriggersOfJob(eq(JOB_ID), eq(USER_NAME))).thenReturn(new Trigger[] { cronTrigger });
    setJobDataMap(USER_NAME);
    final Job job = scheduler.getJob(JOB_ID);
    assertEquals(JOB_ID, job.getJobId());
    assertEquals(jobDetails, job.getJobParams());
    assertEquals(USER_NAME, job.getUserName());
    assertEquals(JOB_NAME, job.getJobName());
    assertEquals(Job.JobState.NORMAL, job.getState());
}
Also used : CronTrigger(org.quartz.CronTrigger) Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 60 with Job

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

the class QuartzSchedulerIT method createJobTest_ForUser.

@Test
public void createJobTest_ForUser() throws Exception {
    String actionId = "actionId";
    ComplexJobTrigger trigger = getComplexJobTrigger();
    IBackgroundExecutionStreamProvider outputStreamProvider = mock(IBackgroundExecutionStreamProvider.class);
    Map<String, Serializable> paramMap = new HashMap<>();
    paramMap.put(QuartzScheduler.RESERVEDMAPKEY_ACTIONUSER, "ninja");
    final Job job = scheduler.createJob(JOB_NAME, paramMap, trigger, outputStreamProvider);
    assertNotNull(job);
    assertEquals("ninja", job.getUserName());
    assertEquals(Job.JobState.NORMAL, job.getState());
}
Also used : IBackgroundExecutionStreamProvider(org.pentaho.platform.api.scheduler2.IBackgroundExecutionStreamProvider) Serializable(java.io.Serializable) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) HashMap(java.util.HashMap) 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