### Question:
SettingsScreenPresenter implements HasBusyIndicator { public void save() { if (canUpdate()) { sectionManager.validateAll().then(i -> { save(""); return promises.resolve(); }).catch_(o -> promises.catchOrExecute(o, e -> { hideBusyIndicator(); return promises.reject(e); }, (final Section<SpaceScreenModel> section) -> { hideBusyIndicator(); return sectionManager.goTo(section); })); } } @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();  }### Answer:
@Test public void saveWhenAllowedTest() { doReturn(true).when(organizationalUnitController).canUpdateOrgUnit(organizationalUnit); doReturn(promises.resolve()).when(sectionManager).validateAll(); final Section<SpaceScreenModel> section1 = createSectionMock(); final Section<SpaceScreenModel> section2 = createSectionMock(); doReturn(promises.resolve()).when(section1).save(any(), any()); doReturn(promises.resolve()).when(section2).save(any(), any()); doReturn(promises.resolve()).when(sectionManager).resetAllDirtyIndicators(); doReturn(new ArrayList<>(Arrays.asList(section1, section2))).when(sectionManager).getSections(); presenter.save(); verify(sectionManager, never()).goTo(any()); }
@Test public void saveWhenNotAllowedTest() { doReturn(false).when(organizationalUnitController).canUpdateOrgUnit(organizationalUnit); doReturn(promises.resolve()).when(sectionManager).validateAll(); presenter.save(); verify(sectionManager, never()).goTo(any()); }