Search in sources :

Example 76 with Deployment

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

the class ChineseConverterTest method deployProcess.

protected void deployProcess(BpmnModel bpmnModel) {
    byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
    try {
        Deployment deployment = processEngine.getRepositoryService().createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
        processEngine.getRepositoryService().deleteDeployment(deployment.getId());
    } finally {
        processEngine.close();
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter)

Example 77 with Deployment

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

the class TenancyTest method testStartProcessInstanceByMessageTenancyReversed.

public void testStartProcessInstanceByMessageTenancyReversed() {
    // same as
    // above, but now reversed
    // Deploy process both with and without tenant
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml").deploy();
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml").tenantId(TEST_TENANT_ID).deploy();
    // Start a process instance by message with tenant
    runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
    assertThat(taskService.createTaskQuery().taskName("My task").count()).isEqualTo(3);
    assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(0);
    assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(3);
    // Start a process instance by message without tenant
    runtimeService.startProcessInstanceByMessage("My message");
    runtimeService.startProcessInstanceByMessage("My message");
    assertThat(taskService.createTaskQuery().taskName("My task").count()).isEqualTo(5);
    assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(2);
    assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(3);
    // Cleanup
    for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId(), true);
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment)

Example 78 with Deployment

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

the class TenancyTest method testSignalFromProcessTenancy.

public void testSignalFromProcessTenancy() {
    // Deploy process both with and without tenant
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMultiTenancySignals.bpmn20.xml").deploy();
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMultiTenancySignals.bpmn20.xml").tenantId(TEST_TENANT_ID).deploy();
    // Start 3 proc instances for the one with a tenant and 2 for the one
    // without tenant
    runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByKey("testMtSignalCatch");
    runtimeService.startProcessInstanceByKey("testMtSignalCatch");
    // verify
    assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(3);
    assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(2);
    // Now, start 1 process instance that fires a signal event (not in tenant context), it should only continue those without tenant
    runtimeService.startProcessInstanceByKey("testMtSignalFiring");
    assertThat(taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(0);
    assertThat(taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count()).isEqualTo(2);
    // Start a process instance that is running in tenant context
    runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalFiring", TEST_TENANT_ID);
    assertThat(taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(3);
    assertThat(taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count()).isEqualTo(2);
    // Cleanup
    for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId(), true);
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment)

Example 79 with Deployment

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

the class TenancyTest method testSignalThroughApiTenancy.

public void testSignalThroughApiTenancy() {
    // Deploy process both with and without tenant
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMultiTenancySignals.bpmn20.xml").deploy();
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMultiTenancySignals.bpmn20.xml").tenantId(TEST_TENANT_ID).deploy();
    // Start 4 proc instances for the one with a tenant and 5 for the one without tenant
    runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByKey("testMtSignalCatch");
    runtimeService.startProcessInstanceByKey("testMtSignalCatch");
    runtimeService.startProcessInstanceByKey("testMtSignalCatch");
    runtimeService.startProcessInstanceByKey("testMtSignalCatch");
    runtimeService.startProcessInstanceByKey("testMtSignalCatch");
    // Verify
    assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(4);
    assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(5);
    // Signal through API (with tenant)
    runtimeService.signalEventReceivedWithTenantId("The Signal", TEST_TENANT_ID);
    assertThat(taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(4);
    assertThat(taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count()).isEqualTo(0);
    // Signal through API (without tenant)
    runtimeService.signalEventReceived("The Signal");
    assertThat(taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(4);
    assertThat(taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count()).isEqualTo(5);
    // Cleanup
    for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId(), true);
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment)

Example 80 with Deployment

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

the class TenancyTest method testStartProcessInstanceByMessageTenancy.

public void testStartProcessInstanceByMessageTenancy() {
    // Deploy process both with and without tenant
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml").deploy();
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml").tenantId(TEST_TENANT_ID).deploy();
    // Verify query
    assertThat(repositoryService.createProcessDefinitionQuery().messageEventSubscriptionName("My message").count()).isEqualTo(2);
    assertThat(repositoryService.createProcessDefinitionQuery().messageEventSubscriptionName("My message").processDefinitionWithoutTenantId().count()).isEqualTo(1);
    assertThat(repositoryService.createProcessDefinitionQuery().messageEventSubscriptionName("My message").processDefinitionTenantId(TEST_TENANT_ID).count()).isEqualTo(1);
    // Start a process instance by message without tenant
    runtimeService.startProcessInstanceByMessage("My message");
    runtimeService.startProcessInstanceByMessage("My message");
    assertThat(taskService.createTaskQuery().taskName("My task").count()).isEqualTo(2);
    assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(2);
    assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(0);
    // Start a process instance by message with tenant
    runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
    runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
    assertThat(taskService.createTaskQuery().taskName("My task").count()).isEqualTo(5);
    assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(2);
    assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(3);
    // Cleanup
    for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId(), true);
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment)

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