FetchPresenter implements FetchView.ActionDelegate { @Override public void onRemoteRepositoryChanged() { updateBranches(LIST_REMOTE); } @Inject  FetchPresenter(DtoFactory dtoFactory,
                          FetchView view,
                          GitOutputPartPresenter console,
                          GitServiceClient service,
                          AppContext appContext,
                          GitLocalizationConstant constant,
                          NotificationManager notificationManager,
                          DtoUnmarshallerFactory dtoUnmarshallerFactory,
                          BranchSearcher branchSearcher); void showDialog(); @Override void onFetchClicked(); @Override void onCancelClicked(); @Override void onValueChanged(); @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()); }