@Test public void testSaveProjectScreenModel() { WorkspaceProject project = mock(WorkspaceProject.class); Module module = mock(Module.class); doReturn(module).when(project).getMainModule(); doReturn(project).when(projectScreenService).save(any(), any(), any(), any()); presenter.saveProjectScreenModel("Test comment", DeploymentMode.VALIDATED, null).catch_(i -> { fail("Promise should've been resolved!"); return promises.resolve(); }); verify(projectScreenService).save(any(), any(), eq("Test comment"), eq(DeploymentMode.VALIDATED)); verify(projectContext).updateProjectModule(module); verify(presenter, never()).handlePomConcurrentUpdate(any(), any()); }
Promise<Void> saveProjectScreenModel(final String comment, final DeploymentMode mode, final Supplier<Promise<Void>> chain) { if (concurrentPomUpdateInfo != null) { handlePomConcurrentUpdate(comment, chain); return promises.reject(sectionManager.getCurrentSection()); } return promises.promisify(projectScreenService, s -> { return s.save(pathToPom, model, comment, mode); }).then(workspaceProject -> { projectContext.updateProjectModule(workspaceProject.getMainModule()); return promises.resolve(); }).catch_(o -> promises.catchOrExecute(o, e -> { if (e instanceof GAVAlreadyExistsException) { return handlePomConcurrentUpdate(comment, chain, (GAVAlreadyExistsException) e); } else { view.hideBusyIndicator(); return promises.resolve(); } }, x -> { view.hideBusyIndicator(); return promises.reject(x); })); }
SettingsPresenter { Promise<Void> saveProjectScreenModel(final String comment, final DeploymentMode mode, final Supplier<Promise<Void>> chain) { if (concurrentPomUpdateInfo != null) { handlePomConcurrentUpdate(comment, chain); return promises.reject(sectionManager.getCurrentSection()); } return promises.promisify(projectScreenService, s -> { return s.save(pathToPom, model, comment, mode); }).then(workspaceProject -> { projectContext.updateProjectModule(workspaceProject.getMainModule()); return promises.resolve(); }).catch_(o -> promises.catchOrExecute(o, e -> { if (e instanceof GAVAlreadyExistsException) { return handlePomConcurrentUpdate(comment, chain, (GAVAlreadyExistsException) e); } else { view.hideBusyIndicator(); return promises.resolve(); } }, x -> { view.hideBusyIndicator(); return promises.reject(x); })); } }
SettingsPresenter { Promise<Void> saveProjectScreenModel(final String comment, final DeploymentMode mode, final Supplier<Promise<Void>> chain) { if (concurrentPomUpdateInfo != null) { handlePomConcurrentUpdate(comment, chain); return promises.reject(sectionManager.getCurrentSection()); } return promises.promisify(projectScreenService, s -> { return s.save(pathToPom, model, comment, mode); }).then(workspaceProject -> { projectContext.updateProjectModule(workspaceProject.getMainModule()); return promises.resolve(); }).catch_(o -> promises.catchOrExecute(o, e -> { if (e instanceof GAVAlreadyExistsException) { return handlePomConcurrentUpdate(comment, chain, (GAVAlreadyExistsException) e); } else { view.hideBusyIndicator(); return promises.resolve(); } }, x -> { view.hideBusyIndicator(); return promises.reject(x); })); } @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 { Promise<Void> saveProjectScreenModel(final String comment, final DeploymentMode mode, final Supplier<Promise<Void>> chain) { if (concurrentPomUpdateInfo != null) { handlePomConcurrentUpdate(comment, chain); return promises.reject(sectionManager.getCurrentSection()); } return promises.promisify(projectScreenService, s -> { return s.save(pathToPom, model, comment, mode); }).then(workspaceProject -> { projectContext.updateProjectModule(workspaceProject.getMainModule()); return promises.resolve(); }).catch_(o -> promises.catchOrExecute(o, e -> { if (e instanceof GAVAlreadyExistsException) { return handlePomConcurrentUpdate(comment, chain, (GAVAlreadyExistsException) e); } else { view.hideBusyIndicator(); return promises.resolve(); } }, x -> { view.hideBusyIndicator(); return promises.reject(x); })); } @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 { Promise<Void> saveProjectScreenModel(final String comment, final DeploymentMode mode, final Supplier<Promise<Void>> chain) { if (concurrentPomUpdateInfo != null) { handlePomConcurrentUpdate(comment, chain); return promises.reject(sectionManager.getCurrentSection()); } return promises.promisify(projectScreenService, s -> { return s.save(pathToPom, model, comment, mode); }).then(workspaceProject -> { projectContext.updateProjectModule(workspaceProject.getMainModule()); return promises.resolve(); }).catch_(o -> promises.catchOrExecute(o, e -> { if (e instanceof GAVAlreadyExistsException) { return handlePomConcurrentUpdate(comment, chain, (GAVAlreadyExistsException) e); } else { view.hideBusyIndicator(); return promises.resolve(); } }, x -> { view.hideBusyIndicator(); return promises.reject(x); })); } @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();  }