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