use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testSetupSectionsWithAllErrors.
@Test
public void testSetupSectionsWithAllErrors() {
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());
doThrow(new RuntimeException("Test exception")).when(section2).setup(any());
settingsPresenter.setupSections(mock(ProjectScreenModel.class)).then(i -> {
fail("Promise should've not been resolved!");
return promises.resolve();
});
assertTrue(settingsPresenter.sections.isEmpty());
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 testUpdateDirtyIndicatorExistentDirtySection.
@Test
public void testUpdateDirtyIndicatorExistentDirtySection() {
final Section section = newMockedSection();
doReturn(42).when(section).currentHashCode();
settingsPresenter.sections = new ArrayList<>(Arrays.asList(section));
settingsPresenter.originalHashCodes = new HashMap<>();
settingsPresenter.originalHashCodes.put(section, 32);
settingsPresenter.updateDirtyIndicator(section);
verify(section).setDirty(true);
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testSaveWithFirstSectionException.
@Test
public void testSaveWithFirstSectionException() {
final Section section1 = newMockedSection();
final Section section2 = newMockedSection();
final RuntimeException testException = new RuntimeException("Test exception");
doThrow(testException).when(section1).save(any(), any());
doReturn(promises.resolve()).when(section2).save(any(), any());
doReturn(promises.resolve()).when(settingsPresenter).defaultErrorResolution(testException);
settingsPresenter.sections = new ArrayList<>(Arrays.asList(section1, section2));
settingsPresenter.save("Test comment");
verify(section1).save(eq("Test comment"), any());
verify(section2, never()).save(any(), any());
verify(settingsPresenter).defaultErrorResolution(eq(testException));
verify(settingsPresenter, never()).saveProjectScreenModel(any(), any(), any());
verify(settingsPresenter, never()).resetDirtyIndicator(any());
verify(settingsPresenter, never()).displaySuccessMessage();
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testSaveWithFirstSectionRejection.
@Test
public void testSaveWithFirstSectionRejection() {
final Section section1 = newMockedSection();
final Section section2 = newMockedSection();
doReturn(promises.reject(section1)).when(section1).save(any(), any());
doReturn(promises.resolve()).when(section2).save(any(), any());
settingsPresenter.sections = new ArrayList<>(Arrays.asList(section1, section2));
settingsPresenter.save("Test comment");
verify(section1).save(eq("Test comment"), any());
verify(section2, never()).save(any(), any());
verify(settingsPresenter).goTo(eq(section1));
verify(settingsPresenter, never()).saveProjectScreenModel(any(), any(), any());
verify(settingsPresenter, never()).resetDirtyIndicator(any());
verify(settingsPresenter, never()).displaySuccessMessage();
}
use of org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section in project kie-wb-common by kiegroup.
the class SettingsPresenterTest method testResetDirtyIndicator.
@Test
public void testResetDirtyIndicator() {
final Map<Section, Integer> hashes = new HashMap<>();
final Section section = newMockedSection();
doReturn(42).when(section).currentHashCode();
settingsPresenter.originalHashCodes = hashes;
settingsPresenter.resetDirtyIndicator(section);
assertEquals((Integer) 42, hashes.get(section));
verify(settingsPresenter).updateDirtyIndicator(eq(section));
}
Aggregations