Search in sources :

Example 1 with ProcessConfigModule

use of org.kie.workbench.common.screens.server.management.model.ProcessConfigModule in project kie-wb-common by kiegroup.

the class DeploymentDescriptorServiceCDITest method testGetProcessConfig.

@Test
public void testGetProcessConfig() throws IOException {
    ProcessConfigModule processConfigModule = deploymentDescriptorServiceCDI.getProcessConfig(path + RUNTIME_STRATEGY_SINGLETON);
    assertEquals(RuntimeStrategy.SINGLETON, processConfigModule.getRuntimeStrategy());
    assertEquals("myKie", processConfigModule.getKBase());
    assertEquals("kiesession", processConfigModule.getKSession());
    assertEquals(RuntimeStrategy.PER_PROCESS_INSTANCE, deploymentDescriptorServiceCDI.getProcessConfig(path + RUNTIME_STRATEGY_PER_PROCESS_INSTANCE).getRuntimeStrategy());
    assertEquals(RuntimeStrategy.PER_CASE, deploymentDescriptorServiceCDI.getProcessConfig(path + RUNTIME_STRATEGY_PER_CASE).getRuntimeStrategy());
    assertEquals(RuntimeStrategy.PER_REQUEST, deploymentDescriptorServiceCDI.getProcessConfig(path + RUNTIME_STRATEGY_PER_REQUEST).getRuntimeStrategy());
}
Also used : ProcessConfigModule(org.kie.workbench.common.screens.server.management.model.ProcessConfigModule) Test(org.junit.Test)

Example 2 with ProcessConfigModule

use of org.kie.workbench.common.screens.server.management.model.ProcessConfigModule in project kie-wb-common by kiegroup.

the class DeploymentDescriptorServiceCDITest method testProcessConfigModule.

@Test
public void testProcessConfigModule() {
    ProcessConfigModule processConfigModuleSingleton = new ProcessConfigModule();
    processConfigModuleSingleton.setKSession("test-session");
    processConfigModuleSingleton.setRuntimeStrategy(RuntimeStrategy.SINGLETON);
    processConfigModuleSingleton.setKBase("test-kbase");
    ProcessConfigModule processConfigModulePerProcessInstance = new ProcessConfigModule();
    processConfigModulePerProcessInstance.setKSession("test-session");
    processConfigModulePerProcessInstance.setRuntimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE);
    processConfigModulePerProcessInstance.setKBase("test-kbase");
    assertNotEquals(processConfigModuleSingleton, processConfigModulePerProcessInstance);
    assertNotEquals(processConfigModuleSingleton.hashCode(), processConfigModulePerProcessInstance.hashCode());
    assertEquals("ProcessConfigModule{runtimeStrategy=SINGLETON, kBase='test-kbase', kSession='test-session'}", processConfigModuleSingleton.toString());
}
Also used : ProcessConfigModule(org.kie.workbench.common.screens.server.management.model.ProcessConfigModule) Test(org.junit.Test)

Example 3 with ProcessConfigModule

use of org.kie.workbench.common.screens.server.management.model.ProcessConfigModule in project kie-wb-common by kiegroup.

the class DeploymentDescriptorServiceCDI method getProcessConfig.

@Override
public ProcessConfigModule getProcessConfig(String path) throws IOException {
    ProcessConfigModule processConfig = new ProcessConfigModule();
    KModuleContentHandler kModuleContentHandler = new KModuleContentHandler();
    try (InputStream in = IOUtils.toInputStream(guvnorM2Repository.getKieDeploymentDescriptorText(path), StandardCharsets.UTF_8)) {
        RuntimeStrategy runtimeStrategy = DeploymentDescriptorIO.fromXml(in).getRuntimeStrategy();
        switch(runtimeStrategy) {
            case SINGLETON:
                processConfig.setRuntimeStrategy(SINGLETON);
                break;
            case PER_CASE:
                processConfig.setRuntimeStrategy(PER_CASE);
                break;
            case PER_PROCESS_INSTANCE:
                processConfig.setRuntimeStrategy(PER_PROCESS_INSTANCE);
                break;
            case PER_REQUEST:
                processConfig.setRuntimeStrategy(PER_REQUEST);
                break;
        }
    }
    Map<String, KBaseModel> kBaseModelHashMap = kModuleContentHandler.toModel(guvnorM2Repository.getKModuleText(path)).getKBases();
    KBaseModel defaultKBaseModel = null;
    Optional<KBaseModel> optionalKBaseModel = kBaseModelHashMap.values().stream().filter(KBaseModel::isDefault).findFirst();
    if (optionalKBaseModel.isPresent()) {
        defaultKBaseModel = optionalKBaseModel.get();
    }
    if (defaultKBaseModel != null) {
        processConfig.setKBase(defaultKBaseModel.getName());
        Optional<KSessionModel> optionalKSessionModel = defaultKBaseModel.getKSessions().stream().filter(KSessionModel::isDefault).findFirst();
        KSessionModel defaultKSessionModel = null;
        if (optionalKSessionModel.isPresent()) {
            defaultKSessionModel = optionalKSessionModel.get();
            processConfig.setKSession(defaultKSessionModel.getName());
        }
    }
    return processConfig;
}
Also used : ProcessConfigModule(org.kie.workbench.common.screens.server.management.model.ProcessConfigModule) InputStream(java.io.InputStream) RuntimeStrategy(org.kie.internal.runtime.conf.RuntimeStrategy) RuntimeStrategy(org.kie.workbench.common.screens.server.management.model.RuntimeStrategy) KSessionModel(org.kie.workbench.common.services.shared.kmodule.KSessionModel) KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) KModuleContentHandler(org.kie.workbench.common.services.backend.kmodule.KModuleContentHandler)

Example 4 with ProcessConfigModule

use of org.kie.workbench.common.screens.server.management.model.ProcessConfigModule in project kie-wb-common by kiegroup.

the class ProcessConfigPresenterTest method testOnDependencyPathSelectedEvent.

@Test
public void testOnDependencyPathSelectedEvent() throws IOException {
    final String path = "org:kie:1.0";
    when(deploymentDescriptorService.getProcessConfig(path)).thenReturn(new ProcessConfigModule(RuntimeStrategy.SINGLETON, "mykiebase", "mykiesession"));
    presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent("", path));
    verify(view).setContent("ClientRuntimeStrategy.Singleton", "mykiebase", "mykiesession", "ClientMergeMode.MergeCollections");
}
Also used : ProcessConfigModule(org.kie.workbench.common.screens.server.management.model.ProcessConfigModule) DependencyPathSelectedEvent(org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent) Test(org.junit.Test)

Aggregations

ProcessConfigModule (org.kie.workbench.common.screens.server.management.model.ProcessConfigModule)4 Test (org.junit.Test)3 InputStream (java.io.InputStream)1 RuntimeStrategy (org.kie.internal.runtime.conf.RuntimeStrategy)1 DependencyPathSelectedEvent (org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent)1 RuntimeStrategy (org.kie.workbench.common.screens.server.management.model.RuntimeStrategy)1 KModuleContentHandler (org.kie.workbench.common.services.backend.kmodule.KModuleContentHandler)1 KBaseModel (org.kie.workbench.common.services.shared.kmodule.KBaseModel)1 KSessionModel (org.kie.workbench.common.services.shared.kmodule.KSessionModel)1