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());
}
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());
}
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;
}
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");
}
Aggregations