Search in sources :

Example 11 with KSessionModel

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

the class KnowledgeSessionListItemPresenterTest method testSetType.

@Test
public void testSetType() {
    final KSessionModel kSessionModel = new KSessionModel();
    final KnowledgeSessionsModal parentPresenter = mock(KnowledgeSessionsModal.class);
    knowledgeSessionListItemPresenter.parentPresenter = parentPresenter;
    knowledgeSessionListItemPresenter.kSessionModel = kSessionModel;
    knowledgeSessionListItemPresenter.setType("Type");
    Assert.assertEquals("Type", kSessionModel.getType());
    verify(parentPresenter).fireChangeEvent();
}
Also used : KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) Test(org.junit.Test)

Example 12 with KSessionModel

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

the class KnowledgeSessionListItemPresenterTest method testSetName.

@Test
public void testSetName() {
    final KSessionModel kSessionModel = new KSessionModel();
    final KnowledgeSessionsModal parentPresenter = mock(KnowledgeSessionsModal.class);
    knowledgeSessionListItemPresenter.parentPresenter = parentPresenter;
    knowledgeSessionListItemPresenter.kSessionModel = kSessionModel;
    knowledgeSessionListItemPresenter.setName("Name");
    Assert.assertEquals("Name", kSessionModel.getName());
    verify(parentPresenter).fireChangeEvent();
}
Also used : KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) Test(org.junit.Test)

Example 13 with KSessionModel

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

the class KnowledgeSessionListItemPresenterTest method testAddListener.

@Test
public void testAddListener() {
    doNothing().when(knowledgeSessionListItemPresenter).fireChangeEvent();
    knowledgeSessionListItemPresenter.kSessionModel = new KSessionModel();
    knowledgeSessionListItemPresenter.addListener();
    verify(listenersListPresenter).add(any());
    verify(knowledgeSessionListItemPresenter).signalListenerAddedOrRemoved();
    verify(knowledgeSessionListItemPresenter).fireChangeEvent();
}
Also used : KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) Test(org.junit.Test)

Example 14 with KSessionModel

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

the class KnowledgeSessionsModalTest method testNewKSessionModelNonEmptyList.

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

Example 15 with KSessionModel

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

the class KBaseConverter method unmarshal.

public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingContext context) {
    final KBaseModel kBase = new KBaseModel();
    kBase.setName(reader.getAttribute("name"));
    kBase.setDefault("true".equals(reader.getAttribute("default")));
    String eventMode = reader.getAttribute("eventProcessingMode");
    if (eventMode != null) {
        kBase.setEventProcessingMode(EventProcessingOption.determineEventProcessingMode(eventMode));
    }
    String equalsBehavior = reader.getAttribute("equalsBehavior");
    if (equalsBehavior != null) {
        kBase.setEqualsBehavior(AssertBehaviorOption.determineAssertBehaviorMode(equalsBehavior));
    }
    String declarativeAgenda = reader.getAttribute("declarativeAgenda");
    if (declarativeAgenda != null) {
        kBase.setDeclarativeAgenda(DeclarativeAgendaOption.determineDeclarativeAgendaMode(declarativeAgenda));
    }
    String scope = reader.getAttribute("scope");
    if (scope != null) {
        kBase.setScope(scope.trim());
    }
    String pkgs = reader.getAttribute("packages");
    if (pkgs != null) {
        for (String pkg : pkgs.split(",")) {
            kBase.addPackage(pkg.trim());
        }
    }
    String includes = reader.getAttribute("includes");
    if (includes != null) {
        for (String include : includes.split(",")) {
            kBase.addInclude(include.trim());
        }
    }
    readNodes(reader, new AbstractXStreamConverter.NodeReader() {

        public void onNode(HierarchicalStreamReader reader, String name, String value) {
            if ("ksession".equals(name)) {
                KSessionModel kSession = readObject(reader, context, KSessionModel.class);
                kBase.getKSessions().add(kSession);
            } else if ("includes".equals(name)) {
                for (String include : readList(reader)) {
                    kBase.addInclude(include);
                }
            }
        }
    });
    return kBase;
}
Also used : KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) HierarchicalStreamReader(com.thoughtworks.xstream.io.HierarchicalStreamReader) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) AbstractXStreamConverter(org.drools.core.util.AbstractXStreamConverter)

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