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