@Test public void testSave() { WorkspaceProject project = mock(WorkspaceProject.class); doReturn(project).when(projectScreenService).save(any(), any(), any(), any()); final Section<ProjectScreenModel> section1 = newMockedSection(); final Section<ProjectScreenModel> section2 = newMockedSection(); doReturn(promises.resolve()).when(section1).save(any(), any()); doReturn(promises.resolve()).when(section2).save(any(), any()); doReturn(promises.resolve()).when(sectionManager).resetAllDirtyIndicators(); doReturn(promises.resolve()).when(presenter).saveProjectScreenModel(any(), any(), any()); doReturn(new ArrayList<>(Arrays.asList(section1, section2))).when(sectionManager).getSections(); presenter.save("Test comment"); verify(section1).save(eq("Test comment"), any()); verify(section2).save(eq("Test comment"), any()); verify(presenter).saveProjectScreenModel(eq("Test comment"), eq(DeploymentMode.VALIDATED), any()); verify(presenter).displaySuccessMessage(); }
void save(final String comment) { promises.reduceLazilyChaining(getSavingSteps(comment), this::executeSavingStep) .catch_(o -> promises.catchOrExecute(o, promises::reject, sectionManager::goTo)); }
SettingsPresenter { void save(final String comment) { promises.reduceLazilyChaining(getSavingSteps(comment), this::executeSavingStep) .catch_(o -> promises.catchOrExecute(o, promises::reject, sectionManager::goTo)); } }
SettingsPresenter { void save(final String comment) { promises.reduceLazilyChaining(getSavingSteps(comment), this::executeSavingStep) .catch_(o -> promises.catchOrExecute(o, promises::reject, sectionManager::goTo)); } @Inject  SettingsPresenter(final View view,
                             final Promises promises,
                             final Event<NotificationEvent> notificationEvent,
                             final @Customizable SettingsSections<ProjectScreenModel> settingsSections,
                             final SavePopUpPresenter savePopUpPresenter,
                             final Caller<ProjectScreenService> projectScreenService,
                             final WorkspaceProjectContext projectContext,
                             final ManagedInstance<ObservablePath> observablePaths,
                             final ConflictingRepositoriesPopup conflictingRepositoriesPopup,
                             final SectionManager<ProjectScreenModel> sectionManager,
                             final ProjectController projectController); }
SettingsPresenter { void save(final String comment) { promises.reduceLazilyChaining(getSavingSteps(comment), this::executeSavingStep) .catch_(o -> promises.catchOrExecute(o, promises::reject, sectionManager::goTo)); } @Inject  SettingsPresenter(final View view,
                             final Promises promises,
                             final Event<NotificationEvent> notificationEvent,
                             final @Customizable SettingsSections<ProjectScreenModel> settingsSections,
                             final SavePopUpPresenter savePopUpPresenter,
                             final Caller<ProjectScreenService> projectScreenService,
                             final WorkspaceProjectContext projectContext,
                             final ManagedInstance<ObservablePath> observablePaths,
                             final ConflictingRepositoriesPopup conflictingRepositoriesPopup,
                             final SectionManager<ProjectScreenModel> sectionManager,
                             final ProjectController projectController); @PostConstruct void setup(); Promise<Void> setupUsingCurrentSection(); void showSaveModal(); void onSettingsSectionChanged(@Observes final SettingsSectionChange<ProjectScreenModel> settingsSectionChange); boolean mayClose(); void reset(); View getView(); }
SettingsPresenter { void save(final String comment) { promises.reduceLazilyChaining(getSavingSteps(comment), this::executeSavingStep) .catch_(o -> promises.catchOrExecute(o, promises::reject, sectionManager::goTo)); } @Inject  SettingsPresenter(final View view,
                             final Promises promises,
                             final Event<NotificationEvent> notificationEvent,
                             final @Customizable SettingsSections<ProjectScreenModel> settingsSections,
                             final SavePopUpPresenter savePopUpPresenter,
                             final Caller<ProjectScreenService> projectScreenService,
                             final WorkspaceProjectContext projectContext,
                             final ManagedInstance<ObservablePath> observablePaths,
                             final ConflictingRepositoriesPopup conflictingRepositoriesPopup,
                             final SectionManager<ProjectScreenModel> sectionManager,
                             final ProjectController projectController); @PostConstruct void setup(); Promise<Void> setupUsingCurrentSection(); void showSaveModal(); void onSettingsSectionChanged(@Observes final SettingsSectionChange<ProjectScreenModel> settingsSectionChange); boolean mayClose(); void reset(); View getView();  }