use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testSetupSectionsWithOneError.
@Test
public void testSetupSectionsWithOneError() {
final Section section1 = newMockedSection();
final Section section2 = newMockedSection();
settingsPresenter.sections = new ArrayList<>(Arrays.asList(section1, section2));
doThrow(new RuntimeException("Test exception")).when(section1).setup(any());
doReturn(promises.resolve()).when(section2).setup(any());
settingsPresenter.setupSections(mock(ProjectScreenModel.class)).catch_(i -> {
fail("Promise should've been resolved!");
return promises.resolve();
});
assertEquals(singletonList(section2), 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 testGoTo.
@Test
public void testGoTo() {
final Section section = newMockedSection();
settingsPresenter.goTo(section);
assertEquals(section, settingsPresenter.currentSection);
verify(view).setSection(eq(section.getView()));
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testOnSettingsSectionChanged.
@Test
public void testOnSettingsSectionChanged() {
final Section section = newMockedSection();
settingsPresenter.originalHashCodes = new HashMap<>();
settingsPresenter.onSettingsSectionChanged(new SettingsSectionChange(section));
verify(settingsPresenter).updateDirtyIndicator(eq(section));
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testShowSaveModalWithValidationException.
@Test
public void testShowSaveModalWithValidationException() {
final Section section1 = newMockedSection();
final Section section2 = newMockedSection();
final RuntimeException testException = new RuntimeException("Test exception");
settingsPresenter.sections = new ArrayList<>(Arrays.asList(section1, section2));
doThrow(testException).when(section1).validate();
doReturn(promises.resolve()).when(section2).validate();
doReturn(promises.resolve()).when(settingsPresenter).defaultErrorResolution(any());
settingsPresenter.showSaveModal();
verify(section1).validate();
verify(section2, never()).validate();
verify(view, never()).hideBusyIndicator();
verify(savePopUpPresenter, never()).show(any());
verify(settingsPresenter, never()).goTo(section1);
verify(settingsPresenter).defaultErrorResolution(testException);
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testSetupSectionRejected.
@Test
public void testSetupSectionRejected() {
final Section section = newMockedSection();
settingsPresenter.sections = new ArrayList<>(singletonList(section));
doReturn(promises.reject(section)).when(section).setup(any());
doReturn("Message").when(settingsPresenter).getSectionSetupErrorMessage(eq(section));
settingsPresenter.setupSection(mock(ProjectScreenModel.class), section).catch_(i -> {
fail("Promise should've been resolved!");
return promises.resolve();
});
assertFalse(settingsPresenter.sections.contains(section));
assertTrue(settingsPresenter.sections.isEmpty());
verify(section).setup(any());
verify(notificationEvent).fire(any());
verify(section.getMenuItem(), never()).setup(any(), any());
verify(settingsPresenter, never()).resetDirtyIndicator(section);
}
Aggregations