use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerResourceTest method testTriggerNowError.
@Test
public void testTriggerNowError() throws Exception {
JobRequest mockJobRequest = mock(JobRequest.class);
String jobId = "jobId";
doReturn(jobId).when(mockJobRequest).getJobId();
SchedulerException mockSchedulerException = mock(SchedulerException.class);
doThrow(mockSchedulerException).when(schedulerResource.schedulerService).triggerNow(jobId);
try {
schedulerResource.triggerNow(mockJobRequest);
fail();
} catch (RuntimeException e) {
// correct
}
verify(mockJobRequest, times(1)).getJobId();
verify(schedulerResource.schedulerService, times(1)).triggerNow(jobId);
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerResourceTest method testResumeJobError.
@Test
public void testResumeJobError() throws Exception {
String jobId = "jobId";
JobRequest mockJobRequest = mock(JobRequest.class);
doReturn(jobId).when(mockJobRequest).getJobId();
SchedulerException mockSchedulerException = mock(SchedulerException.class);
doThrow(mockSchedulerException).when(schedulerResource.schedulerService).resumeJob(jobId);
try {
schedulerResource.resumeJob(mockJobRequest);
fail();
} catch (RuntimeException e) {
// correct
}
verify(schedulerResource.schedulerService, times(1)).resumeJob(jobId);
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerResourceTest method testGetJobsError.
@Test
public void testGetJobsError() throws Exception {
Boolean asCronString = Boolean.FALSE;
SchedulerException mockSchedulerException = mock(SchedulerException.class);
doThrow(mockSchedulerException).when(schedulerResource.schedulerService).getJobs();
try {
schedulerResource.getJobs(asCronString);
fail();
} catch (RuntimeException e) {
// correct
}
verify(schedulerResource.schedulerService, times(1)).getJobs();
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerResourceTest method testGetJobStateError.
@Test
public void testGetJobStateError() throws Exception {
JobRequest mockJobRequest = mock(JobRequest.class);
Response mockUnauthorizedResponse = mock(Response.class);
doReturn(mockUnauthorizedResponse).when(schedulerResource).buildPlainTextStatusResponse(UNAUTHORIZED);
// Test 1
UnsupportedOperationException mockUnsupportedOperationException = mock(UnsupportedOperationException.class);
doThrow(mockUnsupportedOperationException).when(schedulerResource.schedulerService).getJobState(mockJobRequest);
Response testResponse = schedulerResource.getJobState(mockJobRequest);
assertEquals(mockUnauthorizedResponse, testResponse);
// Test 2
SchedulerException mockSchedulerException = mock(SchedulerException.class);
doThrow(mockSchedulerException).when(schedulerResource.schedulerService).getJobState(mockJobRequest);
try {
schedulerResource.getJobState(mockJobRequest);
fail();
} catch (RuntimeException e) {
// correct
}
verify(schedulerResource, times(1)).buildPlainTextStatusResponse(UNAUTHORIZED);
verify(schedulerResource.schedulerService, times(2)).getJobState(mockJobRequest);
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerResourceTest method testPauseJobError.
@Test
public void testPauseJobError() throws Exception {
String jobId = "jobId";
JobRequest mockJobRequest = mock(JobRequest.class);
doReturn(jobId).when(mockJobRequest).getJobId();
SchedulerException mockSchedulerException = mock(SchedulerException.class);
doThrow(mockSchedulerException).when(schedulerResource.schedulerService).pauseJob(jobId);
try {
schedulerResource.pauseJob(mockJobRequest);
fail();
} catch (RuntimeException e) {
// correct
}
verify(schedulerResource.schedulerService, times(1)).pauseJob(jobId);
}
Aggregations