@Test public void testSetupSections() { final Section<ProjectScreenModel> section1 = newMockedSection(); final Section<ProjectScreenModel> section2 = newMockedSection(); doReturn(new ArrayList<>(Arrays.asList(section1, section2))).when(sectionManager).getSections(); doReturn(promises.resolve()).when(presenter).setupSection(any(), any()); presenter.setupSections(mock(ProjectScreenModel.class)).catch_(i -> { fail("Promise should've been resolved!"); return promises.resolve(); }); verify(presenter, times(2)).setupSection(any(), any()); }
Promise<Object> setupSections(final ProjectScreenModel model) { final List<Section<ProjectScreenModel>> sections = new ArrayList<>(sectionManager.getSections()); return promises.all(sections, (final Section<ProjectScreenModel> section) -> setupSection(model, section)).then(i -> { if (sectionManager.isEmpty()) { return promises.reject("No sections available"); } else { return promises.resolve(); } }); }
SettingsPresenter { Promise<Object> setupSections(final ProjectScreenModel model) { final List<Section<ProjectScreenModel>> sections = new ArrayList<>(sectionManager.getSections()); return promises.all(sections, (final Section<ProjectScreenModel> section) -> setupSection(model, section)).then(i -> { if (sectionManager.isEmpty()) { return promises.reject("No sections available"); } else { return promises.resolve(); } }); } }
SettingsPresenter { Promise<Object> setupSections(final ProjectScreenModel model) { final List<Section<ProjectScreenModel>> sections = new ArrayList<>(sectionManager.getSections()); return promises.all(sections, (final Section<ProjectScreenModel> section) -> setupSection(model, section)).then(i -> { if (sectionManager.isEmpty()) { return promises.reject("No sections available"); } else { return promises.resolve(); } }); } @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<Object> setupSections(final ProjectScreenModel model) { final List<Section<ProjectScreenModel>> sections = new ArrayList<>(sectionManager.getSections()); return promises.all(sections, (final Section<ProjectScreenModel> section) -> setupSection(model, section)).then(i -> { if (sectionManager.isEmpty()) { return promises.reject("No sections available"); } else { return promises.resolve(); } }); } @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<Object> setupSections(final ProjectScreenModel model) { final List<Section<ProjectScreenModel>> sections = new ArrayList<>(sectionManager.getSections()); return promises.all(sections, (final Section<ProjectScreenModel> section) -> setupSection(model, section)).then(i -> { if (sectionManager.isEmpty()) { return promises.reject("No sections available"); } else { return promises.resolve(); } }); } @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();  }