use of com.google.cloud.dataproc.v1.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());
}
use of com.google.cloud.dataproc.v1.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());
}
use of com.google.cloud.dataproc.v1.Job in project pentaho-platform by pentaho.
the class SchedulerResourceTest method testGetJob.
@Test
public void testGetJob() throws Exception {
String jobId = "jobId";
String asCronString = "asCronString";
Job mockJob = mock(Job.class);
doReturn(mockJob).when(schedulerResource.schedulerService).getJobInfo(jobId);
Response mockResponse = mock(Response.class);
doReturn(mockResponse).when(schedulerResource).buildOkResponse(mockJob);
Response testResponse = schedulerResource.getJob(jobId, asCronString);
assertEquals(mockResponse, testResponse);
verify(schedulerResource.schedulerService, times(1)).getJobInfo(jobId);
}
use of com.google.cloud.dataproc.v1.Job in project pentaho-platform by pentaho.
the class RepositoryCleanerSystemListenerTest method doesNotRescheduleJob_IfFoundSame.
@Test
public void doesNotRescheduleJob_IfFoundSame() throws Exception {
final String oldJobId = "oldJobId";
Job oldJob = new Job();
oldJob.setJobTrigger(Frequency.WEEKLY.createTrigger());
oldJob.setJobId(oldJobId);
when(scheduler.getJobs(any(IJobFilter.class))).thenReturn(Collections.singletonList(oldJob));
prepareMp();
listener.setExecute(Frequency.WEEKLY.getValue());
assertTrue(listener.startup(null));
verify(scheduler, never()).removeJob(oldJobId);
verifyJobHaveNotCreated();
}
use of com.google.cloud.dataproc.v1.Job in project pentaho-platform by pentaho.
the class RepositoryCleanerSystemListenerTest method removesJobs_WhenDisabled.
@Test
public void removesJobs_WhenDisabled() throws Exception {
final String jobId = "jobId";
Job job = new Job();
job.setJobId(jobId);
when(scheduler.getJobs(any(IJobFilter.class))).thenReturn(Collections.singletonList(job));
prepareMp();
listener.setGcEnabled(false);
assertTrue(listener.startup(null));
verifyJobRemoved(jobId);
}
Aggregations