Search in sources :

Example 41 with ServerTemplate

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

the class DeploymentPopupBuilderTest method serverTemplate.

private ServerTemplate serverTemplate(final String id, final String... containerNames) {
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    final ArrayList<ContainerSpec> containersSpec = new ArrayList<ContainerSpec>() {

        {
            for (final String containerName : containerNames) {
                add(containerSpec(containerName));
            }
        }
    };
    doReturn(id).when(serverTemplate).getId();
    doReturn(containersSpec).when(serverTemplate).getContainersSpec();
    return serverTemplate;
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ArrayList(java.util.ArrayList)

Example 42 with ServerTemplate

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

the class SpecManagementServiceCDITest method isNewServerTemplateIdValidTest.

@Test
public void isNewServerTemplateIdValidTest() {
    final SpecManagementServiceCDI specManagementService = spy(new SpecManagementServiceCDI());
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    when(serverTemplate.getContainerSpec(any())).thenReturn(null);
    doThrow(KieServerControllerNotFoundException.class).when(specManagementService).getServerTemplate("noDoraId");
    doReturn(serverTemplate).when(specManagementService).getServerTemplate("doraId");
    assertTrue(specManagementService.isNewServerTemplateIdValid("noDoraId"));
    assertFalse(specManagementService.isNewServerTemplateIdValid("doraId"));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Test(org.junit.Test)

Example 43 with ServerTemplate

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

the class SpecManagementServiceCDITest method testValidContainerIdWhenContainerIdIsValidInTheFirstAttempt.

@Test
public void testValidContainerIdWhenContainerIdIsValidInTheFirstAttempt() {
    final SpecManagementServiceCDI service = spy(new SpecManagementServiceCDI());
    final ServerTemplate template = mock(ServerTemplate.class);
    when(template.getContainerSpec("org.jbpm:Evaluation:1.0")).thenReturn(null);
    doReturn(template).when(service).getServerTemplate("templateId");
    final String containerId = service.validContainerId("templateId", "org.jbpm:Evaluation:1.0");
    assertEquals(containerId, "org.jbpm:Evaluation:1.0");
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Test(org.junit.Test)

Example 44 with ServerTemplate

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

the class SpecManagementServiceCDITest method testIsContainerIdValid.

@Test
public void testIsContainerIdValid() {
    final SpecManagementServiceCDI specManagementService = spy(new SpecManagementServiceCDI());
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    when(serverTemplate.getContainerSpec(any())).thenReturn(null);
    doReturn(serverTemplate).when(specManagementService).getServerTemplate("templateId");
    assertTrue(specManagementService.isContainerIdValid("templateId", "111"));
    assertTrue(specManagementService.isContainerIdValid("templateId", "xxx"));
    assertTrue(specManagementService.isContainerIdValid("templateId", "aaa:bbb:ccc"));
    assertTrue(specManagementService.isContainerIdValid("templateId", "org.jbpm:Evaluation:1.0"));
    assertTrue(specManagementService.isContainerIdValid("templateId", "org.jbpm:Evaluation:1.0-SNAPSHOT"));
    assertTrue(specManagementService.isContainerIdValid("templateId", "org.jbpm:Evaluation:1.0_demo"));
    assertFalse(specManagementService.isContainerIdValid("templateId", "org.jbpm:Evaluation:1.0/SNAPSHOT"));
    assertFalse(specManagementService.isContainerIdValid("templateId", "org.jbpm:Evaluation:1.0&SNAPSHOT"));
    assertFalse(specManagementService.isContainerIdValid("templateId", "org.jbpm:Evaluation:1.0+SNAPSHOT"));
    assertFalse(specManagementService.isContainerIdValid("templateId", "org.jbpm:Evaluation:1.0`SNAPSHOT"));
    assertFalse(specManagementService.isContainerIdValid("templateId", "org.jbpm:Evaluation:1.0~SNAPSHOT"));
    assertFalse(specManagementService.isContainerIdValid("templateId", "aa&&aa"));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Test(org.junit.Test)

Example 45 with ServerTemplate

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

the class SpecManagementServiceCDITest method testValidContainerIdWhenContainerIdIsValidInTheSecondAttempt.

@Test
public void testValidContainerIdWhenContainerIdIsValidInTheSecondAttempt() {
    final SpecManagementServiceCDI service = spy(new SpecManagementServiceCDI());
    final ServerTemplate template = mock(ServerTemplate.class);
    final ContainerSpec containerSpec = mock(ContainerSpec.class);
    when(template.getContainerSpec("org.jbpm:Evaluation:1.0")).thenReturn(containerSpec);
    when(template.getContainerSpec("org.jbpm:Evaluation:1.0-2")).thenReturn(null);
    doReturn(template).when(service).getServerTemplate("templateId");
    final String containerId = service.validContainerId("templateId", "org.jbpm:Evaluation:1.0");
    assertEquals(containerId, "org.jbpm:Evaluation:1.0-2");
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) 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