use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class RepositoryCleanerSystemListenerTest method removesJobs_WhenDisabled.
@Test
public void removesJobs_WhenDisabled() throws Exception {
final String jobId = "jobId";
Job job = new Job();
job.setJobId(jobId);
when(scheduler.getJobs(any(IJobFilter.class))).thenReturn(Collections.singletonList(job));
prepareMp();
listener.setGcEnabled(false);
assertTrue(listener.startup(null));
verifyJobRemoved(jobId);
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class RepositoryCleanerSystemListenerTest method reschedulesJob_IfFoundDifferent.
@Test
public void reschedulesJob_IfFoundDifferent() throws Exception {
final String oldJobId = "oldJobId";
Job oldJob = new Job();
oldJob.setJobTrigger(new CronJobTrigger());
oldJob.setJobId(oldJobId);
when(scheduler.getJobs(any(IJobFilter.class))).thenReturn(Collections.singletonList(oldJob));
prepareMp();
listener.setExecute(Frequency.NOW.getValue());
assertTrue(listener.startup(null));
verifyJobRemoved(oldJobId);
verifyJobCreated(Frequency.NOW);
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testResumeJob.
@Test
public void testResumeJob() throws SchedulerException {
Job job = mock(Job.class);
doReturn(job).when(schedulerService).getJob(nullable(String.class));
doReturn(true).when(schedulerService).isScheduleAllowed();
doNothing().when(schedulerService.scheduler).resumeJob(nullable(String.class));
schedulerService.resumeJob("job-id");
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testGetJobInfo.
@Test
public void testGetJobInfo() throws Exception {
String jobId = "jobId";
Job mockJob = mock(Job.class);
doReturn(mockJob).when(schedulerService).getJob(jobId);
IPentahoSession mockPentahoSession = mock(IPentahoSession.class);
doReturn(mockPentahoSession).when(schedulerService).getSession();
String sessionName = "sessionName";
doReturn(sessionName).when(mockPentahoSession).getName();
doReturn(sessionName).when(mockJob).getUserName();
Map<String, Serializable> mockJobParams = mock(Map.class);
doReturn(mockJobParams).when(mockJob).getJobParams();
Set<String> jobParamsKeyset = new HashSet<>();
doReturn(jobParamsKeyset).when(mockJobParams).keySet();
String jobParamKey = "key";
jobParamsKeyset.add(jobParamKey);
String value = "value";
String[] testArray = new String[] { value };
doReturn(testArray).when(mockJobParams).get(jobParamKey);
// Test 1
Job testJob = schedulerService.getJobInfo(jobId);
assertEquals(mockJob, testJob);
// Test 2
testJob = schedulerService.getJobInfo(jobId);
assertEquals(mockJob, testJob);
verify(mockJobParams, times(2)).put(eq(jobParamKey), any(Serializable.class));
verify(schedulerService, times(2)).getJob(jobId);
verify(schedulerService, times(2)).getSession();
verify(mockPentahoSession, times(2)).getName();
verify(mockJob, times(2)).getUserName();
verify(mockJob, times(6)).getJobParams();
verify(mockJobParams, times(2)).keySet();
verify(mockJobParams, times(2)).get(jobParamKey);
verify(schedulerService, times(2)).canAdminister(null);
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testPauseJobException.
@Test
public void testPauseJobException() 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).pauseJob(nullable(String.class));
try {
schedulerService.pauseJob("job-id");
} catch (SchedulerException e) {
assertEquals("pause-exception", e.getMessage());
}
}
Aggregations