Search in sources :

Example 56 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class SchedulerResourceTest method testGetContentCleanerJobError.

@Test
public void testGetContentCleanerJobError() throws Exception {
    SchedulerException mockSchedulerException = mock(SchedulerException.class);
    doThrow(mockSchedulerException).when(schedulerResource.schedulerService).getContentCleanerJob();
    try {
        schedulerResource.getContentCleanerJob();
        fail();
    } catch (RuntimeException e) {
    // correct
    }
    verify(schedulerResource.schedulerService, times(1)).getContentCleanerJob();
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Test(org.junit.Test)

Example 57 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class SchedulerResourceTest method testPauseError.

@Test
public void testPauseError() throws Exception {
    SchedulerException mockSchedulerException = mock(SchedulerException.class);
    doThrow(mockSchedulerException).when(schedulerResource.schedulerService).pause();
    try {
        schedulerResource.pause();
        fail();
    } catch (RuntimeException e) {
    // correct
    }
    verify(schedulerResource.schedulerService, times(1)).pause();
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Test(org.junit.Test)

Example 58 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class SchedulerResourceTest method updateJob_Returns500_WhenSchedulerFails.

@Test
public void updateJob_Returns500_WhenSchedulerFails() throws Exception {
    JobScheduleRequest request = new JobScheduleRequest();
    when(schedulerResource.schedulerService.updateJob(request)).thenThrow(new SchedulerException(new RuntimeException("error")));
    assertUpdateJob(request, INTERNAL_SERVER_ERROR, "error");
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Test(org.junit.Test)

Example 59 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class SchedulerServiceTest method testStartException.

@Test
public void testStartException() throws SchedulerException {
    doReturn(true).when(schedulerService.policy).isAllowed(SchedulerAction.NAME);
    doThrow(new SchedulerException("")).when(schedulerService.scheduler).start();
    try {
        schedulerService.start();
        fail();
    } catch (SchedulerException e) {
    // Should go here
    }
    verify(schedulerService.policy).isAllowed(SchedulerAction.NAME);
    verify(schedulerService.scheduler).start();
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Test(org.junit.Test)

Example 60 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class SchedulerServiceTest method testGetBlockStatusException.

@Test
public void testGetBlockStatusException() throws Exception {
    JobScheduleRequest jobScheduleRequestMock = mock(JobScheduleRequest.class);
    doThrow(new SchedulerException("")).when(schedulerService).convertScheduleRequestToJobTrigger(jobScheduleRequestMock);
    try {
        schedulerService.getBlockStatus(jobScheduleRequestMock);
        fail();
    } catch (SchedulerException e) {
    // Should catch the exception
    }
    verify(schedulerService).convertScheduleRequestToJobTrigger(jobScheduleRequestMock);
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) 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