Search in sources :

Example 6 with ProcessConfig

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

the class ContainerProcessConfigPresenterTest method testSave.

@Test
public void testSave() {
    final String templateKey = "templateKey";
    final String containerKey = "containerKey";
    when(serverTemplateKey.getId()).thenReturn(templateKey);
    when(containerSpecKey.getId()).thenReturn(containerKey);
    when(view.getSaveSuccessMessage()).thenReturn("SUCCESS");
    presenter.save();
    verify(notification).fire(new NotificationEvent("SUCCESS", NotificationEvent.NotificationType.SUCCESS));
    verify(view).disableActions();
    verify(processConfigPresenter).buildProcessConfig();
    final ArgumentCaptor<ProcessConfig> processConfigCaptor = ArgumentCaptor.forClass(ProcessConfig.class);
    verify(specManagementService).updateContainerConfig(eq(templateKey), eq(containerKey), eq(Capability.PROCESS), processConfigCaptor.capture());
    verify(view).enableActions();
    verify(processConfigPresenter).setProcessConfig(processConfigCaptor.getValue());
}
Also used : ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 7 with ProcessConfig

use of org.kie.server.controller.api.model.spec.ProcessConfig 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 8 with ProcessConfig

use of org.kie.server.controller.api.model.spec.ProcessConfig 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)

Example 9 with ProcessConfig

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

the class BuildExecutorTest method testMakeConfigsWhenServerTemplateHasProcessCapability.

@Test
public void testMakeConfigsWhenServerTemplateHasProcessCapability() {
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    final RuleConfig ruleConfig = mock(RuleConfig.class);
    final ProcessConfig processConfig = mock(ProcessConfig.class);
    doReturn(ruleConfig).when(buildExecutor).makeRuleConfig();
    doReturn(processConfig).when(buildExecutor).makeProcessConfig(new HashMap<>());
    doReturn(true).when(buildExecutor).hasProcessCapability(any());
    final Map<Capability, ContainerConfig> configs = buildExecutor.makeConfigs(serverTemplate, new HashMap<>());
    assertTrue(configs.keySet().contains(Capability.RULE));
    assertTrue(configs.keySet().contains(Capability.PROCESS));
    assertTrue(configs.values().contains(ruleConfig));
    assertTrue(configs.values().contains(processConfig));
    assertEquals(2, configs.size());
}
Also used : ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) 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 10 with ProcessConfig

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

the class ServerTemplateVFSStorageTest method testStoreLoadAndUpdateServerTemplate.

@Test
public void testStoreLoadAndUpdateServerTemplate() {
    templateStorage.store(serverTemplate);
    ServerTemplate fromStorage = templateStorage.load(serverTemplate.getId());
    assertNotNull(fromStorage);
    assertEquals(serverTemplate.getId(), fromStorage.getId());
    assertEquals(serverTemplate.getName(), fromStorage.getName());
    // let's add new container
    ContainerSpec newContainerSpec = new ContainerSpec();
    newContainerSpec.setId("test container 2");
    newContainerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName()));
    newContainerSpec.setReleasedId(new ReleaseId("org.kie", "kie-server-kjar", "3.0"));
    newContainerSpec.setStatus(KieContainerStatus.STARTED);
    fromStorage.addContainerSpec(newContainerSpec);
    // now let's add server instance
    fromStorage.addServerInstance(ModelFactory.newServerInstanceKey(serverTemplate.getId(), "http://localhost:8080/server"));
    templateStorage.update(fromStorage);
    ServerTemplate template = templateStorage.load(serverTemplate.getId());
    assertNotNull(template);
    assertEquals(serverTemplate.getId(), template.getId());
    assertEquals(serverTemplate.getName(), template.getName());
    Collection<ServerInstanceKey> instances = template.getServerInstanceKeys();
    assertNotNull(instances);
    assertEquals(1, instances.size());
    ServerInstanceKey serverInstanceKey = instances.iterator().next();
    assertNotNull(serverInstanceKey);
    assertEquals(serverTemplate.getId(), serverInstanceKey.getServerTemplateId());
    assertEquals(serverTemplate.getId() + "@localhost:8080", serverInstanceKey.getServerName());
    assertEquals(serverTemplate.getId() + "@localhost:8080", serverInstanceKey.getServerInstanceId());
    assertEquals("http://localhost:8080/server", serverInstanceKey.getUrl());
    Collection<ContainerSpec> containerSpecs = template.getContainersSpec();
    assertNotNull(containerSpecs);
    assertEquals(2, containerSpecs.size());
    Iterator<ContainerSpec> iterator = containerSpecs.iterator();
    // first container spec...
    ContainerSpec spec = 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());
    // second container spec
    spec = iterator.next();
    assertNotNull(spec);
    assertEquals(newContainerSpec.getId(), spec.getId());
    assertEquals(newContainerSpec.getReleasedId(), spec.getReleasedId());
    assertEquals(newContainerSpec.getServerTemplateKey().getId(), spec.getServerTemplateKey().getId());
    assertEquals(newContainerSpec.getServerTemplateKey().getName(), spec.getServerTemplateKey().getName());
    assertEquals(newContainerSpec.getConfigs().size(), spec.getConfigs().size());
}
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) ReleaseId(org.kie.server.api.model.ReleaseId) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) Test(org.junit.Test)

Aggregations

ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)15 Test (org.junit.Test)12 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)8 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)7 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)5 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)5 HashMap (java.util.HashMap)4 Capability (org.kie.server.controller.api.model.spec.Capability)4 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)4 ReleaseId (org.kie.server.api.model.ReleaseId)3 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)3 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)3 Container (org.kie.server.controller.api.model.runtime.Container)2 ContainerSpecKey (org.kie.server.controller.api.model.spec.ContainerSpecKey)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)1 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 Before (org.junit.Before)1 ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)1 ContainerSpecData (org.kie.workbench.common.screens.server.management.model.ContainerSpecData)1