BranchPresenter implements BranchView.ActionDelegate { @Override public void onDeleteClicked() { final String name = selectedBranch.getName(); service.branchDelete(project.getRootProject(), name, true, new AsyncRequestCallback<String>() { @Override protected void onSuccess(String result) { getBranches(); } @Override protected void onFailure(Throwable exception) { handleError(exception); } }); } @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 testOnDeleteClickedWhenBranchDeleteRequestIsSuccessful() throws Exception { selectBranch(); presenter.onDeleteClicked(); verify(service).branchDelete(eq(rootProjectDescriptor), eq(BRANCH_NAME), eq(NEED_DELETING), asyncRequestCallbackCaptor.capture()); AsyncRequestCallback<String> deleteBranchCallback = asyncRequestCallbackCaptor.getValue(); GwtReflectionUtils.callOnSuccess(deleteBranchCallback, PROJECT_PATH); verify(selectedBranch).getName(); verify(service, times(2)).branchList(eq(rootProjectDescriptor), eq(LIST_ALL), anyObject()); verify(constant, never()).branchDeleteFailed(); verify(console, never()).printError(anyString()); verify(notificationManager, never()).showError(anyString()); }
@Test public void testOnDeleteClickedWhenBranchDeleteRequestIsFailed() throws Exception { selectBranch(); presenter.onDeleteClicked(); verify(service).branchDelete(eq(rootProjectDescriptor), eq(BRANCH_NAME), eq(NEED_DELETING), asyncRequestCallbackCaptor.capture()); AsyncRequestCallback<String> deleteBranchCallback = asyncRequestCallbackCaptor.getValue(); GwtReflectionUtils.callOnFailure(deleteBranchCallback, mock(Throwable.class)); verify(selectedBranch).getName(); verify(constant, times(2)).branchDeleteFailed(); verify(console).printError(anyString()); verify(notificationManager).showError(anyString()); }