Search in sources :

Example 51 with SchedulerException

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

Example 52 with SchedulerException

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

Example 53 with SchedulerException

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

Example 54 with SchedulerException

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

Example 55 with SchedulerException

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