Search in sources :

Example 36 with ServerTemplate

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

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

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

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

the class BuildExecutorTest method testBuildAndDeployCommandSingleServerTemplate.

@Test
public void testBuildAndDeployCommandSingleServerTemplate() {
    final ServerTemplate serverTemplate = new ServerTemplate("id", "name");
    when(specManagementServiceMock.listServerTemplates()).thenReturn(new ServerTemplateList(Collections.singletonList(serverTemplate)));
    buildExecutor.triggerBuildAndDeploy();
    ArgumentCaptor<ContainerSpec> containerSpecArgumentCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
    verify(specManagementServiceMock).saveContainerSpec(eq(serverTemplate.getId()), containerSpecArgumentCaptor.capture());
    final ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    verifyNotification(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
    verifyNotification(ProjectEditorResources.CONSTANTS.DeploySuccessful(), NotificationEvent.NotificationType.SUCCESS);
    verify(notificationEvent, times(2)).fire(any(NotificationEvent.class));
    verifyBusyShowHideAnyString(1, 1);
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 40 with ServerTemplate

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

the class DeploymentPopupBuilderTest method testMultipleServerTemplatesValidationWhenContainerNameDoesNotExist.

@Test
public void testMultipleServerTemplatesValidationWhenContainerNameDoesNotExist() throws Exception {
    final List<ServerTemplate> serverTemplates = new ArrayList<ServerTemplate>() {

        {
            add(serverTemplate("serverTemplate1", "container1", "container2"));
            add(serverTemplate("serverTemplate2", "container1", "container2", "container3"));
            add(serverTemplate("serverTemplate3", "container1", "container2"));
        }
    };
    doNothing().when(popupView).addServerTemplates(any());
    doReturn("serverTemplate1").when(popupView).getServerTemplate();
    final ValidateExistingContainerCallback validation = builder.multipleServerTemplatesValidation(serverTemplates);
    assertFalse(validation.containerNameExists("container3"));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ArrayList(java.util.ArrayList) ValidateExistingContainerCallback(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback) Test(org.junit.Test)

Aggregations

ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)61 Test (org.junit.Test)49 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)24 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)12 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)11 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)10 ArrayList (java.util.ArrayList)9 Capability (org.kie.server.controller.api.model.spec.Capability)9 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)9 Path (org.uberfire.java.nio.file.Path)9 ReleaseId (org.kie.server.api.model.ReleaseId)8 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)8 Command (org.uberfire.mvp.Command)7 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)7 Matchers.anyString (org.mockito.Matchers.anyString)6 HashMap (java.util.HashMap)5 List (java.util.List)5 Container (org.kie.server.controller.api.model.runtime.Container)5 ValidateExistingContainerCallback (org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback)5 ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)5