use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testGetBlockStatus.
@Test
public void testGetBlockStatus() throws Exception {
JobScheduleRequest jobScheduleRequestMock = mock(JobScheduleRequest.class);
BlockStatusProxy blockStatusProxyMock = mock(BlockStatusProxy.class);
IJobTrigger jobTrigger = mock(IJobTrigger.class);
doReturn(jobTrigger).when(schedulerService).convertScheduleRequestToJobTrigger(jobScheduleRequestMock);
doReturn(true).when(schedulerService.blockoutManager).isPartiallyBlocked(jobTrigger);
doReturn(true).when(schedulerService.blockoutManager).willFire(jobTrigger);
doReturn(blockStatusProxyMock).when(schedulerService).getBlockStatusProxy(anyBoolean(), anyBoolean());
// Test 1
BlockStatusProxy blockStatusProxy = schedulerService.getBlockStatus(jobScheduleRequestMock);
assertNotNull(blockStatusProxy);
// Test 2
doReturn(false).when(schedulerService.blockoutManager).isPartiallyBlocked(jobTrigger);
blockStatusProxy = schedulerService.getBlockStatus(jobScheduleRequestMock);
assertNotNull(blockStatusProxy);
verify(schedulerService, times(2)).convertScheduleRequestToJobTrigger(jobScheduleRequestMock);
verify(schedulerService.blockoutManager, times(2)).isPartiallyBlocked(jobTrigger);
verify(schedulerService, times(2)).getBlockStatusProxy(anyBoolean(), anyBoolean());
verify(schedulerService.blockoutManager, times(1)).willFire(jobTrigger);
}
use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testAddBlockoutException.
@Test
public void testAddBlockoutException() throws Exception {
// Test 1
JobScheduleRequest jobScheduleRequest = mock(JobScheduleRequest.class);
doReturn(false).when(schedulerService).canAdminister();
try {
schedulerService.addBlockout(jobScheduleRequest);
fail();
} catch (IllegalAccessException e) {
// Should catch exception
}
// Test 2
Job jobMock = mock(Job.class);
JobScheduleParam jobScheduleParamMock1 = mock(JobScheduleParam.class);
JobScheduleParam jobScheduleParamMock2 = mock(JobScheduleParam.class);
List<JobScheduleParam> jobScheduleParams = new ArrayList<>();
doReturn(true).when(schedulerService).canAdminister();
doNothing().when(jobScheduleRequest).setActionClass(anyString());
doReturn(jobScheduleParams).when(jobScheduleRequest).getJobParameters();
doReturn(jobScheduleParamMock1).when(schedulerService).getJobScheduleParam(anyString(), anyString());
doReturn(jobScheduleParamMock2).when(schedulerService).getJobScheduleParam(anyString(), anyLong());
doNothing().when(schedulerService).updateStartDateForTimeZone(jobScheduleRequest);
doReturn(jobMock).when(schedulerService).createJob(any(JobScheduleRequest.class));
doThrow(new IOException()).when(schedulerService).createJob(jobScheduleRequest);
try {
schedulerService.addBlockout(jobScheduleRequest);
fail();
} catch (IOException e) {
// Should catch exception
}
// Test 3
doThrow(new SchedulerException("")).when(schedulerService).createJob(jobScheduleRequest);
try {
schedulerService.addBlockout(jobScheduleRequest);
fail();
} catch (SchedulerException e) {
// Should catch exception
}
verify(schedulerService, times(3)).canAdminister();
verify(jobScheduleRequest, times(2)).setActionClass(anyString());
verify(jobScheduleRequest, times(4)).getJobParameters();
verify(schedulerService, times(2)).createJob(any(JobScheduleRequest.class));
}
use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testUpdateBlockoutException.
@Test
public void testUpdateBlockoutException() throws Exception {
String jobId = "jobId";
JobScheduleRequest jobScheduleRequest = mock(JobScheduleRequest.class);
Job job = mock(Job.class);
// Test 1
doReturn(false).when(schedulerService).canAdminister();
try {
schedulerService.updateBlockout(jobId, jobScheduleRequest);
fail();
} catch (IllegalAccessException e) {
// Should catch the exception
}
// Test 2
doReturn(true).when(schedulerService).canAdminister();
doThrow(new SchedulerException("")).when(schedulerService).removeJob(anyString());
try {
schedulerService.updateBlockout(jobId, jobScheduleRequest);
fail();
} catch (SchedulerException e) {
// Should catch the exception
}
// Test 3
doReturn(false).when(schedulerService).removeJob(anyString());
try {
schedulerService.updateBlockout(jobId, jobScheduleRequest);
fail();
} catch (IllegalAccessException e) {
// Should catch the exception
}
// Test 4
doReturn(true).when(schedulerService).removeJob(anyString());
doThrow(new IOException()).when(schedulerService).addBlockout(jobScheduleRequest);
try {
schedulerService.updateBlockout(jobId, jobScheduleRequest);
fail();
} catch (IOException e) {
// Should catch the exception
}
// Test 5
doThrow(new SchedulerException("")).when(schedulerService).addBlockout(jobScheduleRequest);
try {
schedulerService.updateBlockout(jobId, jobScheduleRequest);
fail();
} catch (SchedulerException e) {
// Should catch the exception
}
verify(schedulerService, times(5)).canAdminister();
verify(schedulerService, times(4)).removeJob(anyString());
verify(schedulerService, times(2)).addBlockout(jobScheduleRequest);
}
use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class SolutionImportHandlerIT method createJobScheduleRequest.
private JobScheduleRequest createJobScheduleRequest(String name, JobState jobState) {
JobScheduleRequest scheduleRequest = mock(JobScheduleRequest.class);
doReturn(TestAction.class.getName()).when(scheduleRequest).getActionClass();
doReturn(name).when(scheduleRequest).getJobName();
doReturn(jobState).when(scheduleRequest).getJobState();
return scheduleRequest;
}
Aggregations