BranchPresenter implements BranchView.ActionDelegate { public void showBranches() { project = appContext.getCurrentProject(); getBranches(); } @Inject  BranchPresenter(BranchView view,
                           DtoFactory dtoFactory,
                           EditorAgent editorAgent,
                           GitServiceClient service,
                           GitLocalizationConstant constant,
                           GitOutputPartPresenter console,
                           AppContext appContext,
                           NotificationManager notificationManager,
                           DtoUnmarshallerFactory dtoUnmarshallerFactory,
                           GitOutputPartPresenter gitConsole,
                           WorkspaceAgent workspaceAgent,
                           DialogFactory dialogFactory,
                           ProjectExplorerPresenter projectExplorer,
                           EventBus eventBus); void showBranches(); @Override void onCloseClicked(); @Override void onRenameClicked(); @Override void onDeleteClicked(); @Override void onCheckoutClicked(); @Override void onCreateClicked(); @Override void onBranchUnselected(); @Override void onBranchSelected(@NotNull Branch branch);  }
@Test public void testShowBranchesWhenGetBranchesRequestIsSuccessful() throws Exception { final List<Branch> branches = new ArrayList<>(); presenter.showBranches(); verify(service).branchList(eq(rootProjectDescriptor), eq(LIST_ALL), branchListCallbackCaptor.capture()); AsyncRequestCallback<List<Branch>> branchListCallback = branchListCallbackCaptor.getValue(); GwtReflectionUtils.callOnSuccess(branchListCallback, branches); verify(appContext).getCurrentProject(); verify(view).showDialogIfClosed(); verify(view).setBranches(eq(branches)); verify(console, never()).printError(anyString()); verify(notificationManager, never()).showError(anyString()); verify(constant, never()).branchesListFailed(); }
@Test public void testShowBranchesWhenGetBranchesRequestIsFailed() throws Exception { presenter.showBranches(); verify(service).branchList(eq(rootProjectDescriptor), eq(LIST_ALL), branchListCallbackCaptor.capture()); AsyncRequestCallback<List<Branch>> branchListCallback = branchListCallbackCaptor.getValue(); GwtReflectionUtils.callOnFailure(branchListCallback, mock(Throwable.class)); verify(appContext).getCurrentProject(); verify(view, never()).showDialogIfClosed(); verify(console).printError(anyString()); verify(notificationManager).showError(anyString()); verify(constant).branchesListFailed(); }