LocalPeerMessageSender implements Callable<Boolean> { @Override public Boolean call() throws Exception { for ( Envelope envelope : envelopes ) { messenger.notifyListeners( envelope ); messengerDataService.markAsSent( envelope ); } return true; } LocalPeerMessageSender( final MessengerImpl messenger, final MessengerDataService messengerDataService,
                                   final Set<Envelope> envelopes ); @Override Boolean call();  }
@Test public void testCall() throws Exception { boolean result = localPeerMessageSender.call(); assertTrue( result ); verify( messenger, times( 2 ) ).notifyListeners( isA( Envelope.class ) ); verify( messengerDataService, times( 2 ) ).markAsSent( isA( Envelope.class ) ); }