Search in sources :

Example 1 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 testUpdateDirtyIndicatorNonexistentSection.

@Test
public void testUpdateDirtyIndicatorNonexistentSection() {
    final Section section = newMockedSection();
    settingsPresenter.originalHashCodes = new HashMap<>();
    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 2 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 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());
}
Also used : Section(org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section) Test(org.junit.Test)

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

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

Example 5 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 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);
}
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