PullPresenter implements PullView.ActionDelegate { @Override public void onRemoteRepositoryChanged() { updateBranches(LIST_REMOTE); } @Inject  PullPresenter(PullView view,
                         EditorAgent editorAgent,
                         GitServiceClient gitServiceClient,
                         GitOutputPartPresenter console,
                         EventBus eventBus,
                         AppContext appContext,
                         GitLocalizationConstant constant,
                         NotificationManager notificationManager,
                         DtoUnmarshallerFactory dtoUnmarshallerFactory,
                         DtoFactory dtoFactory,
                         BranchSearcher branchSearcher,
                         ProjectExplorerPresenter projectExplorer); void showDialog(); @Override void onPullClicked(); @Override void onCancelClicked(); @Override void onRemoteBranchChanged(); @Override void onRemoteRepositoryChanged();  }
@Test public void shouldRefreshRemoteBranchesWhenRepositoryIsChanged() throws Exception { final List<Remote> remotes = new ArrayList<>(); remotes.add(mock(Remote.class)); final List<Branch> branches = new ArrayList<>(); branches.add(branch); when(branch.isActive()).thenReturn(ACTIVE_BRANCH); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Object[] arguments = invocation.getArguments(); AsyncRequestCallback<List<Branch>> callback = (AsyncRequestCallback<List<Branch>>)arguments[2]; Method onSuccess = GwtReflectionUtils.getMethod(callback.getClass(), "onSuccess"); onSuccess.invoke(callback, branches); return callback; } }).when(service).branchList((ProjectDescriptor)anyObject(), anyString(), (AsyncRequestCallback<List<Branch>>)anyObject()); presenter.onRemoteRepositoryChanged(); verify(service, times(2)).branchList(eq(rootProjectDescriptor), anyString(), (AsyncRequestCallback<List<Branch>>)anyObject()); verify(view).setRemoteBranches((List<String>)anyObject()); verify(view).setLocalBranches((List<String>)anyObject()); verify(view).selectRemoteBranch(anyString()); }