Search in sources :

Example 11 with KBaseModel

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

the class KnowledgeBasesPresenter method newKBaseModel.

KBaseModel newKBaseModel(final String knowledgeBaseName) {
    final KBaseModel kBaseModel = new KBaseModel();
    kBaseModel.setName(knowledgeBaseName);
    kBaseModel.setDefault(knowledgeBaseListPresenter.getObjectsList().isEmpty());
    return kBaseModel;
}
Also used : KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel)

Example 12 with KBaseModel

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

the class KSessionSelector method selectFromModel.

private void selectFromModel(final String currentKSession) {
    for (KBaseModel kbase : kmodule.getKBases().values()) {
        for (KSessionModel ksession : kbase.getKSessions()) {
            if (ksession.getName().equals(currentKSession)) {
                listKSessions(kmodule.getKBases().get(kbase.getName()).getKSessions());
                view.setSelected(kbase.getName(), currentKSession);
                break;
            }
        }
    }
}
Also used : KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel)

Example 13 with KBaseModel

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

the class KSessionSelector method addMockKBaseModel.

private void addMockKBaseModel(final String kbaseName, final String ksessionsName) {
    KBaseModel kbaseModel = new KBaseModel();
    kbaseModel.setName(kbaseName);
    KSessionModel ksessionModel = new KSessionModel();
    ksessionModel.setName(ksessionsName);
    kbaseModel.getKSessions().add(ksessionModel);
    kmodule.getKBases().put(kbaseName, kbaseModel);
}
Also used : KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel)

Example 14 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 15 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)

Aggregations

KBaseModel (org.kie.workbench.common.services.shared.kmodule.KBaseModel)20 Test (org.junit.Test)11 KSessionModel (org.kie.workbench.common.services.shared.kmodule.KSessionModel)7 KnowledgeBasesPresenter (org.kie.workbench.common.screens.library.client.settings.knowledgebases.KnowledgeBasesPresenter)3 KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)3 HierarchicalStreamReader (com.thoughtworks.xstream.io.HierarchicalStreamReader)2 AbstractXStreamConverter (org.drools.core.util.AbstractXStreamConverter)2 KnowledgeBaseItemPresenter (org.kie.workbench.common.screens.library.client.settings.knowledgebases.item.KnowledgeBaseItemPresenter)1