SchedulerService { public Job addBlockout( JobScheduleRequest jobScheduleRequest ) throws IOException, IllegalAccessException, SchedulerException { if ( canAdminister() ) { jobScheduleRequest.setActionClass( BlockoutAction.class.getCanonicalName() ); jobScheduleRequest.getJobParameters().add( getJobScheduleParam( IBlockoutManager.DURATION_PARAM, jobScheduleRequest.getDuration() ) ); jobScheduleRequest.getJobParameters() .add( getJobScheduleParam( IBlockoutManager.TIME_ZONE_PARAM, jobScheduleRequest.getTimeZone() ) ); return createJob( jobScheduleRequest ); } throw new IllegalAccessException(); }  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 testAddBlockout() throws Exception { JobScheduleRequest jobScheduleRequest = mock( JobScheduleRequest.class ); Job jobMock = mock( Job.class ); JobScheduleParam jobScheduleParamMock1 = mock( JobScheduleParam.class ); JobScheduleParam jobScheduleParamMock2 = mock( JobScheduleParam.class ); List<JobScheduleParam> jobScheduleParams = new ArrayList<>(); doReturn( true ).when( schedulerService ).canAdminister(); doNothing().when( jobScheduleRequest ).setActionClass( anyString() ); doReturn( jobScheduleParams ).when( jobScheduleRequest ).getJobParameters(); doReturn( jobScheduleParamMock1 ).when( schedulerService ).getJobScheduleParam( anyString(), anyString() ); doReturn( jobScheduleParamMock2 ).when( schedulerService ).getJobScheduleParam( anyString(), anyLong() ); doNothing().when( schedulerService ).updateStartDateForTimeZone( jobScheduleRequest ); doReturn( jobMock ).when( schedulerService ).createJob( any( JobScheduleRequest.class ) ); Job job = schedulerService.addBlockout( jobScheduleRequest ); assertNotNull( job ); assertEquals( 2, jobScheduleParams.size() ); verify( schedulerService ).canAdminister(); verify( jobScheduleRequest ).setActionClass( anyString() ); verify( jobScheduleRequest, times( 2 ) ).getJobParameters(); verify( schedulerService ).createJob( any( JobScheduleRequest.class ) ); }