Search in sources :

Example 1 with ProcessConfig

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

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

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

the class ContainerProcessConfigPresenter method save.

public void save() {
    view.disableActions();
    final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig();
    specManagementService.call(new RemoteCallback<Void>() {

        @Override
        public void callback(final Void containerConfig) {
            notification.fire(new NotificationEvent(view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS));
            setupView(newProcessConfig);
        }
    }, new ErrorCallback<Object>() {

        @Override
        public boolean error(final Object o, final Throwable throwable) {
            notification.fire(new NotificationEvent(view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR));
            setupView(processConfigPresenter.getProcessConfig());
            return false;
        }
    }).updateContainerConfig(processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig);
}
Also used : ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 4 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 5 with ProcessConfig

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

the class ProcessConfigPresenterTest method testBuildProcessConfig.

@Test
public void testBuildProcessConfig() {
    when(view.getRuntimeStrategy()).thenReturn("a");
    when(view.getKBase()).thenReturn("b");
    when(view.getKSession()).thenReturn("c");
    when(view.getMergeMode()).thenReturn("d");
    final ProcessConfig processConfig = presenter.buildProcessConfig();
    assertEquals("SINGLETON", processConfig.getRuntimeStrategy());
    assertEquals("b", processConfig.getKBase());
    assertEquals("c", processConfig.getKSession());
    assertEquals("KEEP_ALL", processConfig.getMergeMode());
}
Also used : ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) Test(org.junit.Test)

Aggregations

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