Search in sources :

Example 56 with Deployment

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

the class TenancyTest method testCallActivityWithTenant.

// Bug from http://forums.activiti.org/content/callactiviti-tenant-id
public void testCallActivityWithTenant() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        String tenantId = "apache";
        //deploying both processes. Process 1 will call Process 2 
        repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testCallActivityWithTenant-process01.bpmn20.xml").tenantId(tenantId).deploy();
        repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testCallActivityWithTenant-process02.bpmn20.xml").tenantId(tenantId).deploy();
        //Starting Process 1. Process 1 will be executed successfully but when the call to process 2 is made internally it will throw the exception
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKeyAndTenantId("process1", null, CollectionUtil.singletonMap("sendFor", "test"), tenantId);
        Assert.assertNotNull(processInstance);
        Assert.assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("process2").processInstanceTenantId(tenantId).count());
        Assert.assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("process2").count());
        // following line if executed will give activiti object not found exception as the process1 is linked to a tenant id.
        try {
            processInstance = runtimeService.startProcessInstanceByKey("process1");
            Assert.fail();
        } catch (Exception e) {
        }
        // Cleanup
        for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
            repositoryService.deleteDeployment(deployment.getId(), true);
        }
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiException(org.activiti.engine.ActivitiException)

Example 57 with Deployment

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

the class TenancyTest method testSignalAsyncThroughApiTenancy.

public void testSignalAsyncThroughApiTenancy() {
    // 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
    assertEquals(4, taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count());
    assertEquals(5, taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count());
    // Signal through API (with tenant)
    runtimeService.signalEventReceivedAsyncWithTenantId("The Signal", TEST_TENANT_ID);
    assertEquals(0, taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count());
    assertEquals(0, taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count());
    for (Job job : managementService.createJobQuery().list()) {
        managementService.executeJob(job.getId());
    }
    assertEquals(4, taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count());
    assertEquals(0, taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count());
    // Signal through API (without tenant)
    runtimeService.signalEventReceivedAsync("The Signal");
    assertEquals(4, taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count());
    assertEquals(0, taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count());
    for (Job job : managementService.createJobQuery().list()) {
        managementService.executeJob(job.getId());
    }
    assertEquals(4, taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count());
    assertEquals(5, taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count());
    // Cleanup
    for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId(), true);
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment) Job(org.activiti.engine.runtime.Job)

Example 58 with Deployment

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

the class ProcessDefinitionsTest method testDeployments.

@Test
public void testDeployments() {
    when(repositoryService.createDeploymentQuery()).thenReturn(deploymentQuery);
    DeploymentEntity deployment = new DeploymentEntity();
    List<Deployment> deploymentList = new ArrayList<Deployment>();
    deployment.setId("testDeploymentId");
    deployment.setName("testDeploymentName");
    deployment.setTenantId("tenantId");
    deploymentList.add(deployment);
    when(deploymentQuery.list()).thenReturn(deploymentList);
    List<List<String>> result = processDefinitionsMBean.getDeployments();
    assertNotNull(result);
    assertEquals(1, result.size());
    assertEquals(3, result.get(0).size());
    assertEquals("testDeploymentId", result.get(0).get(0));
    assertEquals("testDeploymentName", result.get(0).get(1));
    assertEquals("tenantId", result.get(0).get(2));
}
Also used : DeploymentEntity(org.activiti.engine.impl.persistence.entity.DeploymentEntity) ArrayList(java.util.ArrayList) Deployment(org.activiti.engine.repository.Deployment) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 59 with Deployment

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

the class ProcessDefinitionsMBean method deployProcessDefinition.

@ManagedOperation(description = "Deploy Process Definition")
public void deployProcessDefinition(String resourceName, String processDefinitionFile) throws FileNotFoundException {
    DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
    Deployment deployment = deploymentBuilder.addInputStream(resourceName, new FileInputStream(processDefinitionFile)).deploy();
}
Also used : Deployment(org.activiti.engine.repository.Deployment) DeploymentBuilder(org.activiti.engine.repository.DeploymentBuilder) FileInputStream(java.io.FileInputStream) ManagedOperation(org.activiti.management.jmx.annotations.ManagedOperation)

Example 60 with Deployment

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

the class ProcessDefinitionsMBean method getDeployments.

@ManagedAttribute(description = "List of deployed Processes")
public List<List<String>> getDeployments() {
    List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
    List<List<String>> result = new ArrayList<List<String>>(deployments.size());
    for (Deployment deployment : deployments) {
        List<String> item = new ArrayList<String>(3);
        item.add(deployment.getId());
        item.add(deployment.getName());
        item.add(deployment.getTenantId());
        result.add(item);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Deployment(org.activiti.engine.repository.Deployment) List(java.util.List) ArrayList(java.util.ArrayList) ManagedAttribute(org.activiti.management.jmx.annotations.ManagedAttribute)

Aggregations

Deployment (org.activiti.engine.repository.Deployment)66 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)12 BpmnModel (org.activiti.bpmn.model.BpmnModel)10 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 ActivitiException (org.activiti.engine.ActivitiException)7 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)6 HttpGet (org.apache.http.client.methods.HttpGet)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 InputStream (java.io.InputStream)3 HashSet (java.util.HashSet)3 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)3 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)3 ProcessEngine (org.activiti.engine.ProcessEngine)3 RuntimeService (org.activiti.engine.RuntimeService)3 DeploymentBuilder (org.activiti.engine.repository.DeploymentBuilder)3 Task (org.activiti.engine.task.Task)3