HistoryPresenter extends BasePresenter implements HistoryView.ActionDelegate { public void showDialog() { ProjectDescriptor project = appContext.getCurrentProject().getRootProject(); getCommitsLog(project); selectedRevision = null; view.selectProjectChangesButton(true); view.selectResourceChangesButton(false); showChangesInProject = true; view.selectDiffWithPrevVersionButton(true); diffType = DiffWith.DIFF_WITH_PREV_VERSION; displayCommitA(null); displayCommitB(null); view.setDiffContext(""); view.setCompareType(constant.historyNothingToDisplay()); if (isViewClosed) { workspaceAgent.openPart(this, PartStackType.TOOLING); isViewClosed = false; } PartPresenter activePart = partStack.getActivePart(); if (activePart == null || !activePart.equals(this)) { partStack.setActivePart(this); } } @Inject  HistoryPresenter(final HistoryView view,
                            EventBus eventBus,
                            GitResources resources,
                            GitServiceClient service,
                            final WorkspaceAgent workspaceAgent,
                            GitLocalizationConstant constant,
                            GitOutputPartPresenter console,
                            AppContext appContext,
                            NotificationManager notificationManager,
                            DtoUnmarshallerFactory dtoUnmarshallerFactory,
                            DateTimeFormatter dateTimeFormatter,
                            SelectionAgent selectionAgent); void showDialog(); @Override void onRefreshClicked(); @Override void onProjectChangesClicked(); @Override void onResourceChangesClicked(); @Override void onDiffWithIndexClicked(); @Override void onDiffWithWorkTreeClicked(); @Override void onDiffWithPrevCommitClicked(); @Override void onRevisionSelected(@NotNull Revision revision); @Override String getTitle(); @Override ImageResource getTitleImage(); @Override SVGResource getTitleSVGImage(); @Override String getTitleToolTip(); @Override void go(AcceptsOneWidget container); @Override int getSize();  }
@Test public void testShowDialogWhenLogRequestIsSuccessful() throws Exception { doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Object[] arguments = invocation.getArguments(); AsyncRequestCallback<String> callback = (AsyncRequestCallback<String>)arguments[2]; Method onSuccess = GwtReflectionUtils.getMethod(callback.getClass(), "onSuccess"); onSuccess.invoke(callback, logResponse); return callback; } }).when(service).log((ProjectDescriptor)anyObject(), anyBoolean(), (AsyncRequestCallback<LogResponse>)anyObject()); presenter.showDialog(); verify(appContext).getCurrentProject(); verify(service).log(eq(rootProjectDescriptor), eq(TEXT_NOT_FORMATTED), (AsyncRequestCallback<LogResponse>)anyObject()); verify(view).selectProjectChangesButton(eq(SELECTED_ITEM)); verify(view).selectDiffWithPrevVersionButton(eq(SELECTED_ITEM)); verify(view).setCommitADate(eq(EMPTY_TEXT)); verify(view).setCommitARevision(eq(EMPTY_TEXT)); verify(view).setCommitBDate(eq(EMPTY_TEXT)); verify(view).setCommitBRevision(eq(EMPTY_TEXT)); verify(view).setDiffContext(eq(EMPTY_TEXT)); verify(view).setCompareType(anyString()); verify(view).setRevisions((List<Revision>)anyObject()); verify(workspaceAgent).openPart(eq(presenter), eq(PartStackType.TOOLING)); verify(partStack).getActivePart(); verify(partStack).setActivePart(eq(presenter)); }
@Test public void testShowDialogWhenLogRequestIsFailed() throws Exception { doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Object[] arguments = invocation.getArguments(); AsyncRequestCallback<String> callback = (AsyncRequestCallback<String>)arguments[2]; Method onFailure = GwtReflectionUtils.getMethod(callback.getClass(), "onFailure"); onFailure.invoke(callback, mock(Throwable.class)); return callback; } }).when(service).log((ProjectDescriptor)anyObject(), anyBoolean(), (AsyncRequestCallback<LogResponse>)anyObject()); presenter.showDialog(); verify(appContext).getCurrentProject(); verify(service).log(eq(rootProjectDescriptor), eq(TEXT_NOT_FORMATTED), (AsyncRequestCallback<LogResponse>)anyObject()); verify(view).selectProjectChangesButton(eq(SELECTED_ITEM)); verify(view).selectDiffWithPrevVersionButton(eq(SELECTED_ITEM)); verify(view, times(2)).setCommitADate(eq(EMPTY_TEXT)); verify(view, times(2)).setCommitARevision(eq(EMPTY_TEXT)); verify(view, times(2)).setCommitBDate(eq(EMPTY_TEXT)); verify(view, times(2)).setCommitBRevision(eq(EMPTY_TEXT)); verify(view, times(2)).setDiffContext(eq(EMPTY_TEXT)); verify(view, times(2)).setCompareType(anyString()); verify(workspaceAgent).openPart(eq(presenter), eq(PartStackType.TOOLING)); verify(partStack).getActivePart(); verify(partStack).setActivePart(eq(presenter)); verify(constant, times(2)).historyNothingToDisplay(); verify(constant).logFailed(); verify(console).printError(anyString()); verify(notificationManager).showNotification((Notification)anyObject()); }