use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_SimpleJobTrigger.
@Test
public void testCreateJobScheduleRequest_SimpleJobTrigger() throws Exception {
String jobName = "JOB";
Job job = mock(Job.class);
SimpleJobTrigger trigger = mock(SimpleJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
assertNotNull(jobScheduleRequest);
assertEquals(jobName, jobScheduleRequest.getJobName());
assertEquals(trigger, jobScheduleRequest.getSimpleJobTrigger());
}
use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_CronJobTrigger.
@Test
public void testCreateJobScheduleRequest_CronJobTrigger() throws Exception {
String jobName = "JOB";
Job job = mock(Job.class);
CronJobTrigger trigger = mock(CronJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
assertNotNull(jobScheduleRequest);
assertEquals(jobName, jobScheduleRequest.getJobName());
assertEquals(trigger, jobScheduleRequest.getCronJobTrigger());
}
use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_TimeZoneJobParam.
@Test
public void testCreateJobScheduleRequest_TimeZoneJobParam() throws Exception {
String jobName = "JOB";
String timeZone = "America/New_York";
Map<String, Serializable> params = new HashMap<>();
params.put(IBlockoutManager.TIME_ZONE_PARAM, timeZone);
Job job = mock(Job.class);
CronJobTrigger trigger = mock(CronJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
when(job.getJobParams()).thenReturn(params);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
assertEquals(timeZone, jobScheduleRequest.getTimeZone());
assertEquals(timeZone, jobScheduleRequest.getJobParameters().get(0).getValue());
}
use of org.pentaho.platform.web.http.api.resources.JobScheduleRequest in project pentaho-platform by pentaho.
the class SolutionImportHandlerTest method testImportSchedules.
@Test
public void testImportSchedules() throws Exception {
List<JobScheduleRequest> schedules = new ArrayList<>();
JobScheduleRequest scheduleRequest = Mockito.spy(new JobScheduleRequest());
schedules.add(scheduleRequest);
SolutionImportHandler spyHandler = Mockito.spy(importHandler);
Response response = Mockito.mock(Response.class);
Mockito.when(response.getStatus()).thenReturn(Response.Status.OK.getStatusCode());
Mockito.when(response.getEntity()).thenReturn("job id");
Mockito.doReturn(response).when(spyHandler).createSchedulerJob(Mockito.any(SchedulerResource.class), Mockito.eq(scheduleRequest));
mockSchedulerPause();
spyHandler.importSchedules(schedules);
Mockito.verify(spyHandler).createSchedulerJob(Mockito.any(SchedulerResource.class), Mockito.eq(scheduleRequest));
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_FailsToCreateScheduleWithSpaceOnWindows.
@Test
public void testImportSchedules_FailsToCreateScheduleWithSpaceOnWindows() throws Exception {
String sep = File.separator;
System.setProperty("file.separator", "\\");
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());
System.setProperty("file.separator", sep);
}
Aggregations