Search in sources :

Example 11 with SchedulerException

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));
}
Also used : IJobFilter(org.pentaho.platform.api.scheduler2.IJobFilter) SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Test(org.junit.Test)

Example 12 with SchedulerException

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);
}
Also used : Response(javax.ws.rs.core.Response) SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) IOException(java.io.IOException) Test(org.junit.Test)

Example 13 with SchedulerException

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();
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Test(org.junit.Test)

Example 14 with SchedulerException

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();
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Test(org.junit.Test)

Example 15 with SchedulerException

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);
}
Also used : Response(javax.ws.rs.core.Response) SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) UnifiedRepositoryException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryException) Test(org.junit.Test)

Aggregations

SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)51 Test (org.junit.Test)49 Job (org.pentaho.platform.api.scheduler2.Job)43 IScheduler (org.pentaho.platform.api.scheduler2.IScheduler)23 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)16 Serializable (java.io.Serializable)15 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)11 Date (java.util.Date)10 JobTrigger (org.pentaho.platform.api.scheduler2.JobTrigger)9 Scheduler (org.quartz.Scheduler)9 ArrayList (java.util.ArrayList)8 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)8 IOException (java.io.IOException)6 Calendar (java.util.Calendar)6 HashMap (java.util.HashMap)6 CronTrigger (org.quartz.CronTrigger)6 SimpleTrigger (org.quartz.SimpleTrigger)6 Trigger (org.quartz.Trigger)6 Response (javax.ws.rs.core.Response)5