MessageNotifier implements Runnable { @Override public void run() { try { listener.onMessage( message ); } catch ( Exception e ) { LOG.error( String.format( "Error notifying %s on %s", listener.getRecipient(), message ), e ); } } MessageNotifier( final MessageListener listener, final Message message ); @Override void run();  }
@Test public void testRun() throws Exception { messageNotifier.run(); verify( listener ).onMessage( message ); }
@Test public void testRunWithException() throws Exception { Exception exception = mock( RuntimeException.class ); doThrow( exception ).when( listener ).onMessage( message ); messageNotifier.run(); verify( exception ).printStackTrace( any( PrintStream.class ) ); }