use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testAddBlockoutException.
@Test
public void testAddBlockoutException() throws Exception {
// Test 1
JobScheduleRequest jobScheduleRequest = mock(JobScheduleRequest.class);
doReturn(false).when(schedulerService).canAdminister();
try {
schedulerService.addBlockout(jobScheduleRequest);
fail();
} catch (IllegalAccessException e) {
// Should catch exception
}
// Test 2
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());
doThrow(new IOException()).when(schedulerService).createJob(jobScheduleRequest);
try {
schedulerService.addBlockout(jobScheduleRequest);
fail();
} catch (IOException e) {
// Should catch exception
}
// Test 3
doThrow(new SchedulerException("")).when(schedulerService).createJob(jobScheduleRequest);
try {
schedulerService.addBlockout(jobScheduleRequest);
fail();
} catch (SchedulerException e) {
// Should catch exception
}
verify(schedulerService, times(3)).canAdminister();
verify(jobScheduleRequest, times(2)).setActionClass(nullable(String.class));
verify(jobScheduleRequest, times(4)).getJobParameters();
verify(schedulerService, times(2)).createJob(any(JobScheduleRequest.class));
}
use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testGetJobInfoError.
@Test
public void testGetJobInfoError() 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();
String username = "username";
doReturn(username).when(mockJob).getUserName();
try {
schedulerService.getJobInfo(jobId);
fail();
} catch (RuntimeException e) {
// Expected
}
}
use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testGetContentCleanerJob.
@Test
public void testGetContentCleanerJob() throws Exception {
IJobFilter jobFilter = mock(IJobFilter.class);
List<Job> jobs = new ArrayList<>();
IPentahoSession session = mock(IPentahoSession.class);
doReturn(session).when(schedulerService).getSession();
doReturn("sessionName").when(session).getName();
doReturn(true).when(schedulerService.policy).isAllowed(AdministerSecurityAction.NAME);
doReturn(jobFilter).when(schedulerService).getJobFilter(anyBoolean(), nullable(String.class));
doReturn(jobs).when(schedulerService.scheduler).getJobs(any(IJobFilter.class));
// Test 1
Job job = schedulerService.getContentCleanerJob();
assertNull(job);
// Test 2
Job job1 = mock(Job.class);
jobs.add(job1);
job = schedulerService.getContentCleanerJob();
assertNotNull(job);
verify(schedulerService, times(2)).getSession();
verify(session, times(2)).getName();
verify(schedulerService.policy, times(2)).isAllowed(AdministerSecurityAction.NAME);
verify(schedulerService.scheduler, times(2)).getJobs(any(IJobFilter.class));
}
use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testGetJobStateError.
@Test
public void testGetJobStateError() 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);
String username = "username";
doReturn(username).when(mockJob).getUserName();
String sessionName = "notUsername";
doReturn(sessionName).when(mockSession).getName();
doReturn(false).when(schedulerService).isScheduleAllowed();
try {
schedulerService.getJobState(mockJobRequest);
fail();
} catch (UnsupportedOperationException e) {
// Expected
}
}
use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testRemoveJob.
@Test
public void testRemoveJob() throws SchedulerException {
Job job = mock(Job.class);
doReturn(job).when(schedulerService).getJob(nullable(String.class));
doReturn(true).when(schedulerService).isScheduleAllowed();
doNothing().when(schedulerService.scheduler).removeJob(nullable(String.class));
schedulerService.removeJob("job-id");
}
Aggregations