@Test public void setupUsingCurrentSectionTest() { doReturn(new ArrayList<>(singletonList(createSectionMock()))).when(sectionManager).getSections(); doReturn(true).when(sectionManager).manages(any()); doReturn(promises.resolve()).when(sectionManager).goToCurrentSection(); doReturn(promises.resolve()).when(presenter).setupSections(any()); doReturn(true).when(organizationalUnitController).canUpdateOrgUnit(organizationalUnit); presenter.setupUsingCurrentSection(); verify(view).init(eq(presenter)); verify(busyIndicatorView).showBusyIndicator(anyString()); verify(view).enableActions(eq(true)); verify(presenter).setupSections(any()); verify(sectionManager).goToCurrentSection(); verify(busyIndicatorView).hideBusyIndicator(); verify(sectionManager, never()).goToFirstAvailable(); verify(notificationEvent, never()).fire(any()); }
public Promise<Void> setupUsingCurrentSection() { this.view.init(this); showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); view.enableActions(canUpdate()); return setupSections(new SpaceScreenModel()).then(o -> { hideBusyIndicator(); if (sectionManager.manages(sectionManager.getCurrentSection())) { return sectionManager.goToCurrentSection(); } else { return sectionManager.goToFirstAvailable(); } }).catch_(o -> promises.catchOrExecute(o, e -> { hideBusyIndicator(); return promises.reject(e); }, i -> { notificationEvent.fire(new NotificationEvent(ts.getTranslation(LibraryConstants.SettingsLoadError), ERROR)); hideBusyIndicator(); return promises.resolve(); })); }
SettingsScreenPresenter implements HasBusyIndicator { public Promise<Void> setupUsingCurrentSection() { this.view.init(this); showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); view.enableActions(canUpdate()); return setupSections(new SpaceScreenModel()).then(o -> { hideBusyIndicator(); if (sectionManager.manages(sectionManager.getCurrentSection())) { return sectionManager.goToCurrentSection(); } else { return sectionManager.goToFirstAvailable(); } }).catch_(o -> promises.catchOrExecute(o, e -> { hideBusyIndicator(); return promises.reject(e); }, i -> { notificationEvent.fire(new NotificationEvent(ts.getTranslation(LibraryConstants.SettingsLoadError), ERROR)); hideBusyIndicator(); return promises.resolve(); })); } }
SettingsScreenPresenter implements HasBusyIndicator { public Promise<Void> setupUsingCurrentSection() { this.view.init(this); showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); view.enableActions(canUpdate()); return setupSections(new SpaceScreenModel()).then(o -> { hideBusyIndicator(); if (sectionManager.manages(sectionManager.getCurrentSection())) { return sectionManager.goToCurrentSection(); } else { return sectionManager.goToFirstAvailable(); } }).catch_(o -> promises.catchOrExecute(o, e -> { hideBusyIndicator(); return promises.reject(e); }, i -> { notificationEvent.fire(new NotificationEvent(ts.getTranslation(LibraryConstants.SettingsLoadError), ERROR)); hideBusyIndicator(); 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 { public Promise<Void> setupUsingCurrentSection() { this.view.init(this); showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); view.enableActions(canUpdate()); return setupSections(new SpaceScreenModel()).then(o -> { hideBusyIndicator(); if (sectionManager.manages(sectionManager.getCurrentSection())) { return sectionManager.goToCurrentSection(); } else { return sectionManager.goToFirstAvailable(); } }).catch_(o -> promises.catchOrExecute(o, e -> { hideBusyIndicator(); return promises.reject(e); }, i -> { notificationEvent.fire(new NotificationEvent(ts.getTranslation(LibraryConstants.SettingsLoadError), ERROR)); hideBusyIndicator(); 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 { public Promise<Void> setupUsingCurrentSection() { this.view.init(this); showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); view.enableActions(canUpdate()); return setupSections(new SpaceScreenModel()).then(o -> { hideBusyIndicator(); if (sectionManager.manages(sectionManager.getCurrentSection())) { return sectionManager.goToCurrentSection(); } else { return sectionManager.goToFirstAvailable(); } }).catch_(o -> promises.catchOrExecute(o, e -> { hideBusyIndicator(); return promises.reject(e); }, i -> { notificationEvent.fire(new NotificationEvent(ts.getTranslation(LibraryConstants.SettingsLoadError), ERROR)); hideBusyIndicator(); 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();  }