Search in sources :

Example 16 with Section

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());
}
Also used : Section(org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section) Test(org.junit.Test)

Example 17 with Section

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);
}
Also used : Section(org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section) Test(org.junit.Test)

Example 18 with Section

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));
}
Also used : Section(org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section) Test(org.junit.Test)

Example 19 with Section

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());
}
Also used : ArrayList(java.util.ArrayList) Section(org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section) Test(org.junit.Test)

Example 20 with Section

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());
}
Also used : Section(org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section) Test(org.junit.Test)

Aggregations

Section (org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section)21 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1