Search in sources :

Example 1 with KieServerControllerClientException

use of org.kie.server.controller.client.exception.KieServerControllerClientException in project droolsjbpm-integration by kiegroup.

the class KieControllerManagementIntegrationTest method testEmptyListContainers.

@Test
public void testEmptyListContainers() {
    try {
        controllerClient.listContainerSpec(kieServerInfo.getServerId());
        fail("Should throw exception about server template not existing.");
    } catch (KieServerControllerClientException e) {
        assertNotFoundException((T) e);
        assertThat(e.getMessage()).endsWith("No server template found for id " + kieServerInfo.getServerId());
    }
    // Create kie server instance connection in controller.
    createServerTemplate();
    ContainerSpecList emptyList = controllerClient.listContainerSpec(kieServerInfo.getServerId());
    KieServerAssert.assertNullOrEmpty("Active containers found!", emptyList.getContainerSpecs());
}
Also used : KieServerControllerClientException(org.kie.server.controller.client.exception.KieServerControllerClientException) ContainerSpecList(org.kie.server.controller.api.model.spec.ContainerSpecList) Test(org.junit.Test)

Example 2 with KieServerControllerClientException

use of org.kie.server.controller.client.exception.KieServerControllerClientException in project droolsjbpm-integration by kiegroup.

the class KieControllerManagementIntegrationTest method testUpdateContainerId.

@Test
public void testUpdateContainerId() {
    // Create kie server instance connection in controller.
    ServerTemplate serverTemplate = createServerTemplate();
    // Deploy container for kie server instance.
    ContainerSpec containerToDeploy = new ContainerSpec(CONTAINER_ID, CONTAINER_NAME, serverTemplate, RELEASE_ID, KieContainerStatus.STOPPED, Collections.EMPTY_MAP);
    controllerClient.saveContainerSpec(serverTemplate.getId(), containerToDeploy);
    // Get container using kie controller.
    ContainerSpec containerResponseEntity = controllerClient.getContainerInfo(kieServerInfo.getServerId(), CONTAINER_ID);
    checkContainer(containerResponseEntity, KieContainerStatus.STOPPED);
    assertEquals(CONTAINER_NAME, containerResponseEntity.getContainerName());
    containerToDeploy.setId("newID");
    try {
        controllerClient.updateContainerSpec(serverTemplate.getId(), CONTAINER_ID, containerToDeploy);
        fail("Container has updated id.");
    } catch (KieServerControllerClientException e) {
        assertBadRequestException((T) e);
        KieServerAssert.assertResultContainsString(e.getMessage(), "Cannot update container newID on container " + CONTAINER_ID);
    }
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) KieServerControllerClientException(org.kie.server.controller.client.exception.KieServerControllerClientException) Test(org.junit.Test)

Example 3 with KieServerControllerClientException

use of org.kie.server.controller.client.exception.KieServerControllerClientException in project droolsjbpm-integration by kiegroup.

the class KieControllerManagementIntegrationTest method testStartNotExistingContainer.

@Test
public void testStartNotExistingContainer() throws Exception {
    ContainerSpec containerSpec = new ContainerSpec();
    containerSpec.setId(CONTAINER_ID);
    containerSpec.setServerTemplateKey(new ServerTemplateKey(kieServerInfo.getServerId(), null));
    // Try to start not existing container using kie controller without created kie server instance.
    try {
        controllerClient.startContainer(containerSpec);
        fail("Should throw exception about server template not found.");
    } catch (KieServerControllerClientException e) {
        assertNotFoundException((T) e);
        assertThat(e.getMessage()).endsWith("No server template found for id " + kieServerInfo.getServerId());
    }
    createServerTemplate();
    // Try to start not existing container using kie controller with created kie server instance.
    try {
        controllerClient.startContainer(containerSpec);
        fail("Should throw exception about container not found.");
    } catch (KieServerControllerClientException e) {
        assertNotFoundException((T) e);
        assertThat(e.getMessage()).endsWith("No container spec found for id " + CONTAINER_ID + " within server template with id " + kieServerInfo.getServerId());
    }
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) KieServerControllerClientException(org.kie.server.controller.client.exception.KieServerControllerClientException) Test(org.junit.Test)

Example 4 with KieServerControllerClientException

use of org.kie.server.controller.client.exception.KieServerControllerClientException in project droolsjbpm-integration by kiegroup.

the class KieControllerManagementIntegrationTest method testCreateDuplicitContainer.

@Test
public void testCreateDuplicitContainer() {
    // Create kie server instance connection in controller.
    ServerTemplate serverTemplate = createServerTemplate();
    // Deploy container for kie server instance.
    ContainerSpec containerToDeploy = new ContainerSpec(CONTAINER_ID, CONTAINER_NAME, serverTemplate, RELEASE_ID, KieContainerStatus.STOPPED, new HashMap());
    controllerClient.saveContainerSpec(serverTemplate.getId(), containerToDeploy);
    try {
        // Try to create same container.
        controllerClient.saveContainerSpec(serverTemplate.getId(), containerToDeploy);
        fail("Should throw exception about container being created already.");
    } catch (KieServerControllerClientException e) {
        assertBadRequestException((T) e);
        assertThat(e.getMessage()).endsWith("Server template with id " + serverTemplate.getId() + " associated already with container " + CONTAINER_ID);
    }
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) HashMap(java.util.HashMap) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) KieServerControllerClientException(org.kie.server.controller.client.exception.KieServerControllerClientException) Test(org.junit.Test)

Example 5 with KieServerControllerClientException

use of org.kie.server.controller.client.exception.KieServerControllerClientException in project droolsjbpm-integration by kiegroup.

the class KieControllerManagementIntegrationTest method testCreateContainerByUpdateContainer.

@Test
public void testCreateContainerByUpdateContainer() {
    // Create kie server instance connection in controller.
    ServerTemplate serverTemplate = createServerTemplate();
    // Deploy container for kie server instance.
    ContainerSpec containerToDeploy = new ContainerSpec(CONTAINER_ID, CONTAINER_NAME, serverTemplate, RELEASE_ID, KieContainerStatus.STOPPED, Collections.EMPTY_MAP);
    try {
        controllerClient.updateContainerSpec(serverTemplate.getId(), containerToDeploy);
        fail("Container was created by update command - REST Post method.");
    } catch (KieServerControllerClientException e) {
        assertNotFoundException((T) e);
    }
    KieServerAssert.assertNullOrEmpty("Found deployed container.", controllerClient.listContainerSpec(serverTemplate.getId()).getContainerSpecs());
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) KieServerControllerClientException(org.kie.server.controller.client.exception.KieServerControllerClientException) Test(org.junit.Test)

Aggregations

KieServerControllerClientException (org.kie.server.controller.client.exception.KieServerControllerClientException)18 Test (org.junit.Test)17 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)13 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)13 HashMap (java.util.HashMap)3 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)2 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)2 IOException (java.io.IOException)1 KieContainerResourceList (org.kie.server.api.model.KieContainerResourceList)1 KieServerControllerDescriptorCommand (org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand)1 ServerInstanceKeyList (org.kie.server.controller.api.model.runtime.ServerInstanceKeyList)1 ContainerSpecList (org.kie.server.controller.api.model.spec.ContainerSpecList)1 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)1 WebSocketServiceResponse (org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse)1