title: mocking GWT EventBus with mockito
body: <p>I have some problems spying on a real SimpleEventBus implementation of EventBus:
  I have an activity which is also a handler for a specific event. This event is fired by a service.</p>
  
  <p>The code:</p>
  
  <pre><code>    @Mock private AssetCellList view;
      @Mock private AcceptsOneWidget panel;
      @Mock private SelectionModel&lt;Asset&gt; selectionModel;
      @Mock private HasData&lt;Asset&gt; cellList;
      @Mock private AssetService service;
      @Mock private Asset asset;
      @Mock private List&lt;Asset&gt; list;
      @Mock private AssetListDTOClientImpl assetDTO;
      @Mock private AssetEvent event;
  
  
      @Before
      public void setUp() throws Exception {
          MockitoAnnotations.initMocks(this);
      }
  
      @Test 
      public void test(){
  
  
          /*Some stubbing*/
          when(view.getSelectionModel()).thenReturn(selectionModel);
          when(view.getList()).thenReturn(cellList);
          when(assetDTO.getAssetList()).thenReturn(list);
          when(assetDTO.getAssetList().get(anyInt())).thenReturn(asset);
          when(event.getAssetDTO()).thenReturn(assetDTO);
  
  
          /*Creatin the Real EventBus*/
          EventBus eventBus = new SimpleEventBus();
  
          /*Creating the activity */
          AssetListActivity activity = new AssetListActivity(eventBus, 
                  view,
                  service);
  
          /*Spying the eventBus*/
          EventBus eventBusSpy = spy(eventBus);
          /*Spying the activity*/
          AssetListActivity activitySpy = spy(activity);
  
  
          /*Starting the activity*/
          activity.start(panel);
  
          /*verifying the service call -&gt; OK */
          verify(service, times(1)).getAssets(anyInt());
  
          /*Simulating the service which eventually fires an event*/
          eventBus.fireEvent(event);
  
          /*verifying that the eventBus really fires the event --&gt; NO OK*/
          verify(eventBusSpy, times(1)).addHandler( eq( AssetEvent.TYPE ),                      isA(AssetEventHandler.class));
  
          /*later verifiction*/
          verify(activitySpy).onAssetsReceived(event);
  
      }
  </code></pre>
  
  <p>The error trace is in th eventBusSpy verification and says:</p>
  
  <pre><code>Wanted but not invoked:
  simpleEventBus.addHandler(
      Event type,
      isA(cat.ccma.testproject.client.events.AssetEventHandler)
  );
  -&gt; at cat.ccma.testproject.client.AssetListTest.test(AssetListTest.java:87)
  Actually, there were zero interactions with this mock.
  </code></pre>
  
  <p>Thank You.</p>