SchedulerService { public String shutdown() throws SchedulerException { if ( getPolicy().isAllowed( SchedulerAction.NAME ) ) { getScheduler().shutdown(); } return getScheduler().getStatus().name(); }  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 testShutdown() throws SchedulerException { doReturn( true ).when( schedulerService.policy ).isAllowed( SchedulerAction.NAME ); doNothing().when( schedulerService.scheduler ).shutdown(); doReturn( IScheduler.SchedulerStatus.STOPPED ).when( schedulerService.scheduler ).getStatus(); String state = schedulerService.shutdown(); assertEquals( "STOPPED", state ); doReturn( IScheduler.SchedulerStatus.RUNNING ).when( schedulerService.scheduler ).getStatus(); doReturn( false ).when( schedulerService.policy ).isAllowed( SchedulerAction.NAME ); state = schedulerService.shutdown(); assertEquals( "RUNNING", state ); verify( schedulerService.policy, times( 2 ) ).isAllowed( SchedulerAction.NAME ); verify( schedulerService.scheduler, times( 1 ) ).shutdown(); verify( schedulerService.scheduler, times( 2 ) ).getStatus(); }
@Test public void testShutdownException() throws SchedulerException { doReturn( true ).when( schedulerService.policy ).isAllowed( SchedulerAction.NAME ); doThrow( new SchedulerException( "" ) ).when( schedulerService.scheduler ).shutdown(); try { schedulerService.shutdown(); fail(); } catch ( SchedulerException e ) { } verify( schedulerService.policy ).isAllowed( SchedulerAction.NAME ); verify( schedulerService.scheduler ).shutdown(); }