PushToRemotePresenter implements PushToRemoteView.ActionDelegate { void updateLocalBranches() { getBranchesForCurrentProject(LIST_LOCAL, new AsyncCallback<List<Branch>>() { @Override public void onSuccess(List<Branch> result) { List<String> localBranches = branchSearcher.getLocalBranchesToDisplay(result); view.setLocalBranches(localBranches); for (Branch branch : result) { if (branch.isActive()) { view.selectLocalBranch(branch.getDisplayName()); break; } } updateRemoteBranches(); } @Override public void onFailure(Throwable exception) { String errorMessage = exception.getMessage() != null ? exception.getMessage() : constant.localBranchesListFailed(); console.printError(errorMessage); notificationManager.showError(errorMessage); view.setEnablePushButton(false); } }); } @Inject  PushToRemotePresenter(DtoFactory dtoFactory,
                                 PushToRemoteView view,
                                 GitServiceClient service,
                                 GitOutputPartPresenter console,
                                 AppContext appContext,
                                 GitLocalizationConstant constant,
                                 NotificationManager notificationManager,
                                 DtoUnmarshallerFactory dtoUnmarshallerFactory,
                                 BranchSearcher branchSearcher); void showDialog(); @Override void onPushClicked(); @Override void onCancelClicked(); @Override void onLocalBranchChanged(); @Override void onRepositoryChanged();  }
@Test public void testShowListOfLocalBranchesAndStartUpdateRemoteBranches() throws Exception { final List<Branch> localBranches = new ArrayList<>(); localBranches.add(localBranch); presenter.updateLocalBranches(); verify(service).branchList((ProjectDescriptor)anyObject(), (String)eq(null), asyncRequestCallbackArrayBranchCaptor.capture()); AsyncRequestCallback<List<Branch>> value = asyncRequestCallbackArrayBranchCaptor.getValue(); Method onSuccessRemotes = GwtReflectionUtils.getMethod(value.getClass(), "onSuccess"); onSuccessRemotes.invoke(value, localBranches); verify(branchSearcher).getLocalBranchesToDisplay(eq(localBranches)); verify(view).setLocalBranches((List<String>)anyObject()); verify(view).selectLocalBranch(localBranch.getDisplayName()); }