@Test public void setupSectionsTest() { doReturn(new ArrayList<>(Arrays.asList(createSectionMock(), createSectionMock()))).when(sectionManager).getSections(); doReturn(promises.resolve()).when(presenter).setupSection(any(), any()); presenter.setupSections(mock(SpaceScreenModel.class)).catch_(i -> { fail("Promise should've been resolved!"); return promises.resolve(); }); verify(presenter, times(2)).setupSection(any(), any()); }
Promise<Object> setupSections(final SpaceScreenModel model) { final List<Section<SpaceScreenModel>> sections = new ArrayList<>(sectionManager.getSections()); return promises.all(sections, (final Section<SpaceScreenModel> section) -> setupSection(model, section)).then(i -> { if (sectionManager.isEmpty()) { return promises.reject("No sections available"); } else { return promises.resolve(); } }); }
SettingsScreenPresenter implements HasBusyIndicator { Promise<Object> setupSections(final SpaceScreenModel model) { final List<Section<SpaceScreenModel>> sections = new ArrayList<>(sectionManager.getSections()); return promises.all(sections, (final Section<SpaceScreenModel> section) -> setupSection(model, section)).then(i -> { if (sectionManager.isEmpty()) { return promises.reject("No sections available"); } else { return promises.resolve(); } }); } }
SettingsScreenPresenter implements HasBusyIndicator { Promise<Object> setupSections(final SpaceScreenModel model) { final List<Section<SpaceScreenModel>> sections = new ArrayList<>(sectionManager.getSections()); return promises.all(sections, (final Section<SpaceScreenModel> section) -> setupSection(model, section)).then(i -> { if (sectionManager.isEmpty()) { return promises.reject("No sections available"); } else { return promises.resolve(); } }); } @Inject  SettingsScreenPresenter(final View view,
                                   final TranslationService ts,
                                   final OrganizationalUnitController organizationalUnitController,
                                   final WorkspaceProjectContext projectContext,
                                   final BusyIndicatorView busyIndicatorView,
                                   final SectionManager<SpaceScreenModel> sectionManager,
                                   final @SpaceSettings SettingsSections settingsSections,
                                   final Promises promises,
                                   final Event<NotificationEvent> notificationEvent); }
SettingsScreenPresenter implements HasBusyIndicator { Promise<Object> setupSections(final SpaceScreenModel model) { final List<Section<SpaceScreenModel>> sections = new ArrayList<>(sectionManager.getSections()); return promises.all(sections, (final Section<SpaceScreenModel> section) -> setupSection(model, section)).then(i -> { if (sectionManager.isEmpty()) { return promises.reject("No sections available"); } else { return promises.resolve(); } }); } @Inject  SettingsScreenPresenter(final View view,
                                   final TranslationService ts,
                                   final OrganizationalUnitController organizationalUnitController,
                                   final WorkspaceProjectContext projectContext,
                                   final BusyIndicatorView busyIndicatorView,
                                   final SectionManager<SpaceScreenModel> sectionManager,
                                   final @SpaceSettings SettingsSections settingsSections,
                                   final Promises promises,
                                   final Event<NotificationEvent> notificationEvent); @PostConstruct void postConstruct(); Promise<Void> setupUsingCurrentSection(); View getView(); @Override void showBusyIndicator(final String message); @Override void hideBusyIndicator(); void onSettingsSectionChanged(@Observes final SettingsSectionChange<SpaceScreenModel> settingsSectionChange); void save(); void reset(); }
SettingsScreenPresenter implements HasBusyIndicator { Promise<Object> setupSections(final SpaceScreenModel model) { final List<Section<SpaceScreenModel>> sections = new ArrayList<>(sectionManager.getSections()); return promises.all(sections, (final Section<SpaceScreenModel> section) -> setupSection(model, section)).then(i -> { if (sectionManager.isEmpty()) { return promises.reject("No sections available"); } else { return promises.resolve(); } }); } @Inject  SettingsScreenPresenter(final View view,
                                   final TranslationService ts,
                                   final OrganizationalUnitController organizationalUnitController,
                                   final WorkspaceProjectContext projectContext,
                                   final BusyIndicatorView busyIndicatorView,
                                   final SectionManager<SpaceScreenModel> sectionManager,
                                   final @SpaceSettings SettingsSections settingsSections,
                                   final Promises promises,
                                   final Event<NotificationEvent> notificationEvent); @PostConstruct void postConstruct(); Promise<Void> setupUsingCurrentSection(); View getView(); @Override void showBusyIndicator(final String message); @Override void hideBusyIndicator(); void onSettingsSectionChanged(@Observes final SettingsSectionChange<SpaceScreenModel> settingsSectionChange); void save(); void reset();  }