SchedulerService { public JobState getJobState( JobRequest jobRequest ) throws SchedulerException { Job job = getJob( jobRequest.getJobId() ); if ( isScheduleAllowed() || getSession().getName().equals( job.getUserName() ) ) { return job.getState(); } throw new UnsupportedOperationException(); }  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 testGetJobState() throws Exception { JobRequest mockJobRequest = mock( JobRequest.class ); String jobId = "jobId"; doReturn( jobId ).when( mockJobRequest ).getJobId(); IPentahoSession mockSession = mock( IPentahoSession.class ); doReturn( mockSession ).when( schedulerService ).getSession(); Job mockJob = mock( Job.class ); doReturn( mockJob ).when( schedulerService ).getJob( jobId ); doReturn( Job.JobState.BLOCKED ).when( mockJob ).getState(); String username = "username"; doReturn( username ).when( mockJob ).getUserName(); doReturn( username ).when( mockSession ).getName(); doReturn( true ).when( schedulerService ).isScheduleAllowed(); Job.JobState testState = schedulerService.getJobState( mockJobRequest ); assertEquals( Job.JobState.BLOCKED, testState ); doReturn( false ).when( schedulerService ).isScheduleAllowed(); testState = schedulerService.getJobState( mockJobRequest ); assertEquals( Job.JobState.BLOCKED, testState ); verify( mockJobRequest, times( 2 ) ).getJobId(); verify( schedulerService, times( 1 ) ).getSession(); verify( schedulerService, times( 2 ) ).getJob( jobId ); verify( mockJob, times( 2 ) ).getState(); verify( mockJob, times( 1 ) ).getUserName(); verify( mockSession, times( 1 ) ).getName(); }