use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class DefaultSchedulerServiceTest method mockJob.
private Job mockJob(String userName, String jobName) {
Job job = mock(Job.class);
when(job.getUserName()).thenReturn(userName);
when(job.getJobName()).thenReturn(jobName);
return job;
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class QuartzSchedulerTest method testSetJobNextRunToTheFuture.
@Test
public void testSetJobNextRunToTheFuture() {
Trigger trigger = Mockito.mock(Trigger.class);
Job job = new Job();
QuartzScheduler quartzScheduler = new QuartzScheduler();
long nowDate = new Date().getTime();
long futureDate = nowDate + 1000000000;
Mockito.when(trigger.getNextFireTime()).thenReturn(new Date(futureDate));
Mockito.when(trigger.getFireTimeAfter(any())).thenReturn(new Date(nowDate));
quartzScheduler.setJobNextRun(job, trigger);
assertEquals(new Date(futureDate), job.getNextRun());
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class QuartzSchedulerTest method testSetJobNextRunToThePast.
@Test
public void testSetJobNextRunToThePast() {
Trigger trigger = Mockito.mock(Trigger.class);
Job job = new Job();
QuartzScheduler quartzScheduler = new QuartzScheduler();
long nowDate = new Date().getTime();
long pastDate = nowDate - 1000000000;
Mockito.when(trigger.getNextFireTime()).thenReturn(new Date(pastDate));
Mockito.when(trigger.getFireTimeAfter(any())).thenReturn(new Date(nowDate));
quartzScheduler.setJobNextRun(job, trigger);
assertEquals(new Date(nowDate), job.getNextRun());
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class JobAdapter method unmarshal.
public Job unmarshal(JaxbSafeJob jaxbSafeJob) throws Exception {
if (jaxbSafeJob == null) {
return null;
}
Job job = new Job();
try {
job.setJobTrigger(jaxbSafeJob.jobTrigger);
job.setJobParams(toProperMap(jaxbSafeJob.jobParams));
job.setLastRun(jaxbSafeJob.lastRun);
job.setNextRun(jaxbSafeJob.nextRun);
job.setSchedulableClass(jaxbSafeJob.schedulableClass);
job.setJobId(jaxbSafeJob.jobId);
job.setUserName(jaxbSafeJob.userName);
job.setJobName(jaxbSafeJob.jobName);
job.setState(jaxbSafeJob.state);
} catch (Throwable t) {
// no message bundle since this is a development error case
// $NON-NLS-1$
logger.error("Error unmarshalling job", t);
return null;
}
return job;
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class SolutionImportHandlerIT method testImportSchedules.
@Test
public void testImportSchedules() throws PlatformImportException, SchedulerException {
SolutionImportHandler importHandler = new SolutionImportHandler(Collections.emptyList());
importHandler = spy(importHandler);
List<JobScheduleRequest> requests = new ArrayList<>(4);
requests.add(createJobScheduleRequest("NORMAL", JobState.NORMAL));
requests.add(createJobScheduleRequest("PAUSED", JobState.PAUSED));
requests.add(createJobScheduleRequest("PAUSED", JobState.COMPLETE));
requests.add(createJobScheduleRequest("PAUSED", JobState.ERROR));
doReturn(new ArrayList<Job>()).when(importHandler).getAllJobs(any());
importHandler.importSchedules(requests);
List<Job> jobs = scheduler.getJobs(job -> true);
assertEquals(4, jobs.size());
for (Job job : jobs) {
assertEquals(job.getJobName(), job.getState().toString());
}
}
Aggregations