use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class SolutionImportHandlerTest method testFileIsScheduleInputSource.
@Test
public void testFileIsScheduleInputSource() {
ExportManifest manifest = Mockito.mock(ExportManifest.class);
SolutionImportHandler spyHandler = Mockito.spy(importHandler);
List<JobScheduleRequest> scheduleRequests = new ArrayList<>();
for (int i = 0; i < 10; i++) {
JobScheduleRequest jobScheduleRequest = new JobScheduleRequest();
jobScheduleRequest.setInputFile("/public/test/file" + i);
scheduleRequests.add(jobScheduleRequest);
}
Assert.assertFalse(spyHandler.fileIsScheduleInputSource(manifest, null));
Mockito.when(manifest.getScheduleList()).thenReturn(scheduleRequests);
Assert.assertFalse(spyHandler.fileIsScheduleInputSource(manifest, "/public/file"));
Assert.assertTrue(spyHandler.fileIsScheduleInputSource(manifest, "/public/test/file3"));
Assert.assertTrue(spyHandler.fileIsScheduleInputSource(manifest, "public/test/file3"));
}
use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class SolutionImportHandlerTest method testImportSchedules_FailsToCreateScheduleWithSpace.
@Test
public void testImportSchedules_FailsToCreateScheduleWithSpace() throws Exception {
List<JobScheduleRequest> schedules = new ArrayList<>();
JobScheduleRequest scheduleRequest = Mockito.spy(new JobScheduleRequest());
scheduleRequest.setInputFile("/home/admin/scheduled Transform.ktr");
scheduleRequest.setOutputFile("/home/admin/scheduled Transform*");
schedules.add(scheduleRequest);
SolutionImportHandler spyHandler = Mockito.spy(importHandler);
ScheduleRequestMatcher throwMatcher = new ScheduleRequestMatcher("/home/admin/scheduled Transform.ktr", "/home/admin/scheduled Transform*");
Mockito.doThrow(new IOException("error creating schedule")).when(spyHandler).createSchedulerJob(Mockito.any(SchedulerResource.class), Mockito.argThat(throwMatcher));
Response response = Mockito.mock(Response.class);
Mockito.when(response.getStatus()).thenReturn(Response.Status.OK.getStatusCode());
Mockito.when(response.getEntity()).thenReturn("job id");
ScheduleRequestMatcher goodMatcher = new ScheduleRequestMatcher("/home/admin/scheduled_Transform.ktr", "/home/admin/scheduled_Transform*");
Mockito.doReturn(response).when(spyHandler).createSchedulerJob(Mockito.any(SchedulerResource.class), Mockito.argThat(goodMatcher));
mockSchedulerPause();
spyHandler.importSchedules(schedules);
Mockito.verify(spyHandler, Mockito.times(2)).createSchedulerJob(Mockito.any(SchedulerResource.class), Mockito.any(JobScheduleRequest.class));
Assert.assertEquals(1, ImportSession.getSession().getImportedScheduleJobIds().size());
}
use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class SolutionImportHandlerTest method testImportSchedules_FailsToCreateSchedule.
@Test
public void testImportSchedules_FailsToCreateSchedule() throws Exception {
List<JobScheduleRequest> schedules = new ArrayList<>();
JobScheduleRequest scheduleRequest = Mockito.spy(new JobScheduleRequest());
scheduleRequest.setInputFile("/home/admin/scheduledTransform.ktr");
scheduleRequest.setOutputFile("/home/admin/scheduledTransform*");
schedules.add(scheduleRequest);
SolutionImportHandler spyHandler = Mockito.spy(importHandler);
Mockito.doThrow(new IOException("error creating schedule")).when(spyHandler).createSchedulerJob(Mockito.any(SchedulerResource.class), Mockito.eq(scheduleRequest));
mockSchedulerPause();
spyHandler.importSchedules(schedules);
Assert.assertEquals(0, ImportSession.getSession().getImportedScheduleJobIds().size());
}
use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testUpdateBlockout.
@Test
public void testUpdateBlockout() throws Exception {
String jobId = "jobId";
JobScheduleRequest jobScheduleRequest = mock(JobScheduleRequest.class);
Job jobMock = mock(Job.class);
doReturn(true).when(schedulerService).canAdminister();
doReturn(true).when(schedulerService).removeJob(anyString());
doReturn(jobMock).when(schedulerService).addBlockout(jobScheduleRequest);
Job job = schedulerService.updateBlockout(jobId, jobScheduleRequest);
assertNotNull(job);
verify(schedulerService).canAdminister();
verify(schedulerService).removeJob(anyString());
verify(schedulerService).addBlockout(jobScheduleRequest);
}
use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest 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);
}
Aggregations