DeploymentsSectionPresenter extends Section<ProjectScreenModel> { @Override public Promise<Void> save(final String comment, final Supplier<Promise<Void>> chain) { if (concurrentDeploymentsXmlUpdateInfo != null) { notificationEvent.fire(new NotificationEvent(view.getConcurrentUpdateMessage(), WARNING)); return setup(); } return save(comment).then(i -> { sectionManager.resetAllDirtyIndicators(); return promises.resolve(); }); } @Inject  DeploymentsSectionPresenter(final View view,
                                       final Promises promises,
                                       final MenuItem<ProjectScreenModel> menuItem,
                                       final WorkspaceProjectContext projectContext,
                                       final Caller<DDEditorService> ddEditorService,
                                       final ManagedInstance<ObservablePath> observablePaths,
                                       final Event<SettingsSectionChange<ProjectScreenModel>> settingsSectionChangeEvent,
                                       final Event<NotificationEvent> notificationEvent,
                                       final SectionManager<DeploymentDescriptorModel> sectionManager,
                                       final DeploymentsSections deploymentsSections); @PostConstruct void init(); @Override Promise<Void> setup(final ProjectScreenModel ignore); @Override Promise<Void> save(final String comment,
                              final Supplier<Promise<Void>> chain); void onSectionChanged(@Observes final SettingsSectionChange<DeploymentDescriptorModel> settingsSectionChange); @Override int currentHashCode(); @Override SectionView<?> getView();  }
@Test public void testSave() { doReturn(promises.resolve()).when(presenter).save(eq("Test comment")); presenter.save("Test comment", null).catch_(i -> { Assert.fail("Promise should've been resolved!"); return promises.resolve(); }); verify(presenter).save(eq("Test comment")); verify(presenter, never()).setup(); verify(notificationEvent, never()).fire(any()); }
@Test public void testSaveModel() { doReturn(mock(Path.class)).when(ddEditorService).save(any(), any(), any(), any()); final DeploymentDescriptorModel model = new DeploymentDescriptorModel(); model.setOverview(new Overview()); presenter.model = model; presenter.save("Test comment").catch_(i -> { Assert.fail("Promise should've been resolved!"); return promises.resolve(); }); verify(ddEditorService).save(any(), any(), any(), eq("Test comment")); }