### Question:
ChangeRequestReviewScreenPresenter { public void squash() { changeRequestService.call((RemoteCallback<List<ChangeRequestCommit>>) this::showSquashPopUp) .getCommits(workspaceProject.getSpace().getName(), repository.getAlias(), currentChangeRequestId); } @Inject  ChangeRequestReviewScreenPresenter(final View view,
                                              final TranslationService ts,
                                              final LibraryPlaces libraryPlaces,
                                              final Caller<ChangeRequestService> changeRequestService,
                                              final Caller<RepositoryService> repositoryService,
                                              final BusyIndicatorView busyIndicatorView,
                                              final OverviewScreenPresenter overviewScreen,
                                              final ChangedFilesScreenPresenter changedFilesScreen,
                                              final Promises promises,
                                              final ProjectController projectController,
                                              final Event<NotificationEvent> notificationEvent,
                                              final SessionInfo sessionInfo,
                                              final SquashChangeRequestPopUpPresenter squashChangeRequestPopUpPresenter); @PostConstruct void postConstruct(); void refreshOnFocus(@Observes final SelectPlaceEvent selectPlaceEvent); void onChangeRequestUpdated(@Observes final ChangeRequestUpdatedEvent event); void onChangeRequestStatusUpdated(@Observes final ChangeRequestStatusUpdatedEvent event); void onRepositoryFileListUpdated(@Observes final RepositoryFileListUpdatedEvent event); void onRepositoryUpdated(@Observes final RepositoryUpdatedEvent event); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView View getView(); void showOverviewContent(); void showChangedFilesContent(); void cancel(); void reject(); void squash(); void merge(); void revert(); void close(); void reopen();  }### Answer:
@Test public void squashWhenHasPermissionTest() throws NoSuchFieldException { new FieldSetter(presenter, ChangeRequestReviewScreenPresenter.class.getDeclaredField("workspaceProject")) .set(workspaceProject); new FieldSetter(presenter, ChangeRequestReviewScreenPresenter.class.getDeclaredField("repository")) .set(repository); doReturn(promises.resolve(true)) .when(projectController) .canUpdateBranch(workspaceProject, branch); doReturn(true) .when(changeRequestService) .squashChangeRequest(anyString(), anyString(), anyLong(), anyString()); presenter.squash(); verify(squashChangeRequestPopUpPresenter) .show(any(), any()); }
@Test public void squashWhenNotAllowedTest() throws NoSuchFieldException { new FieldSetter(presenter, ChangeRequestReviewScreenPresenter.class.getDeclaredField("workspaceProject")) .set(workspaceProject); new FieldSetter(presenter, ChangeRequestReviewScreenPresenter.class.getDeclaredField("repository")) .set(repository); doReturn(promises.resolve(false)) .when(projectController) .canUpdateBranch(workspaceProject, branch); doReturn(new ArrayList()) .when(changeRequestService) .getCommits(any(), any(), any()); presenter.squash(); verify(changeRequestService, never()) .squashChangeRequest(anyString(), anyString(), anyLong(), anyString()); }