SchedulerService { public Job triggerNow( String jobId ) throws SchedulerException { Job job = getScheduler().getJob( jobId ); if ( getPolicy().isAllowed( SchedulerAction.NAME ) ) { getScheduler().triggerNow( jobId ); } else { if ( getSession().getName().equals( job.getUserName() ) ) { getScheduler().triggerNow( jobId ); } } job = getScheduler().getJob( jobId ); return job; }  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 testTriggerNow() throws Exception { JobRequest jobRequest = mock( JobRequest.class ); Job job = mock( Job.class ); doReturn( job ).when( schedulerService.scheduler ).getJob( anyString() ); doReturn( true ).when( schedulerService.policy ).isAllowed( anyString() ); doNothing().when( schedulerService.scheduler ).triggerNow( anyString() ); Job resultJob1 = schedulerService.triggerNow( jobRequest.getJobId() ); assertEquals( job, resultJob1 ); doReturn( "test" ).when( job ).getUserName(); doReturn( false ).when( schedulerService.policy ).isAllowed( anyString() ); IPentahoSession pentahoSession = mock( IPentahoSession.class ); doReturn( "test" ).when( pentahoSession ).getName(); doReturn( pentahoSession ).when( schedulerService ).getSession(); Job resultJob2 = schedulerService.triggerNow( jobRequest.getJobId() ); assertEquals( job, resultJob2 ); verify( schedulerService.scheduler, times( 4 ) ).getJob( anyString() ); verify( schedulerService.scheduler, times( 2 ) ).triggerNow( anyString() ); verify( schedulerService.policy, times( 2 ) ).isAllowed( anyString() ); }