use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class RepositoryCleanerSystemListenerTest method returnsTrue_EvenGetsExceptions.
@Test
public void returnsTrue_EvenGetsExceptions() throws Exception {
when(scheduler.getJobs(any(IJobFilter.class))).thenThrow(new SchedulerException("test exception"));
prepareMp();
assertTrue("The listener should not return false to let the system continue working", listener.startup(null));
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerResourceTest method testUpdateBlockoutError.
@Test
public void testUpdateBlockoutError() throws Exception {
String jobId = "jobId";
JobScheduleRequest mockJobScheduleRequest = mock(JobScheduleRequest.class);
Response mockUnauthorizedResponse = mock(Response.class);
doReturn(mockUnauthorizedResponse).when(schedulerResource).buildStatusResponse(UNAUTHORIZED);
// Test 1
IOException mockIOException = mock(IOException.class);
doThrow(mockIOException).when(schedulerResource.schedulerService).updateBlockout(jobId, mockJobScheduleRequest);
Response testResponse = schedulerResource.updateBlockout(jobId, mockJobScheduleRequest);
assertEquals(mockUnauthorizedResponse, testResponse);
// Test 2
SchedulerException mockSchedulerException = mock(SchedulerException.class);
doThrow(mockSchedulerException).when(schedulerResource.schedulerService).updateBlockout(jobId, mockJobScheduleRequest);
testResponse = schedulerResource.updateBlockout(jobId, mockJobScheduleRequest);
assertEquals(mockUnauthorizedResponse, testResponse);
// Test 3
IllegalAccessException mockIllegalAccessException = mock(IllegalAccessException.class);
doThrow(mockIllegalAccessException).when(schedulerResource.schedulerService).updateBlockout(jobId, mockJobScheduleRequest);
testResponse = schedulerResource.updateBlockout(jobId, mockJobScheduleRequest);
assertEquals(mockUnauthorizedResponse, testResponse);
verify(schedulerResource.schedulerService, times(3)).updateBlockout(jobId, mockJobScheduleRequest);
verify(schedulerResource, times(3)).buildStatusResponse(UNAUTHORIZED);
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerResourceTest method testGetStateError.
@Test
public void testGetStateError() throws Exception {
SchedulerException mockSchedulerException = mock(SchedulerException.class);
doThrow(mockSchedulerException).when(schedulerResource.schedulerService).getState();
try {
schedulerResource.getState();
fail();
} catch (RuntimeException e) {
// correct
}
verify(schedulerResource.schedulerService, times(1)).getState();
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerResourceTest method testShutdownError.
@Test
public void testShutdownError() throws Exception {
SchedulerException mockSchedulerException = mock(SchedulerException.class);
doThrow(mockSchedulerException).when(schedulerResource.schedulerService).shutdown();
try {
schedulerResource.shutdown();
fail();
} catch (RuntimeException e) {
// correct
}
verify(schedulerResource.schedulerService, times(1)).shutdown();
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerResourceTest method testBlockoutWillFireError.
@Test
public void testBlockoutWillFireError() throws Exception {
JobScheduleRequest mockJobScheduleRequest = mock(JobScheduleRequest.class);
UnifiedRepositoryException mockUnifiedRepositoryException = mock(UnifiedRepositoryException.class);
SchedulerException mockSchedulerException = mock(SchedulerException.class);
Response mockUnifiedRepositoryExceptionResponse = mock(Response.class);
doReturn(mockUnifiedRepositoryExceptionResponse).when(schedulerResource).buildServerErrorResponse(mockUnifiedRepositoryException);
Response mockSchedulerExceptionResponse = mock(Response.class);
doReturn(mockSchedulerExceptionResponse).when(schedulerResource).buildServerErrorResponse(mockSchedulerException);
// Test 1
doThrow(mockUnifiedRepositoryException).when(schedulerResource).convertScheduleRequestToJobTrigger(mockJobScheduleRequest);
Response testResponse = schedulerResource.blockoutWillFire(mockJobScheduleRequest);
assertEquals(mockUnifiedRepositoryExceptionResponse, testResponse);
// Test 2
doThrow(mockSchedulerException).when(schedulerResource).convertScheduleRequestToJobTrigger(mockJobScheduleRequest);
testResponse = schedulerResource.blockoutWillFire(mockJobScheduleRequest);
assertEquals(mockSchedulerExceptionResponse, testResponse);
verify(schedulerResource, times(1)).buildServerErrorResponse(mockUnifiedRepositoryException);
verify(schedulerResource, times(1)).buildServerErrorResponse(mockSchedulerException);
verify(schedulerResource, times(2)).convertScheduleRequestToJobTrigger(mockJobScheduleRequest);
}
Aggregations