HistoryPresenter extends BasePresenter implements HistoryView.ActionDelegate { @Override public void onDiffWithPrevCommitClicked() { if (DiffWith.DIFF_WITH_PREV_VERSION.equals(diffType)) { return; } diffType = DiffWith.DIFF_WITH_PREV_VERSION; view.selectDiffWithIndexButton(false); view.selectDiffWithPrevVersionButton(true); view.selectDiffWithWorkingTreeButton(false); update(); } @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 testOnDiffWithPrevCommitClicked() throws Exception { List<Revision> revisions = new ArrayList<Revision>(); revisions.add(selectedRevision); revisions.add(selectedRevision); when(logResponse.getCommits()).thenReturn(revisions); 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.onRefreshClicked(); presenter.onDiffWithWorkTreeClicked(); presenter.onRevisionSelected(selectedRevision); reset(view); reset(service); presenter.onDiffWithPrevCommitClicked(); verify(view).selectDiffWithPrevVersionButton(eq(SELECTED_ITEM)); verify(view).selectDiffWithIndexButton(eq(UNSELECTED_ITEM)); verify(view).selectDiffWithWorkingTreeButton(eq(UNSELECTED_ITEM)); verify(service, never()) .diff((ProjectDescriptor)anyObject(), (List<String>)anyObject(), (DiffRequest.DiffType)anyObject(), anyBoolean(), anyInt(), anyString(), anyBoolean(), (AsyncRequestCallback<String>)anyObject()); verify(service) .diff((ProjectDescriptor)anyObject(), (List<String>)anyObject(), (DiffRequest.DiffType)anyObject(), anyBoolean(), anyInt(), anyString(), anyString(), (AsyncRequestCallback<String>)anyObject()); verify(service).log(eq(rootProjectDescriptor), eq(TEXT_NOT_FORMATTED), (AsyncRequestCallback<LogResponse>)anyObject()); }
@Test public void testOnDiffWithPrevCommitTwiceClicked() throws Exception { presenter.onDiffWithPrevCommitClicked(); reset(view); reset(service); presenter.onDiffWithPrevCommitClicked(); verify(view, never()).selectDiffWithIndexButton(anyBoolean()); verify(view, never()).selectDiffWithPrevVersionButton(anyBoolean()); verify(view, never()).selectDiffWithWorkingTreeButton(anyBoolean()); verify(service, never()) .diff((ProjectDescriptor)anyObject(), (List<String>)anyObject(), (DiffRequest.DiffType)anyObject(), anyBoolean(), anyInt(), anyString(), anyBoolean(), (AsyncRequestCallback<String>)anyObject()); verify(service, never()) .diff((ProjectDescriptor)anyObject(), (List<String>)anyObject(), (DiffRequest.DiffType)anyObject(), anyBoolean(), anyInt(), anyString(), anyString(), (AsyncRequestCallback<String>)anyObject()); verify(service, never()).log(eq(projectDescriptor), eq(TEXT_NOT_FORMATTED), (AsyncRequestCallback<LogResponse>)anyObject()); }