SchedulerService { public Job getContentCleanerJob() throws SchedulerException { IPentahoSession session = getSession(); final String principalName = session.getName(); final Boolean canAdminister = getPolicy().isAllowed( AdministerSecurityAction.NAME ); List<Job> jobs = getScheduler().getJobs( getJobFilter( canAdminister, principalName ) ); if ( jobs.size() > 0 ) { return jobs.get( 0 ); } return null; }  Job createJob( JobScheduleRequest scheduleRequest ); Job updateJob( JobScheduleRequest scheduleRequest ); Job triggerNow( String jobId ); Job getContentCleanerJob(); List<RepositoryFileDto> doGetGeneratedContentForSchedule( String lineageId ); Job getJob( String jobId ); boolean isScheduleAllowed(); boolean isScheduleAllowed( String id ); IJobFilter getJobFilter( boolean canAdminister, String principalName ); String doGetCanSchedule(); String getState(); String start(); String pause(); String shutdown(); JobState pauseJob( String jobId ); JobState resumeJob( String jobId ); boolean removeJob( String jobId ); Job getJobInfo( String jobId ); List<Job> getBlockOutJobs(); boolean hasBlockouts(); boolean willFire( IJobTrigger trigger ); boolean shouldFireNow(); Job addBlockout( JobScheduleRequest jobScheduleRequest ); Job updateBlockout( String jobId, JobScheduleRequest jobScheduleRequest ); BlockStatusProxy getBlockStatus( JobScheduleRequest jobScheduleRequest ); JobScheduleRequest getJobInfo(); JobState getJobState( JobRequest jobRequest ); Class<IAction> getAction( String actionClass ); IUnifiedRepository getRepository(); IScheduler getScheduler(); IAuthorizationPolicy getPolicy(); boolean getAutoCreateUniqueFilename( final JobScheduleRequest scheduleRequest ); String getAppendDateFormat( final JobScheduleRequest scheduleRequest ); List<Job> getJobs();  }
@Test public void testGetContentCleanerJob() throws Exception { IJobFilter jobFilter = mock( IJobFilter.class ); List<Job> jobs = new ArrayList<>(); IPentahoSession session = mock( IPentahoSession.class ); doReturn( session ).when( schedulerService ).getSession(); doReturn( "sessionName" ).when( session ).getName(); doReturn( true ).when( schedulerService.policy ).isAllowed( AdministerSecurityAction.NAME ); doReturn( jobFilter ).when( schedulerService ).getJobFilter( anyBoolean(), anyString() ); doReturn( jobs ).when( schedulerService.scheduler ).getJobs( any( IJobFilter.class ) ); Job job = schedulerService.getContentCleanerJob(); assertNull( job ); Job job1 = mock( Job.class ); jobs.add( job1 ); job = schedulerService.getContentCleanerJob(); assertNotNull( job ); verify( schedulerService, times( 2 ) ).getSession(); verify( session, times( 2 ) ).getName(); verify( schedulerService.policy, times( 2 ) ).isAllowed( AdministerSecurityAction.NAME ); verify( schedulerService.scheduler, times( 2 ) ).getJobs( any( IJobFilter.class ) ); }