@Test public void submitSuccessTest() throws NoSuchFieldException { final String destinationBranch = "destinationBranch"; new FieldSetter(presenter, SubmitChangeRequestScreenPresenter.class.getDeclaredField("workspaceProject")) .set(workspaceProject); new FieldSetter(presenter, SubmitChangeRequestScreenPresenter.class.getDeclaredField("selectedBranch")) .set(destinationBranch); doReturn("summary").when(view).getSummary(); doReturn("description").when(view).getDescription(); doReturn(promises.resolve(true)).when(projectController) .canSubmitChangeRequest(workspaceProject, destinationBranch); ChangeRequest cr = mock(ChangeRequest.class); doReturn(cr).when(changeRequestService).createChangeRequest(anyString(), anyString(), anyString(), anyString(), anyString(), anyString()); presenter.submit(); verify(view).clearErrors(); verify(view, never()).setSummaryError(); verify(view, never()).setDescriptionError(); verify(changeRequestService).createChangeRequest(anyString(), anyString(), anyString(), anyString(), anyString(), anyString()); verify(libraryPlaces).goToChangeRequestReviewScreen(anyLong()); }
public void submit() { if (!validateFields()) { return; } busyIndicatorView.showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); projectController.canSubmitChangeRequest(workspaceProject, selectedBranch).then(userCanSubmitChangeRequest -> { if (Boolean.TRUE.equals(userCanSubmitChangeRequest)) { changeRequestService.call((final ChangeRequest item) -> { busyIndicatorView.hideBusyIndicator(); notificationEvent.fire( new NotificationEvent(ts.format(LibraryConstants.ChangeRequestSubmitMessage, item.getId()), NotificationEvent.NotificationType.SUCCESS)); destroyDiffItems(); this.libraryPlaces.goToChangeRequestReviewScreen(item.getId()); }, createChangeRequestErrorCallback()) .createChangeRequest(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), currentBranchName, selectedBranch, view.getSummary(), view.getDescription()); } return promises.resolve(); }); }
SubmitChangeRequestScreenPresenter { public void submit() { if (!validateFields()) { return; } busyIndicatorView.showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); projectController.canSubmitChangeRequest(workspaceProject, selectedBranch).then(userCanSubmitChangeRequest -> { if (Boolean.TRUE.equals(userCanSubmitChangeRequest)) { changeRequestService.call((final ChangeRequest item) -> { busyIndicatorView.hideBusyIndicator(); notificationEvent.fire( new NotificationEvent(ts.format(LibraryConstants.ChangeRequestSubmitMessage, item.getId()), NotificationEvent.NotificationType.SUCCESS)); destroyDiffItems(); this.libraryPlaces.goToChangeRequestReviewScreen(item.getId()); }, createChangeRequestErrorCallback()) .createChangeRequest(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), currentBranchName, selectedBranch, view.getSummary(), view.getDescription()); } return promises.resolve(); }); } }
SubmitChangeRequestScreenPresenter { public void submit() { if (!validateFields()) { return; } busyIndicatorView.showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); projectController.canSubmitChangeRequest(workspaceProject, selectedBranch).then(userCanSubmitChangeRequest -> { if (Boolean.TRUE.equals(userCanSubmitChangeRequest)) { changeRequestService.call((final ChangeRequest item) -> { busyIndicatorView.hideBusyIndicator(); notificationEvent.fire( new NotificationEvent(ts.format(LibraryConstants.ChangeRequestSubmitMessage, item.getId()), NotificationEvent.NotificationType.SUCCESS)); destroyDiffItems(); this.libraryPlaces.goToChangeRequestReviewScreen(item.getId()); }, createChangeRequestErrorCallback()) .createChangeRequest(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), currentBranchName, selectedBranch, view.getSummary(), view.getDescription()); } return promises.resolve(); }); } @Inject  SubmitChangeRequestScreenPresenter(final View view,
                                              final TranslationService ts,
                                              final LibraryPlaces libraryPlaces,
                                              final ManagedInstance<DiffItemPresenter> diffItemPresenterInstances,
                                              final Caller<ChangeRequestService> changeRequestService,
                                              final ProjectController projectController,
                                              final Promises promises,
                                              final BusyIndicatorView busyIndicatorView,
                                              final ChangeRequestUtils changeRequestUtils,
                                              final Event<NotificationEvent> notificationEvent); }
SubmitChangeRequestScreenPresenter { public void submit() { if (!validateFields()) { return; } busyIndicatorView.showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); projectController.canSubmitChangeRequest(workspaceProject, selectedBranch).then(userCanSubmitChangeRequest -> { if (Boolean.TRUE.equals(userCanSubmitChangeRequest)) { changeRequestService.call((final ChangeRequest item) -> { busyIndicatorView.hideBusyIndicator(); notificationEvent.fire( new NotificationEvent(ts.format(LibraryConstants.ChangeRequestSubmitMessage, item.getId()), NotificationEvent.NotificationType.SUCCESS)); destroyDiffItems(); this.libraryPlaces.goToChangeRequestReviewScreen(item.getId()); }, createChangeRequestErrorCallback()) .createChangeRequest(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), currentBranchName, selectedBranch, view.getSummary(), view.getDescription()); } return promises.resolve(); }); } @Inject  SubmitChangeRequestScreenPresenter(final View view,
                                              final TranslationService ts,
                                              final LibraryPlaces libraryPlaces,
                                              final ManagedInstance<DiffItemPresenter> diffItemPresenterInstances,
                                              final Caller<ChangeRequestService> changeRequestService,
                                              final ProjectController projectController,
                                              final Promises promises,
                                              final BusyIndicatorView busyIndicatorView,
                                              final ChangeRequestUtils changeRequestUtils,
                                              final Event<NotificationEvent> notificationEvent); @PostConstruct void postConstruct(); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView View getView(); @OnClose void onClose(); void refreshOnFocus(@Observes final SelectPlaceEvent selectPlaceEvent); void onRepositoryFileListUpdated(@Observes final RepositoryFileListUpdatedEvent event); void cancel(); void submit(); void selectBranch(final String branchName); void updateDiffContainer(); }
SubmitChangeRequestScreenPresenter { public void submit() { if (!validateFields()) { return; } busyIndicatorView.showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); projectController.canSubmitChangeRequest(workspaceProject, selectedBranch).then(userCanSubmitChangeRequest -> { if (Boolean.TRUE.equals(userCanSubmitChangeRequest)) { changeRequestService.call((final ChangeRequest item) -> { busyIndicatorView.hideBusyIndicator(); notificationEvent.fire( new NotificationEvent(ts.format(LibraryConstants.ChangeRequestSubmitMessage, item.getId()), NotificationEvent.NotificationType.SUCCESS)); destroyDiffItems(); this.libraryPlaces.goToChangeRequestReviewScreen(item.getId()); }, createChangeRequestErrorCallback()) .createChangeRequest(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), currentBranchName, selectedBranch, view.getSummary(), view.getDescription()); } return promises.resolve(); }); } @Inject  SubmitChangeRequestScreenPresenter(final View view,
                                              final TranslationService ts,
                                              final LibraryPlaces libraryPlaces,
                                              final ManagedInstance<DiffItemPresenter> diffItemPresenterInstances,
                                              final Caller<ChangeRequestService> changeRequestService,
                                              final ProjectController projectController,
                                              final Promises promises,
                                              final BusyIndicatorView busyIndicatorView,
                                              final ChangeRequestUtils changeRequestUtils,
                                              final Event<NotificationEvent> notificationEvent); @PostConstruct void postConstruct(); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView View getView(); @OnClose void onClose(); void refreshOnFocus(@Observes final SelectPlaceEvent selectPlaceEvent); void onRepositoryFileListUpdated(@Observes final RepositoryFileListUpdatedEvent event); void cancel(); void submit(); void selectBranch(final String branchName); void updateDiffContainer();  }