use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testRemoveJobException.
@Test
public void testRemoveJobException() throws SchedulerException {
Job job = mock(Job.class);
doReturn(job).when(schedulerService).getJob(nullable(String.class));
doReturn(true).when(schedulerService).isScheduleAllowed();
doThrow(new SchedulerException("pause-exception")).when(schedulerService.scheduler).removeJob(nullable(String.class));
try {
schedulerService.removeJob("job-id");
} catch (SchedulerException e) {
assertEquals("pause-exception", e.getMessage());
}
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class QuartzSchedulerIT method getJobTest.
@Test
public void getJobTest() throws Exception {
final CronTrigger cronTrigger = mock(CronTrigger.class);
when(cronTrigger.getCronExpression()).thenReturn(CRON_EXPRESSION);
when(quartzScheduler.getTriggersOfJob(eq(JOB_ID), eq(USER_NAME))).thenReturn(new Trigger[] { cronTrigger });
setJobDataMap(USER_NAME);
final Job job = scheduler.getJob(JOB_ID);
assertEquals(JOB_ID, job.getJobId());
assertEquals(jobDetails, job.getJobParams());
assertEquals(USER_NAME, job.getUserName());
assertEquals(JOB_NAME, job.getJobName());
assertEquals(Job.JobState.NORMAL, job.getState());
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class QuartzSchedulerIT method createJobTest_ForUser.
@Test
public void createJobTest_ForUser() throws Exception {
String actionId = "actionId";
ComplexJobTrigger trigger = getComplexJobTrigger();
IBackgroundExecutionStreamProvider outputStreamProvider = mock(IBackgroundExecutionStreamProvider.class);
Map<String, Serializable> paramMap = new HashMap<>();
paramMap.put(QuartzScheduler.RESERVEDMAPKEY_ACTIONUSER, "ninja");
final Job job = scheduler.createJob(JOB_NAME, paramMap, trigger, outputStreamProvider);
assertNotNull(job);
assertEquals("ninja", job.getUserName());
assertEquals(Job.JobState.NORMAL, job.getState());
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class QuartzSchedulerIT method createJobTest.
@Test
public void createJobTest() throws Exception {
String actionId = "actionId";
ComplexJobTrigger trigger = getComplexJobTrigger();
IBackgroundExecutionStreamProvider outputStreamProvider = mock(IBackgroundExecutionStreamProvider.class);
final Job job = scheduler.createJob(JOB_NAME, actionId, null, trigger, outputStreamProvider);
assertNotNull(job);
assertEquals(Job.JobState.NORMAL, job.getState());
assertTrue(job.getJobParams().containsKey(QuartzScheduler.RESERVEDMAPKEY_ACTIONID));
assertEquals(actionId, job.getJobParams().get(QuartzScheduler.RESERVEDMAPKEY_ACTIONID));
assertTrue(job.getJobParams().containsKey(QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER));
assertEquals(outputStreamProvider, job.getJobParams().get(QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER));
assertTrue(job.getJobParams().containsKey(QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID));
assertNotNull(job.getJobParams().get(QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID));
assertTrue(job.getJobParams().containsKey(QuartzScheduler.RESERVEDMAPKEY_ACTIONUSER));
assertEquals(USER_NAME, job.getJobParams().get(QuartzScheduler.RESERVEDMAPKEY_ACTIONUSER));
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class QuartzSchedulerIT method testPauseAndResumeJob.
@Test
public void testPauseAndResumeJob() throws SchedulerException {
String jobName = "complexJob1";
int counter = TestAction.counter;
Calendar calendar = Calendar.getInstance();
int startingMin = calendar.get(Calendar.MINUTE);
int startingSec = calendar.get(Calendar.SECOND) + 1;
if (startingSec > 59) {
startingSec = startingSec % 60;
startingMin++;
if (startingMin > 59) {
startingMin = startingMin % 60;
}
}
ComplexJobTrigger complexJobTrigger = new ComplexJobTrigger();
complexJobTrigger.setHourlyRecurrence((ITimeRecurrence) null);
complexJobTrigger.setMinuteRecurrence(startingMin);
complexJobTrigger.setSecondRecurrence(startingSec);
Job job = scheduler.createJob(jobName, TestAction.class, jobParams, complexJobTrigger);
scheduler.pauseJob(job.getJobId());
sleep(2);
Assert.assertEquals(counter, TestAction.counter);
Assert.assertEquals(1, scheduler.getJobs(null).size());
scheduler.resumeJob(job.getJobId());
sleep(2);
Assert.assertTrue(counter != TestAction.counter);
scheduler.removeJob(job.getJobId());
Assert.assertEquals(0, scheduler.getJobs(null).size());
}
Aggregations