@Test @SuppressWarnings( "unchecked" ) public void testApplicationDeleted_exceptionWhileListingJobs() throws Exception { RoboconfScheduler roboconfScheduler = Mockito.mock( RoboconfScheduler.class ); roboconfScheduler.scheduler = Mockito.mock( Scheduler.class ); Mockito .when( roboconfScheduler.scheduler.getTriggerKeys( Mockito.any( GroupMatcher.class ))) .thenThrow( new SchedulerException( "For test" )); ManagerListener listener = new ManagerListener( roboconfScheduler ); listener.application( new Application( "app", Mockito.mock( ApplicationTemplate.class )), EventType.DELETED ); Mockito .verify( roboconfScheduler.scheduler, Mockito.times( 1 )) .getTriggerKeys( Mockito.any( GroupMatcher.class )); }
@Override public void application( Application application, EventType eventType ) { if( eventType == EventType.DELETED ) { this.logger.fine( "Application " + application + " was deleted. Associated jobs are about to be deleted." ); try { Set<TriggerKey> tks = this.scheduler.scheduler.getTriggerKeys( GroupMatcher.triggerGroupEquals( application.getName())); for( TriggerKey tk : tks ) { try { this.scheduler.deleteJob( tk.getName()); } catch( Exception e ) { this.logger.warning( "An error occurred while unscheduling job " + tk.getName() + ". " + e.getMessage()); Utils.logException( this.logger, e ); } } } catch( Exception e ) { this.logger.warning( "An error occurred while listing jobs for application " + application + ". " + e.getMessage()); Utils.logException( this.logger, e ); } } }
ManagerListener implements IDmListener { @Override public void application( Application application, EventType eventType ) { if( eventType == EventType.DELETED ) { this.logger.fine( "Application " + application + " was deleted. Associated jobs are about to be deleted." ); try { Set<TriggerKey> tks = this.scheduler.scheduler.getTriggerKeys( GroupMatcher.triggerGroupEquals( application.getName())); for( TriggerKey tk : tks ) { try { this.scheduler.deleteJob( tk.getName()); } catch( Exception e ) { this.logger.warning( "An error occurred while unscheduling job " + tk.getName() + ". " + e.getMessage()); Utils.logException( this.logger, e ); } } } catch( Exception e ) { this.logger.warning( "An error occurred while listing jobs for application " + application + ". " + e.getMessage()); Utils.logException( this.logger, e ); } } } }
ManagerListener implements IDmListener { @Override public void application( Application application, EventType eventType ) { if( eventType == EventType.DELETED ) { this.logger.fine( "Application " + application + " was deleted. Associated jobs are about to be deleted." ); try { Set<TriggerKey> tks = this.scheduler.scheduler.getTriggerKeys( GroupMatcher.triggerGroupEquals( application.getName())); for( TriggerKey tk : tks ) { try { this.scheduler.deleteJob( tk.getName()); } catch( Exception e ) { this.logger.warning( "An error occurred while unscheduling job " + tk.getName() + ". " + e.getMessage()); Utils.logException( this.logger, e ); } } } catch( Exception e ) { this.logger.warning( "An error occurred while listing jobs for application " + application + ". " + e.getMessage()); Utils.logException( this.logger, e ); } } } ManagerListener( RoboconfScheduler scheduler ); }
ManagerListener implements IDmListener { @Override public void application( Application application, EventType eventType ) { if( eventType == EventType.DELETED ) { this.logger.fine( "Application " + application + " was deleted. Associated jobs are about to be deleted." ); try { Set<TriggerKey> tks = this.scheduler.scheduler.getTriggerKeys( GroupMatcher.triggerGroupEquals( application.getName())); for( TriggerKey tk : tks ) { try { this.scheduler.deleteJob( tk.getName()); } catch( Exception e ) { this.logger.warning( "An error occurred while unscheduling job " + tk.getName() + ". " + e.getMessage()); Utils.logException( this.logger, e ); } } } catch( Exception e ) { this.logger.warning( "An error occurred while listing jobs for application " + application + ". " + e.getMessage()); Utils.logException( this.logger, e ); } } } ManagerListener( RoboconfScheduler scheduler ); @Override String getId(); @Override void enableNotifications(); @Override void disableNotifications(); @Override void applicationTemplate( ApplicationTemplate tpl, EventType eventType ); @Override void instance( Instance instance, Application application, EventType eventType ); @Override void raw( String message, Object... data ); @Override void application( Application application, EventType eventType ); }
ManagerListener implements IDmListener { @Override public void application( Application application, EventType eventType ) { if( eventType == EventType.DELETED ) { this.logger.fine( "Application " + application + " was deleted. Associated jobs are about to be deleted." ); try { Set<TriggerKey> tks = this.scheduler.scheduler.getTriggerKeys( GroupMatcher.triggerGroupEquals( application.getName())); for( TriggerKey tk : tks ) { try { this.scheduler.deleteJob( tk.getName()); } catch( Exception e ) { this.logger.warning( "An error occurred while unscheduling job " + tk.getName() + ". " + e.getMessage()); Utils.logException( this.logger, e ); } } } catch( Exception e ) { this.logger.warning( "An error occurred while listing jobs for application " + application + ". " + e.getMessage()); Utils.logException( this.logger, e ); } } } ManagerListener( RoboconfScheduler scheduler ); @Override String getId(); @Override void enableNotifications(); @Override void disableNotifications(); @Override void applicationTemplate( ApplicationTemplate tpl, EventType eventType ); @Override void instance( Instance instance, Application application, EventType eventType ); @Override void raw( String message, Object... data ); @Override void application( Application application, EventType eventType );  }