ToolAdminViewImpl extends Composite implements ToolAdminView { @UiHandler("addButton") void addButtonClicked(SelectEvent event) { toolDetailsDialog.get(new AsyncCallback<ToolAdminDetailsDialog>() { @Override public void onFailure(Throwable caught) { ErrorHandler.post(caught); } @Override public void onSuccess(final ToolAdminDetailsDialog result) { result.show(); result.ensureDebugId(Belphegor.ToolAdminIds.TOOL_ADMIN_DIALOG); result.addSaveToolSelectedEventHandler(new SaveToolSelectedEvent.SaveToolSelectedEventHandler() { @Override public void onSaveToolSelected(SaveToolSelectedEvent event) { AddToolSelectedEvent addToolSelectedEvent = new AddToolSelectedEvent(event.getTool()); fireEvent(addToolSelectedEvent); result.hide(); } }); } }); } @Inject  ToolAdminViewImpl(final ToolAdminViewAppearance appearance,
                             ToolProperties toolProps,
                             @Assisted ListStore<Tool> listStore); @Override HandlerRegistration addAddToolSelectedEventHandler(AddToolSelectedEvent.AddToolSelectedEventHandler handler); @Override HandlerRegistration addDeleteToolSelectedEventHandler(DeleteToolSelectedEvent.DeleteToolSelectedEventHandler handler); @Override HandlerRegistration addSaveToolSelectedEventHandler(SaveToolSelectedEvent.SaveToolSelectedEventHandler handler); @Override HandlerRegistration addToolSelectedEventHandler(ToolSelectedEvent.ToolSelectedEventHandler handler); @Override void editToolDetails(final Tool tool); void toolSelected(Tool tool);  }
@Test public void testAddButtonClicked() { ToolAdminViewImpl spy = spy(uut); SelectEvent mockEvent = mock(SelectEvent.class); spy.addButtonClicked(mockEvent); verify(toolDetailsDialogMock).get(asyncCallbackDialogCaptor.capture()); AsyncCallback<ToolAdminDetailsDialog> asyncCallback = asyncCallbackDialogCaptor.getValue(); ToolAdminDetailsDialog resultMock = mock(ToolAdminDetailsDialog.class); asyncCallback.onSuccess(resultMock); verify(resultMock).show(); verify(resultMock).addSaveToolSelectedEventHandler(saveToolSelectedEventHandlerArgumentCaptor.capture()); SaveToolSelectedEvent.SaveToolSelectedEventHandler saveHandlerMock = saveToolSelectedEventHandlerArgumentCaptor.getValue(); SaveToolSelectedEvent saveEventMock = mock(SaveToolSelectedEvent.class); saveHandlerMock.onSaveToolSelected(saveEventMock); verify(spy).fireEvent(isA(AddToolSelectedEvent.class)); verify(resultMock).hide(); }