use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testShowSaveModal.
@Test
public void testShowSaveModal() {
final Section section1 = newMockedSection();
final Section section2 = newMockedSection();
settingsPresenter.sections = new ArrayList<>(Arrays.asList(section1, section2));
doReturn(promises.resolve()).when(section1).validate();
doReturn(promises.resolve()).when(section2).validate();
settingsPresenter.showSaveModal();
verify(section1).validate();
verify(section2).validate();
verify(savePopUpPresenter).show(any());
verify(settingsPresenter, never()).goTo(any());
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testUpdateDirtyIndicatorExistentNotDirtySection.
@Test
public void testUpdateDirtyIndicatorExistentNotDirtySection() {
final Section section = newMockedSection();
doReturn(42).when(section).currentHashCode();
settingsPresenter.sections = new ArrayList<>(Arrays.asList(section));
settingsPresenter.originalHashCodes = new HashMap<>();
settingsPresenter.originalHashCodes.put(section, 42);
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 testSetup.
@Test
public void testSetup() {
final Section section1 = newMockedSection();
final Section section2 = newMockedSection();
final List<Section> sections = Arrays.asList(section1, section2);
doReturn(sections).when(settingsSections).getList();
doReturn(promises.resolve()).when(settingsPresenter).setup(section1);
doNothing().when(settingsPresenter).setActiveMenuItem();
settingsPresenter.setup();
verify(settingsPresenter, times(1)).setActiveMenuItem();
assertEquals(2, settingsPresenter.sections.size());
assertTrue(settingsPresenter.sections.containsAll(sections));
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testSetupSections.
@Test
public void testSetupSections() {
final Section section1 = newMockedSection();
final Section section2 = newMockedSection();
final List<Section> sections = new ArrayList<>(Arrays.asList(section1, section2));
settingsPresenter.sections = sections;
doReturn(promises.resolve()).when(settingsPresenter).setupSection(any(), any());
settingsPresenter.setupSections(mock(ProjectScreenModel.class)).catch_(i -> {
fail("Promise should've been resolved!");
return promises.resolve();
});
assertEquals(sections, settingsPresenter.sections);
verify(settingsPresenter, times(2)).setupSection(any(), any());
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testSetupWithOneSectionSetupRejection.
@Test
public void testSetupWithOneSectionSetupRejection() {
final Section section1 = newMockedSection();
final Section section2 = newMockedSection();
settingsPresenter.sections = new ArrayList<>(Arrays.asList(section1, section2));
doReturn(promises.reject("Test")).when(settingsPresenter).setupSections(any());
settingsPresenter.setup(section1).catch_(i -> {
fail("Promise should've been resolved!");
return promises.resolve();
});
// All sections are setup regardless of exceptions/rejections
verify(projectScreenService).load(any());
verify(settingsPresenter).setupSections(any());
verify(settingsPresenter, never()).setupMenuItems();
verify(settingsPresenter, never()).goTo(any());
verify(notificationEvent).fire(any());
}
Aggregations