use of org.pentaho.platform.api.scheduler2.IJobFilter in project pentaho-platform by pentaho.
the class DefaultSchedulerServiceTest method testGetJobsAdminUser.
@Test
public void testGetJobsAdminUser() throws Exception {
when(policy.isAllowed(anyString())).thenReturn(true);
when(iPentahoSessionMock.getName()).thenReturn("admin");
defaultSchedulerService.getJobs();
verify(iSchedulerMock).getJobs((IJobFilter) filterCaptor.capture());
IJobFilter filter = (IJobFilter) filterCaptor.getValue();
assertNotNull(filter);
List<Job> testJobs = getJobs();
List<Job> filteredJobs = new ArrayList<>();
for (Job job : testJobs) {
if (filter.accept(job)) {
filteredJobs.add(job);
assertNotEquals("BlockoutAction", job.getJobName());
}
}
assertEquals(10, filteredJobs.size());
}
use of org.pentaho.platform.api.scheduler2.IJobFilter in project pentaho-platform by pentaho.
the class DefaultSchedulerServiceTest method testGetJobsNonAdminUser.
@Test
public void testGetJobsNonAdminUser() throws Exception {
when(policy.isAllowed(anyString())).thenReturn(false);
when(iPentahoSessionMock.getName()).thenReturn("testUser1");
defaultSchedulerService.getJobs();
verify(iSchedulerMock).getJobs((IJobFilter) filterCaptor.capture());
IJobFilter filter = (IJobFilter) filterCaptor.getValue();
assertNotNull(filter);
List<Job> testJobs = getJobs();
List<Job> filteredJobs = new ArrayList<>();
for (Job job : testJobs) {
if (filter.accept(job)) {
filteredJobs.add(job);
}
}
assertEquals(1, filteredJobs.size());
assertEquals("testJobName1", filteredJobs.get(0).getJobName());
assertEquals("testUser1", filteredJobs.get(0).getUserName());
}
Aggregations