@Test( expected = MessageEventFireEventException.class ) public void testOperationFireEventThrowException() throws KettleException { addHandlers( operationMessageEvent, messageEventHandler, messageEventHandler2 ); doThrow( new RuntimeException( "Test" ) ).when( messageEventHandler ).execute( any( Message.class ) ); LogEvent logEvent = new LogEvent<>( new RemoteSource( ModelType.OPERATION, "Operation_ID" ), logEntry ); messageEventService.fireEvent( logEvent ); verify( messageEventHandler, never() ).execute( logEvent ); verify( messageEventHandler2 ).execute( logEvent ); }
public void fireEvent( final Message event ) throws MessageEventFireEventException { if ( event != null ) { if ( containsHandlerFor( event ) ) { final Collection<MessageEventHandler> handlers = getHandlersFor( event ); if ( handlers != null && handlers.size() > 0 ) { MessageEventFireEventException messageEventFireEventException = null; for ( final MessageEventHandler handler : handlers ) { try { handler.execute( event ); } catch ( final Exception e ) { if ( messageEventFireEventException == null ) { messageEventFireEventException = new MessageEventFireEventException( "Unable to execute some handler." ); } messageEventFireEventException.addHandlerException( e ); } } if ( messageEventFireEventException != null ) { throw messageEventFireEventException; } } } } else { throw new MessageEventFireEventException( "Unable to fire a null event" ); } }
MessageEventService { public void fireEvent( final Message event ) throws MessageEventFireEventException { if ( event != null ) { if ( containsHandlerFor( event ) ) { final Collection<MessageEventHandler> handlers = getHandlersFor( event ); if ( handlers != null && handlers.size() > 0 ) { MessageEventFireEventException messageEventFireEventException = null; for ( final MessageEventHandler handler : handlers ) { try { handler.execute( event ); } catch ( final Exception e ) { if ( messageEventFireEventException == null ) { messageEventFireEventException = new MessageEventFireEventException( "Unable to execute some handler." ); } messageEventFireEventException.addHandlerException( e ); } } if ( messageEventFireEventException != null ) { throw messageEventFireEventException; } } } } else { throw new MessageEventFireEventException( "Unable to fire a null event" ); } } }
MessageEventService { public void fireEvent( final Message event ) throws MessageEventFireEventException { if ( event != null ) { if ( containsHandlerFor( event ) ) { final Collection<MessageEventHandler> handlers = getHandlersFor( event ); if ( handlers != null && handlers.size() > 0 ) { MessageEventFireEventException messageEventFireEventException = null; for ( final MessageEventHandler handler : handlers ) { try { handler.execute( event ); } catch ( final Exception e ) { if ( messageEventFireEventException == null ) { messageEventFireEventException = new MessageEventFireEventException( "Unable to execute some handler." ); } messageEventFireEventException.addHandlerException( e ); } } if ( messageEventFireEventException != null ) { throw messageEventFireEventException; } } } } else { throw new MessageEventFireEventException( "Unable to fire a null event" ); } } MessageEventService(); }
MessageEventService { public void fireEvent( final Message event ) throws MessageEventFireEventException { if ( event != null ) { if ( containsHandlerFor( event ) ) { final Collection<MessageEventHandler> handlers = getHandlersFor( event ); if ( handlers != null && handlers.size() > 0 ) { MessageEventFireEventException messageEventFireEventException = null; for ( final MessageEventHandler handler : handlers ) { try { handler.execute( event ); } catch ( final Exception e ) { if ( messageEventFireEventException == null ) { messageEventFireEventException = new MessageEventFireEventException( "Unable to execute some handler." ); } messageEventFireEventException.addHandlerException( e ); } } if ( messageEventFireEventException != null ) { throw messageEventFireEventException; } } } } else { throw new MessageEventFireEventException( "Unable to fire a null event" ); } } MessageEventService(); void fireEvent( final Message event ); final void addHandler( final Message eventType, final MessageEventHandler handler ); final boolean hasHandlers( final Message eventType ); List<MessageEventHandler> getHandlersFor( final Message eventType ); }
MessageEventService { public void fireEvent( final Message event ) throws MessageEventFireEventException { if ( event != null ) { if ( containsHandlerFor( event ) ) { final Collection<MessageEventHandler> handlers = getHandlersFor( event ); if ( handlers != null && handlers.size() > 0 ) { MessageEventFireEventException messageEventFireEventException = null; for ( final MessageEventHandler handler : handlers ) { try { handler.execute( event ); } catch ( final Exception e ) { if ( messageEventFireEventException == null ) { messageEventFireEventException = new MessageEventFireEventException( "Unable to execute some handler." ); } messageEventFireEventException.addHandlerException( e ); } } if ( messageEventFireEventException != null ) { throw messageEventFireEventException; } } } } else { throw new MessageEventFireEventException( "Unable to fire a null event" ); } } MessageEventService(); void fireEvent( final Message event ); final void addHandler( final Message eventType, final MessageEventHandler handler ); final boolean hasHandlers( final Message eventType ); List<MessageEventHandler> getHandlersFor( final Message eventType );  }