Search in sources :

Example 1 with RuleConfig

use of org.kie.server.controller.api.model.spec.RuleConfig in project kie-wb-common by kiegroup.

the class ServerTemplateVFSStorageTest method testStoreAndLoadServerTemplates.

@Test
public void testStoreAndLoadServerTemplates() {
    templateStorage.store(serverTemplate);
    Collection<ServerTemplateKey> templateKeys = templateStorage.loadKeys();
    assertNotNull(templateKeys);
    assertEquals(1, templateKeys.size());
    ServerTemplateKey templateKey = templateKeys.iterator().next();
    assertNotNull(templateKey);
    assertEquals(serverTemplate.getId(), templateKey.getId());
    assertEquals(serverTemplate.getName(), templateKey.getName());
    Collection<ServerTemplate> templates = templateStorage.load();
    assertNotNull(templates);
    assertEquals(1, templates.size());
    ServerTemplate template = templates.iterator().next();
    assertNotNull(template);
    assertEquals(serverTemplate.getId(), template.getId());
    assertEquals(serverTemplate.getName(), template.getName());
    Collection<ServerInstanceKey> instances = template.getServerInstanceKeys();
    assertNotNull(instances);
    assertEquals(0, instances.size());
    Collection<ContainerSpec> containerSpecs = template.getContainersSpec();
    assertNotNull(containerSpecs);
    assertEquals(1, containerSpecs.size());
    ContainerSpec spec = containerSpecs.iterator().next();
    assertNotNull(spec);
    assertEquals(containerSpec.getId(), spec.getId());
    assertEquals(containerSpec.getReleasedId(), spec.getReleasedId());
    assertEquals(containerSpec.getServerTemplateKey().getId(), spec.getServerTemplateKey().getId());
    assertEquals(containerSpec.getServerTemplateKey().getName(), spec.getServerTemplateKey().getName());
    assertEquals(containerSpec.getConfigs().size(), spec.getConfigs().size());
    assertTrue(spec.getConfigs().containsKey(Capability.RULE));
    assertTrue(spec.getConfigs().containsKey(Capability.PROCESS));
    RuleConfig ruleConfig = (RuleConfig) spec.getConfigs().get(Capability.RULE);
    assertNotNull(ruleConfig);
    assertEquals(this.ruleConfig.getPollInterval(), ruleConfig.getPollInterval());
    assertEquals(this.ruleConfig.getScannerStatus(), ruleConfig.getScannerStatus());
    ProcessConfig processConfig = (ProcessConfig) spec.getConfigs().get(Capability.PROCESS);
    assertNotNull(processConfig);
    assertEquals(this.processConfig.getKBase(), processConfig.getKBase());
    assertEquals(this.processConfig.getKSession(), processConfig.getKSession());
    assertEquals(this.processConfig.getMergeMode(), processConfig.getMergeMode());
    assertEquals(this.processConfig.getRuntimeStrategy(), processConfig.getRuntimeStrategy());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) Test(org.junit.Test)

Example 2 with RuleConfig

use of org.kie.server.controller.api.model.spec.RuleConfig in project kie-wb-common by kiegroup.

the class ServerTemplateVFSStorageTest method testStoreServerTemplate.

@Test
public void testStoreServerTemplate() {
    templateStorage.store(serverTemplate);
    boolean exists = templateStorage.exists(serverTemplate.getId());
    assertTrue(exists);
    ServerTemplate fromStorage = templateStorage.load(serverTemplate.getId());
    assertNotNull(fromStorage);
    assertEquals(serverTemplate.getId(), fromStorage.getId());
    assertEquals(serverTemplate.getName(), fromStorage.getName());
    Collection<ServerInstanceKey> instances = fromStorage.getServerInstanceKeys();
    assertNotNull(instances);
    assertEquals(0, instances.size());
    Collection<ContainerSpec> containerSpecs = fromStorage.getContainersSpec();
    assertNotNull(containerSpecs);
    assertEquals(1, containerSpecs.size());
    ContainerSpec spec = containerSpecs.iterator().next();
    assertNotNull(spec);
    assertEquals(containerSpec.getId(), spec.getId());
    assertEquals(containerSpec.getReleasedId(), spec.getReleasedId());
    assertEquals(containerSpec.getServerTemplateKey().getId(), spec.getServerTemplateKey().getId());
    assertEquals(containerSpec.getServerTemplateKey().getName(), spec.getServerTemplateKey().getName());
    assertEquals(containerSpec.getConfigs().size(), spec.getConfigs().size());
    assertTrue(spec.getConfigs().containsKey(Capability.RULE));
    assertTrue(spec.getConfigs().containsKey(Capability.PROCESS));
    RuleConfig ruleConfig = (RuleConfig) spec.getConfigs().get(Capability.RULE);
    assertNotNull(ruleConfig);
    assertEquals(this.ruleConfig.getPollInterval(), ruleConfig.getPollInterval());
    assertEquals(this.ruleConfig.getScannerStatus(), ruleConfig.getScannerStatus());
    ProcessConfig processConfig = (ProcessConfig) spec.getConfigs().get(Capability.PROCESS);
    assertNotNull(processConfig);
    assertEquals(this.processConfig.getKBase(), processConfig.getKBase());
    assertEquals(this.processConfig.getKSession(), processConfig.getKSession());
    assertEquals(this.processConfig.getMergeMode(), processConfig.getMergeMode());
    assertEquals(this.processConfig.getRuntimeStrategy(), processConfig.getRuntimeStrategy());
}
Also used : ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) Test(org.junit.Test)

Example 3 with RuleConfig

use of org.kie.server.controller.api.model.spec.RuleConfig in project kie-wb-common by kiegroup.

the class BuildExecutorTest method testMakeConfigsWhenServerTemplateDoesNotHaveProcessCapability.

@Test
public void testMakeConfigsWhenServerTemplateDoesNotHaveProcessCapability() {
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    final RuleConfig ruleConfig = mock(RuleConfig.class);
    doReturn(ruleConfig).when(buildExecutor).makeRuleConfig();
    final Map<Capability, ContainerConfig> configs = buildExecutor.makeConfigs(serverTemplate, new HashMap<>());
    assertTrue(configs.keySet().contains(Capability.RULE));
    assertTrue(configs.values().contains(ruleConfig));
    assertEquals(1, configs.size());
}
Also used : ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) Capability(org.kie.server.controller.api.model.spec.Capability) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) Test(org.junit.Test)

Example 4 with RuleConfig

use of org.kie.server.controller.api.model.spec.RuleConfig in project kie-wb-common by kiegroup.

the class BuildExecutorTest method testMakeConfigsWhenServerTemplateHasProcessCapabilityWithStrategy.

@Test
public void testMakeConfigsWhenServerTemplateHasProcessCapabilityWithStrategy() {
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    final RuleConfig ruleConfig = mock(RuleConfig.class);
    doReturn(ruleConfig).when(buildExecutor).makeRuleConfig();
    doReturn(true).when(buildExecutor).hasProcessCapability(any());
    Map<String, String> params = new HashMap<>();
    params.put("RuntimeStrategy", RuntimeStrategy.PER_PROCESS_INSTANCE.name());
    final Map<Capability, ContainerConfig> configs = buildExecutor.makeConfigs(serverTemplate, params);
    assertTrue(configs.keySet().contains(Capability.RULE));
    assertTrue(configs.keySet().contains(Capability.PROCESS));
    assertTrue(configs.values().contains(ruleConfig));
    assertEquals(2, configs.size());
    ProcessConfig processConf = (ProcessConfig) configs.get(Capability.PROCESS);
    assertEquals(RuntimeStrategy.PER_PROCESS_INSTANCE.name(), processConf.getRuntimeStrategy());
}
Also used : ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) Capability(org.kie.server.controller.api.model.spec.Capability) ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) HashMap(java.util.HashMap) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 5 with RuleConfig

use of org.kie.server.controller.api.model.spec.RuleConfig in project kie-wb-common by kiegroup.

the class BuildExecutorTest method testMakeConfigsWhenServerTemplateHasProcessCapabilityWithDefaultStrategy.

@Test
public void testMakeConfigsWhenServerTemplateHasProcessCapabilityWithDefaultStrategy() {
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    final RuleConfig ruleConfig = mock(RuleConfig.class);
    doReturn(ruleConfig).when(buildExecutor).makeRuleConfig();
    doReturn(true).when(buildExecutor).hasProcessCapability(any());
    Map<String, String> params = new HashMap<>();
    final Map<Capability, ContainerConfig> configs = buildExecutor.makeConfigs(serverTemplate, params);
    assertTrue(configs.keySet().contains(Capability.RULE));
    assertTrue(configs.keySet().contains(Capability.PROCESS));
    assertTrue(configs.values().contains(ruleConfig));
    assertEquals(2, configs.size());
    ProcessConfig processConf = (ProcessConfig) configs.get(Capability.PROCESS);
    assertEquals(RuntimeStrategy.SINGLETON.name(), processConf.getRuntimeStrategy());
}
Also used : ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) Capability(org.kie.server.controller.api.model.spec.Capability) ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) HashMap(java.util.HashMap) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)11 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)10 Test (org.junit.Test)8 Capability (org.kie.server.controller.api.model.spec.Capability)7 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)7 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)7 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)6 HashMap (java.util.HashMap)5 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)3 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)3 ReleaseId (org.kie.server.api.model.ReleaseId)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Event (javax.enterprise.event.Event)1