ToolAdminPresenterImpl implements ToolAdminView.Presenter,
                                               AddToolSelectedEvent.AddToolSelectedEventHandler,
                                               ToolSelectedEvent.ToolSelectedEventHandler,
                                               SaveToolSelectedEvent.SaveToolSelectedEventHandler,
                                               DeleteToolSelectedEvent.DeleteToolSelectedEventHandler { @Override public void onToolSelected(ToolSelectedEvent event) { toolAdminServiceFacade.getToolDetails(event.getTool().getId(), new AsyncCallback<Tool>() { @Override public void onFailure(Throwable caught) { ErrorHandler.post(caught); } @Override public void onSuccess(Tool result) { view.editToolDetails(result); } }); } @Inject  ToolAdminPresenterImpl(final ToolAdminViewFactory viewFactory,
                                  ToolAdminServiceFacade toolAdminServiceFacade,
                                  ToolAutoBeanFactory factory,
                                  ToolProperties toolProperties,
                                  ToolAdminView.ToolAdminViewAppearance appearance); @Override void go(HasOneWidget container); @Override void setViewDebugId(String baseId); @Override void onAddToolSelected(AddToolSelectedEvent event); @Override void onDeleteToolSelected(final DeleteToolSelectedEvent event); @Override void onToolSelected(ToolSelectedEvent event); @Override void onSaveToolSelected(SaveToolSelectedEvent event);  }
@Test public void onToolSelected() { Tool toolMock = mock(Tool.class); String idMock = "mockToolId"; ToolSelectedEvent eventMock = mock(ToolSelectedEvent.class); when(toolMock.getId()).thenReturn(idMock); when(eventMock.getTool()).thenReturn(toolMock); uut.onToolSelected(eventMock); verify(toolAdminServiceFacadeMock).getToolDetails(eq(idMock), Matchers.<AsyncCallback<Tool>>any()); verifyNoMoreInteractions(toolAdminServiceFacadeMock, viewMock); }
@Test public void onToolSelected_callbackSuccess() { Tool toolMock = mock(Tool.class); String idMock = "mockToolId"; ToolSelectedEvent eventMock = mock(ToolSelectedEvent.class); when(toolMock.getId()).thenReturn(idMock); when(eventMock.getTool()).thenReturn(toolMock); uut.onToolSelected(eventMock); verify(toolAdminServiceFacadeMock).getToolDetails(eq(idMock), asyncCallbackToolCaptor.capture()); AsyncCallback<Tool> value = asyncCallbackToolCaptor.getValue(); value.onSuccess(toolMock); verify(viewMock).editToolDetails(eq(toolMock)); verifyNoMoreInteractions(toolAdminServiceFacadeMock, viewMock); }