Search in sources :

Example 1 with KSessionModel

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

the class KSessionSelector method selectFirstKBaseAndKSession.

private void selectFirstKBaseAndKSession() {
    KBaseModel firstKBase = kmodule.getKBases().values().iterator().next();
    List<KSessionModel> ksessions = firstKBase.getKSessions();
    listKSessions(ksessions);
    view.setSelected(firstKBase.getName(), ksessions.iterator().next().getName());
}
Also used : KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel)

Example 2 with KSessionModel

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

the class KnowledgeSessionListItemPresenterTest method testOnDefaultKnowledgeSessionChanged.

@Test
public void testOnDefaultKnowledgeSessionChanged() {
    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;
    knowledgeSessionListItemPresenter.onDefaultKnowledgeSessionChanged(new DefaultKnowledgeSessionChange(kBaseModel, kSessionModel));
    Assert.assertTrue(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)

Example 3 with KSessionModel

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

the class KnowledgeSessionListItemPresenterTest method testSetDefault.

@Test
public void testSetDefault() {
    final KSessionModel kSessionModel = new KSessionModel();
    kSessionModel.setDefault(false);
    final KnowledgeSessionsModal parentPresenter = mock(KnowledgeSessionsModal.class);
    knowledgeSessionListItemPresenter.parentPresenter = parentPresenter;
    knowledgeSessionListItemPresenter.kSessionModel = kSessionModel;
    knowledgeSessionListItemPresenter.setDefault(true);
    Assert.assertTrue(kSessionModel.isDefault());
    verify(defaultKnowledgeSessionChangeEvent).fire(any());
    verify(parentPresenter).fireChangeEvent();
}
Also used : KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) Test(org.junit.Test)

Example 4 with KSessionModel

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

the class KnowledgeSessionsModalTest method testNewKSessionModelEmptyList.

@Test
public void testNewKSessionModelEmptyList() {
    doReturn(emptyList()).when(knowledgeBasesListPresenter).getObjectsList();
    final KSessionModel kSessionModel = knowledgeSessionsModal.newKSessionModel();
    Assert.assertEquals("", kSessionModel.getName());
    Assert.assertTrue(kSessionModel.isDefault());
}
Also used : KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) Test(org.junit.Test)

Example 5 with KSessionModel

use of org.kie.workbench.common.services.shared.kmodule.KSessionModel 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)

Aggregations

KSessionModel (org.kie.workbench.common.services.shared.kmodule.KSessionModel)18 Test (org.junit.Test)9 KBaseModel (org.kie.workbench.common.services.shared.kmodule.KBaseModel)7 HierarchicalStreamReader (com.thoughtworks.xstream.io.HierarchicalStreamReader)2 AbstractXStreamConverter (org.drools.core.util.AbstractXStreamConverter)2 ArrayList (java.util.ArrayList)1 WorkItemHandlerModel (org.guvnor.common.services.project.model.WorkItemHandlerModel)1 ListenerModel (org.kie.workbench.common.services.shared.kmodule.ListenerModel)1