GatherStatsListener implements IPentahoSystemListener { @Override public boolean startup( IPentahoSession arg0 ) { try { scheduleJob( intervalInSeconds ); } catch ( Exception e ) { logger.error( "Exception when scheduling stats job", e ); } return true; }  @Override void shutdown(); @Override boolean startup( IPentahoSession arg0 ); int getIntervalInSeconds(); String getTransFileName(); void setTransFileName( String transfileName ); void setIntervalInSeconds( int intervalInSeconds );  }
@Test public void testStartUp() throws Exception { PentahoSystem.registerObject( scheduler ); Job job = mock( Job.class ); when( scheduler.createJob( eq( "Gather Stats" ), eq( GatherStatsAction.class ), eq( gatherStatsListener.jobMap ), any( JobTrigger.class ) ) ).thenReturn( job ); boolean startup = gatherStatsListener.startup( session ); assertTrue( startup ); assertEquals( 1, gatherStatsListener.jobMap.size() ); assertEquals( gatherStatsListener.getTransFileName(), gatherStatsListener.jobMap.get( "transFileName" ) ); assertEquals( 101, gatherStatsListener.getIntervalInSeconds() ); verify( scheduler ).createJob( eq( "Gather Stats" ), eq( GatherStatsAction.class ), eq( gatherStatsListener.jobMap ), any( JobTrigger.class ) ); }