Search in sources :

Example 91 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class DeploymentEventsTest method testDeploymentEvents.

/**
 * Test create, update and delete events of deployment entities.
 */
public void testDeploymentEvents() throws Exception {
    Deployment deployment = null;
    try {
        listener.clearEventsReceived();
        deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml").deploy();
        assertThat(deployment).isNotNull();
        // Check create-event
        assertThat(listener.getEventsReceived()).hasSize(2);
        assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiEntityEvent.class);
        ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
        assertThat(event.getType()).isEqualTo(ActivitiEventType.ENTITY_CREATED);
        assertThat(((Deployment) event.getEntity()).getId()).isEqualTo(deployment.getId());
        assertThat(listener.getEventsReceived().get(1)).isInstanceOf(ActivitiEntityEvent.class);
        event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
        assertThat(event.getType()).isEqualTo(ActivitiEventType.ENTITY_INITIALIZED);
        assertThat(((Deployment) event.getEntity()).getId()).isEqualTo(deployment.getId());
        listener.clearEventsReceived();
        // Check update event when category is updated
        repositoryService.setDeploymentCategory(deployment.getId(), "test");
        assertThat(listener.getEventsReceived()).hasSize(1);
        assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiEntityEvent.class);
        event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
        assertThat(event.getType()).isEqualTo(ActivitiEventType.ENTITY_UPDATED);
        assertThat(((Deployment) event.getEntity()).getId()).isEqualTo(deployment.getId());
        assertThat(((Deployment) event.getEntity()).getCategory()).isEqualTo("test");
        listener.clearEventsReceived();
        // Check delete event when category is updated
        repositoryService.deleteDeployment(deployment.getId(), true);
        assertThat(listener.getEventsReceived()).hasSize(1);
        assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiEntityEvent.class);
        event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
        assertThat(event.getType()).isEqualTo(ActivitiEventType.ENTITY_DELETED);
        assertThat(((Deployment) event.getEntity()).getId()).isEqualTo(deployment.getId());
        listener.clearEventsReceived();
    } finally {
        if (deployment != null && repositoryService.createDeploymentQuery().deploymentId(deployment.getId()).count() > 0) {
            repositoryService.deleteDeployment(deployment.getId(), true);
        }
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment) ActivitiEntityEvent(org.activiti.engine.delegate.event.ActivitiEntityEvent)

Example 92 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class CallActivityTest method testInstantiateSuspendedChildProcess.

public void testInstantiateSuspendedChildProcess() throws Exception {
    BpmnModel childBpmnModel = loadBPMNModel(CHILD_PROCESS_RESOURCE);
    Deployment childDeployment = processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
    suspendProcessDefinitions(childDeployment);
    assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> runtimeService.startProcessInstanceByKey("childProcess")).withMessageContaining("Cannot start process instance. Process definition Child Process");
}
Also used : Deployment(org.activiti.engine.repository.Deployment) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 93 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class CallActivityTest method testInstantiateSuspendedProcessByMessage.

public void testInstantiateSuspendedProcessByMessage() throws Exception {
    BpmnModel messageTriggeredBpmnModel = loadBPMNModel(MESSAGE_TRIGGERED_PROCESS_RESOURCE);
    Deployment messageTriggeredBpmnDeployment = processEngine.getRepositoryService().createDeployment().name("messageTriggeredProcessDeployment").addBpmnModel("messageTriggered.bpmn20.xml", messageTriggeredBpmnModel).deploy();
    suspendProcessDefinitions(messageTriggeredBpmnDeployment);
    assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> runtimeService.startProcessInstanceByMessage("TRIGGER_PROCESS_MESSAGE")).withMessageContaining("Cannot start process instance. Process definition Message Triggered Process");
}
Also used : Deployment(org.activiti.engine.repository.Deployment) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 94 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class ApplicationUpgradeIT method should_updateDeploymentVersion_when_onlyProjectManifestVersionIsSet.

@Test
public void should_updateDeploymentVersion_when_onlyProjectManifestVersionIsSet() {
    ProjectManifest projectManifest = new ProjectManifest();
    projectManifest.setVersion("2");
    Deployment deployment1 = repositoryService.createDeployment().setProjectManifest(projectManifest).enableDuplicateFiltering().name("deploymentName").deploy();
    deploymentIds.add(deployment1.getId());
    assertThat(deployment1.getVersion()).isEqualTo(1);
    assertThat(deployment1.getProjectReleaseVersion()).isEqualTo("2");
    projectManifest.setVersion("17");
    Deployment deployment2 = repositoryService.createDeployment().setProjectManifest(projectManifest).setEnforcedAppVersion(2).enableDuplicateFiltering().name("deploymentName").deploy();
    deploymentIds.add(deployment2.getId());
    assertThat(deployment2.getVersion()).isEqualTo(2);
    assertThat(deployment2.getProjectReleaseVersion()).isEqualTo("17");
}
Also used : ProjectManifest(org.activiti.core.common.project.model.ProjectManifest) Deployment(org.activiti.engine.repository.Deployment) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 95 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class ApplicationUpgradeIT method should_noUpgradeTakePlace_when_enforcedAppVersionAndProjectManifestVersionAreNotSet.

@Test
public void should_noUpgradeTakePlace_when_enforcedAppVersionAndProjectManifestVersionAreNotSet() {
    Deployment deployment1 = repositoryService.createDeployment().enableDuplicateFiltering().name("deploymentName").deploy();
    deploymentIds.add(deployment1.getId());
    assertThat(deployment1.getVersion()).isEqualTo(1);
    Deployment deployment2 = repositoryService.createDeployment().enableDuplicateFiltering().name("deploymentName").deploy();
    deploymentIds.add(deployment2.getId());
    assertThat(deployment2.getVersion()).isEqualTo(1);
}
Also used : Deployment(org.activiti.engine.repository.Deployment) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Deployment (org.activiti.engine.repository.Deployment)96 ArrayList (java.util.ArrayList)11 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)11 ProcessEngine (org.activiti.engine.ProcessEngine)10 RepositoryService (org.activiti.engine.RepositoryService)10 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 BpmnModel (org.activiti.bpmn.model.BpmnModel)9 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)9 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 DeploymentQuery (org.activiti.engine.repository.DeploymentQuery)8 Test (org.junit.Test)8 ActivitiException (org.activiti.engine.ActivitiException)7 Test (org.junit.jupiter.api.Test)7 HttpGet (org.apache.http.client.methods.HttpGet)6 BPMNDeployment (org.wso2.carbon.bpmn.core.mgt.model.BPMNDeployment)6 InputStream (java.io.InputStream)5 HashSet (java.util.HashSet)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5