use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testUpdateDirtyIndicatorNonexistentSection.
@Test
public void testUpdateDirtyIndicatorNonexistentSection() {
final Section section = newMockedSection();
settingsPresenter.originalHashCodes = new HashMap<>();
settingsPresenter.updateDirtyIndicator(section);
verify(section).setDirty(false);
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testSetupWithSection.
@Test
public void testSetupWithSection() {
final Section section = newMockedSection();
settingsPresenter.sections = new ArrayList<>(singletonList(section));
doNothing().when(settingsPresenter).setupMenuItems();
doReturn(promises.resolve()).when(settingsPresenter).setupSections(any());
settingsPresenter.setup(section).catch_(i -> {
fail("Promise should've been resolved!");
return promises.resolve();
});
assertEquals(section, settingsPresenter.currentSection);
verify(view).init(eq(settingsPresenter));
verify(projectScreenService).load(any());
verify(settingsPresenter).setupSections(any());
verify(settingsPresenter).setupMenuItems();
verify(settingsPresenter).goTo(eq(section));
verify(notificationEvent, never()).fire(any());
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testSetupSection.
@Test
public void testSetupSection() {
final Section section = newMockedSection();
final List<Section> sections = new ArrayList<>(singletonList(section));
settingsPresenter.sections = sections;
doReturn(promises.resolve()).when(section).setup(any());
settingsPresenter.setupSection(mock(ProjectScreenModel.class), section).catch_(i -> {
fail("Promise should've been resolved!");
return promises.resolve();
});
assertEquals(sections, settingsPresenter.sections);
verify(section).setup(any());
verify(section.getMenuItem()).setup(any(), any());
verify(settingsPresenter).resetDirtyIndicator(section);
verify(notificationEvent, never()).fire(any());
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method newMockedSection.
private Section newMockedSection() {
final Section section = mock(Section.class);
doReturn(mock(SettingsPresenter.MenuItem.class)).when(section).getMenuItem();
doReturn(promises.resolve()).when(section).setup(any());
doReturn(promises.resolve()).when(section).save(any(), any());
return section;
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testShowSaveModalWithValidationError.
@Test
public void testShowSaveModalWithValidationError() {
final Section section1 = newMockedSection();
final Section section2 = newMockedSection();
settingsPresenter.sections = new ArrayList<>(Arrays.asList(section1, section2));
doReturn(promises.reject(section1)).when(section1).validate();
doReturn(promises.resolve()).when(section2).validate();
settingsPresenter.showSaveModal();
verify(section1).validate();
verify(section2, never()).validate();
verify(view).hideBusyIndicator();
verify(savePopUpPresenter, never()).show(any());
verify(settingsPresenter).goTo(section1);
}
Aggregations