Search in sources :

Example 31 with KBaseModel

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

the class KModuleContentHandlerTest method testConsoleLogger.

@Test
public void testConsoleLogger() throws Exception {
    final KModuleContentHandler kModuleContentHandler = new KModuleContentHandler();
    final KModuleModel model = kModuleContentHandler.toModel(readResource("consoleLoggerKModule.xml"));
    assertNotNull(model);
    assertEquals(1, model.getKBases().size());
    final KBaseModel kBaseModel = model.getKBases().get("org.kie.example2");
    assertNotNull(kBaseModel);
    assertEquals(1, kBaseModel.getKSessions().size());
    final KSessionModel kSessionModel = kBaseModel.getKSessions().get(0);
    assertEquals("ksession2", kSessionModel.getName());
    assertEquals("stateless", kSessionModel.getType());
    assertFalse(kSessionModel.isDefault());
    assertEquals(ClockTypeOption.PSEUDO, kSessionModel.getClockType());
    assertTrue(kSessionModel.getLogger() instanceof ConsoleLogger);
    final String xml = kModuleContentHandler.toString(model);
    assertTrue(xml.contains("<kbase name=\"org.kie.example2\" default=\"false\" eventProcessingMode=\"stream\" equalsBehavior=\"identity\">"));
    assertTrue(xml.contains("<ksession name=\"ksession2\" type=\"stateless\" default=\"false\" clockType=\"pseudo\">"));
    assertTrue(xml.contains("<consoleLogger/>"));
}
Also used : ConsoleLogger(org.kie.workbench.common.services.shared.kmodule.ConsoleLogger) KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 32 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.sections.knowledgebases.KnowledgeBasesPresenter) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) Test(org.junit.Test)

Example 33 with KBaseModel

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

the class KnowledgeBaseItemPresenterTest method testSetup.

@Test
public void testSetup() {
    final KnowledgeBaseItemPresenter setup = knowledgeBaseItemPresenter.setup(new KBaseModel(), mock(KnowledgeBasesPresenter.class));
    Assert.assertEquals(setup, knowledgeBaseItemPresenter);
    verify(view).setKnowledgeSessionsCount(anyInt());
    verify(view).setDefault(anyBoolean());
    verify(view).setName(any());
    verify(knowledgeSessionsModal).setup(any());
    verify(packageListPresenter).setup(any(), any(), any());
    verify(includedKnowledgeBasesListPresenter).setup(any(), any(), any());
    verify(view).setupEventProcessingModelSelect(any());
    verify(view).setupEqualBehaviorSelect(any());
}
Also used : KnowledgeBasesPresenter(org.kie.workbench.common.screens.library.client.settings.sections.knowledgebases.KnowledgeBasesPresenter) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) Test(org.junit.Test)

Example 34 with KBaseModel

use of org.kie.workbench.common.services.shared.kmodule.KBaseModel 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 35 with KBaseModel

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

the class KnowledgeBasesPresenterTest method testNewKBaseModelNonEmptyMap.

@Test
public void testNewKBaseModelNonEmptyMap() {
    doReturn(singletonList(new KBaseModel())).when(knowledgeBaseListPresenter).getObjectsList();
    final KBaseModel kBaseModel = knowledgeBasesPresenter.newKBaseModel("Name");
    Assert.assertEquals("Name", kBaseModel.getName());
    Assert.assertEquals(false, kBaseModel.isDefault());
}
Also used : 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