SchedulerService { public Job getJobInfo( String jobId ) throws SchedulerException { Job job = getJob( jobId ); if ( job == null ) { return null; } if ( canAdminister() || getSession().getName().equals( job.getUserName() ) ) { for ( String key : job.getJobParams().keySet() ) { Serializable value = job.getJobParams().get( key ); if ( value != null && value.getClass() != null && value.getClass().isArray() ) { String[] sa = ( new String[ 0 ] ).getClass().cast( value ); ArrayList<String> list = new ArrayList<>(); for ( int i = 0; i < sa.length; i++ ) { list.add( sa[ i ] ); } job.getJobParams().put( key, list ); } } return job; } else { throw new RuntimeException( "Job not found or improper credentials for access" ); } }  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 testGetJobInfo() throws Exception { String jobId = "jobId"; Job mockJob = mock( Job.class ); doReturn( mockJob ).when( schedulerService ).getJob( jobId ); ISecurityHelper mockSecurityHelper = mock( ISecurityHelper.class ); doReturn( mockSecurityHelper ).when( schedulerService ).getSecurityHelper(); 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 ); doReturn( true ).when( schedulerService ).canAdminister( mockPentahoSession ); Job testJob = schedulerService.getJobInfo( jobId ); assertEquals( mockJob, testJob ); doReturn( false ).when( schedulerService ).canAdminister( mockPentahoSession ); 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 ); }