Search in sources :

Example 11 with Job

use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.

the class SchedulerServiceTest method testResumeJobException.

@Test
public void testResumeJobException() 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).resumeJob(nullable(String.class));
    try {
        schedulerService.resumeJob("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 12 with Job

use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.

the class SchedulerServiceTest method testGetJobInfo.

@Test
public void testGetJobInfo() throws Exception {
    String jobId = "jobId";
    Job mockJob = mock(Job.class);
    doReturn(mockJob).when(schedulerService).getJob(jobId);
    IPentahoSession mockPentahoSession = mock(IPentahoSession.class);
    doReturn(mockPentahoSession).when(schedulerService).getSession();
    String sessionName = "sessionName";
    doReturn(sessionName).when(mockPentahoSession).getName();
    doReturn(sessionName).when(mockJob).getUserName();
    Map<String, Serializable> mockJobParams = mock(Map.class);
    doReturn(mockJobParams).when(mockJob).getJobParams();
    Set<String> jobParamsKeyset = new HashSet<>();
    doReturn(jobParamsKeyset).when(mockJobParams).keySet();
    String jobParamKey = "key";
    jobParamsKeyset.add(jobParamKey);
    String value = "value";
    String[] testArray = new String[] { value };
    doReturn(testArray).when(mockJobParams).get(jobParamKey);
    // Test 1
    Job testJob = schedulerService.getJobInfo(jobId);
    assertEquals(mockJob, testJob);
    // Test 2
    testJob = schedulerService.getJobInfo(jobId);
    assertEquals(mockJob, testJob);
    verify(mockJobParams, times(2)).put(eq(jobParamKey), any(Serializable.class));
    verify(schedulerService, times(2)).getJob(jobId);
    verify(schedulerService, times(2)).getSession();
    verify(mockPentahoSession, times(2)).getName();
    verify(mockJob, times(2)).getUserName();
    verify(mockJob, times(6)).getJobParams();
    verify(mockJobParams, times(2)).keySet();
    verify(mockJobParams, times(2)).get(jobParamKey);
    verify(schedulerService, times(2)).canAdminister(null);
}
Also used : Serializable(java.io.Serializable) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Job(org.pentaho.platform.api.scheduler2.Job) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with Job

use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.

the class SchedulerServiceTest method testResumeJob.

@Test
public void testResumeJob() throws SchedulerException {
    Job job = mock(Job.class);
    doReturn(job).when(schedulerService).getJob(nullable(String.class));
    doReturn(true).when(schedulerService).isScheduleAllowed();
    doNothing().when(schedulerService.scheduler).resumeJob(nullable(String.class));
    schedulerService.resumeJob("job-id");
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 14 with Job

use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.

the class SchedulerServiceTest method testCreateJob.

@Test
public void testCreateJob() throws Exception {
    List<JobScheduleParam> jobParameters = new ArrayList<>();
    JobScheduleParam jobScheduleParam1 = mock(JobScheduleParam.class);
    doReturn("name1").when(jobScheduleParam1).getName();
    doReturn("value1").when(jobScheduleParam1).getValue();
    jobParameters.add(jobScheduleParam1);
    Job job = mock(Job.class);
    JobScheduleRequest scheduleRequest = mock(JobScheduleRequest.class);
    doReturn("className").when(scheduleRequest).getActionClass();
    doReturn("jobName").when(scheduleRequest).getJobName();
    doReturn(jobParameters).when(scheduleRequest).getJobParameters();
    doNothing().when(scheduleRequest).setJobName(nullable(String.class));
    doReturn("timezone").when(scheduleRequest).getTimeZone();
    doNothing().when(schedulerService).updateStartDateForTimeZone(scheduleRequest);
    doReturn(true).when(schedulerService).isPdiFile(any(RepositoryFile.class));
    doReturn(false).when(schedulerService).isPdiFile(null);
    SchedulerOutputPathResolver schedulerOutputPathResolver = mock(SchedulerOutputPathResolver.class);
    doReturn("outputFile").when(schedulerOutputPathResolver).resolveOutputFilePath();
    doReturn(schedulerOutputPathResolver).when(schedulerService).getSchedulerOutputPathResolver(any(JobScheduleRequest.class));
    SimpleJobTrigger simpleJobTrigger = mock(SimpleJobTrigger.class);
    RepositoryFile repositoryFile = mock(RepositoryFile.class);
    doReturn("file.ext").when(repositoryFile).getName();
    Map<String, Serializable> metadata = mock(Map.class);
    doReturn(metadata).when(schedulerService.repository).getFileMetadata(nullable(String.class));
    doReturn(true).when(metadata).containsKey(RepositoryFile.SCHEDULABLE_KEY);
    doReturn("true").when(metadata).get(RepositoryFile.SCHEDULABLE_KEY);
    doReturn(simpleJobTrigger).when(scheduleRequest).getSimpleJobTrigger();
    doReturn(true).when(schedulerService.policy).isAllowed(SchedulerAction.NAME);
    doReturn("file.ext").when(scheduleRequest).getInputFile();
    doReturn(repositoryFile).when(schedulerService.repository).getFile(nullable(String.class));
    doReturn(true).when(schedulerService).getAutoCreateUniqueFilename(any(JobScheduleRequest.class));
    doReturn(job).when(schedulerService.scheduler).createJob(nullable(String.class), nullable(String.class), any(Map.class), any(IJobTrigger.class), any(IBackgroundExecutionStreamProvider.class));
    doReturn(Class.class).when(schedulerService).getAction(nullable(String.class));
    doReturn(job).when(schedulerService.scheduler).createJob(nullable(String.class), any(Class.class), any(Map.class), any(IJobTrigger.class));
    // Test 1
    schedulerService.createJob(scheduleRequest);
    // Test 2
    doReturn("").when(scheduleRequest).getJobName();
    schedulerService.createJob(scheduleRequest);
    // Test 3
    doReturn("").when(scheduleRequest).getInputFile();
    doReturn("").when(scheduleRequest).getActionClass();
    schedulerService.createJob(scheduleRequest);
    verify(scheduleRequest, times(15)).getSimpleJobTrigger();
    verify(scheduleRequest, times(9)).getInputFile();
    verify(schedulerService.policy, times(3)).isAllowed(SchedulerAction.NAME);
    verify(schedulerService.repository, times(2)).getFile(nullable(String.class));
    verify(scheduleRequest, times(6)).getJobName();
    verify(scheduleRequest, times(3)).setJobName(nullable(String.class));
    verify(scheduleRequest, times(5)).getActionClass();
    verify(schedulerService.repository, times(2)).getFileMetadata(nullable(String.class));
    verify(schedulerService, times(3)).isPdiFile(nullable(RepositoryFile.class));
    verify(schedulerService, times(2)).handlePDIScheduling(any(RepositoryFile.class), any(HashMap.class), any(HashMap.class));
    verify(schedulerService, times(2)).getSchedulerOutputPathResolver(any(JobScheduleRequest.class));
    verify(scheduleRequest, times(5)).getActionClass();
    verify(schedulerService).getAction(nullable(String.class));
    verify(schedulerService, times(3)).updateStartDateForTimeZone(scheduleRequest);
    verify(schedulerService.scheduler).createJob(nullable(String.class), any(Class.class), any(Map.class), any(IJobTrigger.class));
}
Also used : JobScheduleParam(org.pentaho.platform.web.http.api.resources.JobScheduleParam) IBackgroundExecutionStreamProvider(org.pentaho.platform.api.scheduler2.IBackgroundExecutionStreamProvider) Serializable(java.io.Serializable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SchedulerOutputPathResolver(org.pentaho.platform.web.http.api.resources.SchedulerOutputPathResolver) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) Job(org.pentaho.platform.api.scheduler2.Job) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 15 with Job

use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.

the class SchedulerServiceTest method testPauseJobException.

@Test
public void testPauseJobException() 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).pauseJob(nullable(String.class));
    try {
        schedulerService.pauseJob("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)

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 TranscoderServiceClient (com.google.cloud.video.transcoder.v1.TranscoderServiceClient)18 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 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)12 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 AudioStream (com.google.cloud.video.transcoder.v1.AudioStream)9 JobConfig (com.google.cloud.video.transcoder.v1.JobConfig)9 VideoStream (com.google.cloud.video.transcoder.v1.VideoStream)9 Map (java.util.Map)8 CronJobTrigger (org.pentaho.platform.api.scheduler2.CronJobTrigger)8