SchedulerService { public boolean isScheduleAllowed() { return getPolicy().isAllowed( SchedulerAction.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 testIsScheduleAllowed() { doReturn( true ).when( schedulerService ).isScheduleAllowed(); Map<String, Serializable> metadata = mock( Map.class ); doReturn( metadata ).when( schedulerService.repository ).getFileMetadata( anyString() ); doReturn( true ).when( metadata ).containsKey( RepositoryFile.SCHEDULABLE_KEY ); doReturn( "true" ).when( metadata ).get( RepositoryFile.SCHEDULABLE_KEY ); boolean canSchedule = schedulerService.isScheduleAllowed( anyString() ); assertTrue( canSchedule ); doReturn( false ).when( schedulerService ).isScheduleAllowed(); canSchedule = schedulerService.isScheduleAllowed( anyString() ); assertFalse( canSchedule ); doReturn( true ).when( schedulerService ).isScheduleAllowed(); doReturn( false ).when( metadata ).containsKey( RepositoryFile.SCHEDULABLE_KEY ); canSchedule = schedulerService.isScheduleAllowed( anyString() ); assertTrue( canSchedule ); doReturn( true ).when( metadata ).containsKey( RepositoryFile.SCHEDULABLE_KEY ); doReturn( "false" ).when( metadata ).get( RepositoryFile.SCHEDULABLE_KEY ); canSchedule = schedulerService.isScheduleAllowed( anyString() ); assertFalse( canSchedule ); verify( schedulerService, times( 4 ) ).isScheduleAllowed(); verify( schedulerService.repository, times( 3 ) ).getFileMetadata( anyString() ); verify( metadata, times( 3 ) ).containsKey( RepositoryFile.SCHEDULABLE_KEY ); verify( metadata, times( 2 ) ).get( RepositoryFile.SCHEDULABLE_KEY ); }