Search in sources :

Example 21 with KBaseModel

use of org.kie.workbench.common.services.shared.kmodule.KBaseModel in project kie-wb-common by kiegroup.

the class KSessionSelector method initKBases.

private void initKBases(final String currentKSession) {
    final ArrayList<String> kbaseNames = new ArrayList<>();
    if (kmodule.getKBases().isEmpty()) {
        addMockKBaseModel(DEFAULT_KIE_BASE, DEFAULT_KIE_SESSION);
        kbaseNames.add(DEFAULT_KIE_BASE);
    } else {
        for (KBaseModel kBase : kmodule.getKBases().values()) {
            kbaseNames.add(kBase.getName());
        }
    }
    Collections.sort(kbaseNames, (first, other) -> first.compareToIgnoreCase(other));
    if (isNotNullOrEmpty(currentKSession) && !kmoduleContainsCurrentKSession(currentKSession)) {
        addMockKBaseModel(NON_EXISTING_KBASE, currentKSession);
        kbaseNames.add(NON_EXISTING_KBASE);
        view.showWarningSelectedKSessionDoesNotExist();
    }
    view.addKBases(kbaseNames.toArray(new String[kbaseNames.size()]));
}
Also used : ArrayList(java.util.ArrayList) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel)

Example 22 with KBaseModel

use of org.kie.workbench.common.services.shared.kmodule.KBaseModel in project kie-wb-common by kiegroup.

the class KnowledgeBasesPresenterTest method testSave.

@Test
public void testSave() {
    final KModuleModel kModuleModel = spy(new KModuleModel());
    knowledgeBasesPresenter.kModuleModel = kModuleModel;
    final Map<String, KBaseModel> kBasesMap = spy(new HashMap<>());
    doReturn(kBasesMap).when(kModuleModel).getKBases();
    knowledgeBasesPresenter.save("Test comment", null).catch_(i -> {
        Assert.fail("Promise should've been resolved!");
        return promises.resolve();
    });
    verify(kBasesMap).clear();
    verify(kBasesMap).putAll(any());
}
Also used : KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 23 with KBaseModel

use of org.kie.workbench.common.services.shared.kmodule.KBaseModel in project kie-wb-common by kiegroup.

the class KnowledgeBaseItemPresenterTest method testSignalAddedOrRemoved.

@Test
public void testSignalAddedOrRemoved() {
    final KBaseModel kBaseModel = new KBaseModel();
    final KnowledgeBasesPresenter parentPresenter = mock(KnowledgeBasesPresenter.class);
    knowledgeBaseItemPresenter.kBaseModel = kBaseModel;
    knowledgeBaseItemPresenter.parentPresenter = parentPresenter;
    knowledgeBaseItemPresenter.signalAddedOrRemoved();
    verify(parentPresenter).fireChangeEvent();
    verify(view).setKnowledgeSessionsCount(eq(0));
}
Also used : KnowledgeBasesPresenter(org.kie.workbench.common.screens.library.client.settings.knowledgebases.KnowledgeBasesPresenter) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) Test(org.junit.Test)

Example 24 with KBaseModel

use of org.kie.workbench.common.services.shared.kmodule.KBaseModel in project kie-wb-common by kiegroup.

the class KnowledgeBaseItemPresenterTest method testSetDefault.

@Test
public void testSetDefault() {
    final KBaseModel kBaseModel = new KBaseModel();
    kBaseModel.setDefault(false);
    final KnowledgeBasesPresenter parentPresenter = mock(KnowledgeBasesPresenter.class);
    knowledgeBaseItemPresenter.kBaseModel = kBaseModel;
    knowledgeBaseItemPresenter.parentPresenter = parentPresenter;
    knowledgeBaseItemPresenter.setDefault(true);
    Assert.assertTrue(kBaseModel.isDefault());
    verify(defaultKnowledgeBaseChangeEvent).fire(any());
    verify(parentPresenter).fireChangeEvent();
}
Also used : KnowledgeBasesPresenter(org.kie.workbench.common.screens.library.client.settings.knowledgebases.KnowledgeBasesPresenter) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) Test(org.junit.Test)

Example 25 with KBaseModel

use of org.kie.workbench.common.services.shared.kmodule.KBaseModel in project kie-wb-common by kiegroup.

the class KnowledgeSessionListItemPresenterTest method testOnDefaultKnowledgeSessionChangedWithAnotherKSessionModel.

@Test
public void testOnDefaultKnowledgeSessionChangedWithAnotherKSessionModel() {
    final KBaseModel kBaseModel = new KBaseModel();
    final KSessionModel kSessionModel = new KSessionModel();
    kSessionModel.setDefault(true);
    final KnowledgeSessionsModal parentPresenter = mock(KnowledgeSessionsModal.class);
    doReturn(kBaseModel).when(parentPresenter).getObject();
    knowledgeSessionListItemPresenter.parentPresenter = parentPresenter;
    knowledgeSessionListItemPresenter.kSessionModel = kSessionModel;
    final KSessionModel anotherKSessionModel = new KSessionModel();
    anotherKSessionModel.setName("Distinguishing name");
    knowledgeSessionListItemPresenter.onDefaultKnowledgeSessionChanged(new DefaultKnowledgeSessionChange(kBaseModel, anotherKSessionModel));
    Assert.assertEquals(false, kSessionModel.isDefault());
}
Also used : KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) Test(org.junit.Test)

Aggregations

KBaseModel (org.kie.workbench.common.services.shared.kmodule.KBaseModel)38 Test (org.junit.Test)27 KSessionModel (org.kie.workbench.common.services.shared.kmodule.KSessionModel)12 KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)6 KnowledgeBasesPresenter (org.kie.workbench.common.screens.library.client.settings.sections.knowledgebases.KnowledgeBasesPresenter)5 KnowledgeBasesPresenter (org.kie.workbench.common.screens.library.client.settings.knowledgebases.KnowledgeBasesPresenter)3 HierarchicalStreamReader (com.thoughtworks.xstream.io.HierarchicalStreamReader)2 AbstractXStreamConverter (org.drools.core.util.AbstractXStreamConverter)2 SingleValueItemObjectModel (org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 RuntimeStrategy (org.kie.internal.runtime.conf.RuntimeStrategy)1 KnowledgeBaseItemPresenter (org.kie.workbench.common.screens.library.client.settings.knowledgebases.item.KnowledgeBaseItemPresenter)1 KnowledgeBaseItemPresenter (org.kie.workbench.common.screens.library.client.settings.sections.knowledgebases.item.KnowledgeBaseItemPresenter)1 ProcessConfigModule (org.kie.workbench.common.screens.server.management.model.ProcessConfigModule)1 RuntimeStrategy (org.kie.workbench.common.screens.server.management.model.RuntimeStrategy)1 KModuleContentHandler (org.kie.workbench.common.services.backend.kmodule.KModuleContentHandler)1 ConsoleLogger (org.kie.workbench.common.services.shared.kmodule.ConsoleLogger)1 FileLogger (org.kie.workbench.common.services.shared.kmodule.FileLogger)1