RepositoryCleanerSystemListener implements IPentahoSystemListener, IJobFilter { @Override public boolean startup( IPentahoSession session ) { IScheduler scheduler = PentahoSystem.get( IScheduler.class, "IScheduler2", session ); if ( scheduler == null ) { logger.error( "Cannot obtain an instance of IScheduler2" ); return false; } try { List<Job> jobs = scheduler.getJobs( this ); if ( gcEnabled ) { if ( jobs.isEmpty() ) { scheduleJob( scheduler ); } else { rescheduleIfNecessary( scheduler, jobs ); } } else { if ( !jobs.isEmpty() ) { unscheduleJob( scheduler, jobs ); } } } catch ( SchedulerException e ) { logger.error( "Scheduler error", e ); } return true; }  @Override boolean startup( IPentahoSession session ); @Override void shutdown(); @Override boolean accept( Job job ); boolean isGcEnabled(); void setGcEnabled( boolean gcEnabled ); String getExecute(); void setExecute( String execute );  }
@Test public void stops_IfSchedulerIsNotDefined() { assertFalse( listener.startup( null ) ); }
@Test public void returnsTrue_EvenGetsExceptions() throws Exception { when( scheduler.getJobs( any( IJobFilter.class ) ) ).thenThrow( new SchedulerException( "test exception" ) ); prepareMp(); assertTrue( "The listener should not return false to let the system continue working", listener.startup( null ) ); }