Search in sources :

Example 11 with Deployment

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

the class TenancyTest method testStartProcessInstanceBySignalTenancy.

public void testStartProcessInstanceBySignalTenancy() {
    // Deploy process both with and without tenant
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testStartProcessInstanceBySignalTenancy.bpmn20.xml").deploy();
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testStartProcessInstanceBySignalTenancy.bpmn20.xml").tenantId(TEST_TENANT_ID).deploy();
    // Signaling without tenant
    runtimeService.signalEventReceived("The Signal");
    assertEquals(3, runtimeService.createProcessInstanceQuery().count());
    assertEquals(3, runtimeService.createProcessInstanceQuery().processInstanceWithoutTenantId().count());
    assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceTenantId(TEST_TENANT_ID).count());
    // Signalling with tenant
    runtimeService.signalEventReceivedWithTenantId("The Signal", TEST_TENANT_ID);
    assertEquals(6, runtimeService.createProcessInstanceQuery().count());
    assertEquals(3, runtimeService.createProcessInstanceQuery().processInstanceWithoutTenantId().count());
    assertEquals(3, runtimeService.createProcessInstanceQuery().processInstanceTenantId(TEST_TENANT_ID).count());
    // Start a process instance with a boundary catch (with and without tenant)
    runtimeService.startProcessInstanceByKey("processWithSignalCatch");
    runtimeService.startProcessInstanceByKeyAndTenantId("processWithSignalCatch", TEST_TENANT_ID);
    runtimeService.signalEventReceived("The Signal");
    assertEquals(11, runtimeService.createProcessInstanceQuery().count());
    assertEquals(7, runtimeService.createProcessInstanceQuery().processInstanceWithoutTenantId().count());
    assertEquals(4, runtimeService.createProcessInstanceQuery().processInstanceTenantId(TEST_TENANT_ID).count());
    runtimeService.signalEventReceivedWithTenantId("The Signal", TEST_TENANT_ID);
    assertEquals(14, runtimeService.createProcessInstanceQuery().count());
    assertEquals(7, runtimeService.createProcessInstanceQuery().processInstanceWithoutTenantId().count());
    assertEquals(7, runtimeService.createProcessInstanceQuery().processInstanceTenantId(TEST_TENANT_ID).count());
    // Cleanup
    for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId(), true);
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment)

Example 12 with Deployment

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

the class TenancyTest method testSignalThroughApiTenancyReversed.

public void testSignalThroughApiTenancyReversed() {
    // cause reversing the order of calling DID leave to an error!
    // 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 (without tenant)
    runtimeService.signalEventReceived("The Signal");
    assertEquals(0, taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count());
    assertEquals(5, taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count());
    // Signal through API (with tenant)
    runtimeService.signalEventReceivedWithTenantId("The Signal", TEST_TENANT_ID);
    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)

Example 13 with Deployment

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

the class DeploymentListQuery method loadItems.

public List<Item> loadItems(int start, int count) {
    List<Deployment> deployments = deploymentFilter.getQuery(repositoryService).listPage(start, count);
    List<Item> items = new ArrayList<Item>();
    for (Deployment deployment : deployments) {
        items.add(deploymentFilter.createItem(deployment));
    }
    return items;
}
Also used : PropertysetItem(com.vaadin.data.util.PropertysetItem) Item(com.vaadin.data.Item) ArrayList(java.util.ArrayList) Deployment(org.activiti.engine.repository.Deployment)

Example 14 with Deployment

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

the class AbstractActivitiTestCase method deployTwoTasksTestProcess.

public String deployTwoTasksTestProcess() {
    BpmnModel bpmnModel = createTwoTasksTestProcess();
    Deployment deployment = repositoryService.createDeployment().addBpmnModel("twoTasksTestProcess.bpmn20.xml", bpmnModel).deploy();
    // For auto-cleanup
    deploymentIdsForAutoCleanup.add(deployment.getId());
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
    return processDefinition.getId();
}
Also used : Deployment(org.activiti.engine.repository.Deployment) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 15 with Deployment

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

the class DeploymentCollectionResourceTest method testGetDeployments.

/**
  * Test getting deployments.
  * GET repository/deployments
  */
public void testGetDeployments() throws Exception {
    try {
        // Alter time to ensure different deployTimes
        Calendar yesterday = Calendar.getInstance();
        yesterday.add(Calendar.DAY_OF_MONTH, -1);
        processEngineConfiguration.getClock().setCurrentTime(yesterday.getTime());
        Deployment firstDeployment = repositoryService.createDeployment().name("Deployment 1").category("DEF").addClasspathResource("org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml").deploy();
        processEngineConfiguration.getClock().setCurrentTime(Calendar.getInstance().getTime());
        Deployment secondDeployment = repositoryService.createDeployment().name("Deployment 2").category("ABC").addClasspathResource("org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml").tenantId("myTenant").deploy();
        String baseUrl = RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT_COLLECTION);
        assertResultsPresentInDataResponse(baseUrl, firstDeployment.getId(), secondDeployment.getId());
        // Check name filtering
        String url = baseUrl + "?name=" + encode("Deployment 1");
        assertResultsPresentInDataResponse(url, firstDeployment.getId());
        // Check name-like filtering
        url = baseUrl + "?nameLike=" + encode("%ment 2");
        assertResultsPresentInDataResponse(url, secondDeployment.getId());
        // Check category filtering
        url = baseUrl + "?category=DEF";
        assertResultsPresentInDataResponse(url, firstDeployment.getId());
        // Check category-not-equals filtering
        url = baseUrl + "?categoryNotEquals=DEF";
        assertResultsPresentInDataResponse(url, secondDeployment.getId());
        // Check tenantId filtering
        url = baseUrl + "?tenantId=myTenant";
        assertResultsPresentInDataResponse(url, secondDeployment.getId());
        // Check tenantId filtering
        url = baseUrl + "?tenantId=unexistingTenant";
        assertResultsPresentInDataResponse(url);
        // Check tenantId like filtering
        url = baseUrl + "?tenantIdLike=" + encode("%enant");
        assertResultsPresentInDataResponse(url, secondDeployment.getId());
        // Check without tenantId filtering
        url = baseUrl + "?withoutTenantId=true";
        assertResultsPresentInDataResponse(url, firstDeployment.getId());
        // Check ordering by name
        CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT_COLLECTION) + "?sort=name&order=asc"), HttpStatus.SC_OK);
        JsonNode dataNode = objectMapper.readTree(response.getEntity().getContent()).get("data");
        closeResponse(response);
        assertEquals(2L, dataNode.size());
        assertEquals(firstDeployment.getId(), dataNode.get(0).get("id").textValue());
        assertEquals(secondDeployment.getId(), dataNode.get(1).get("id").textValue());
        // Check ordering by deploy time
        response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT_COLLECTION) + "?sort=deployTime&order=asc"), HttpStatus.SC_OK);
        dataNode = objectMapper.readTree(response.getEntity().getContent()).get("data");
        closeResponse(response);
        assertEquals(2L, dataNode.size());
        assertEquals(firstDeployment.getId(), dataNode.get(0).get("id").textValue());
        assertEquals(secondDeployment.getId(), dataNode.get(1).get("id").textValue());
        // Check ordering by tenantId
        response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT_COLLECTION) + "?sort=tenantId&order=desc"), HttpStatus.SC_OK);
        dataNode = objectMapper.readTree(response.getEntity().getContent()).get("data");
        closeResponse(response);
        assertEquals(2L, dataNode.size());
        assertEquals(secondDeployment.getId(), dataNode.get(0).get("id").textValue());
        assertEquals(firstDeployment.getId(), dataNode.get(1).get("id").textValue());
        // Check paging
        response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT_COLLECTION) + "?sort=deployTime&order=asc&start=1&size=1"), HttpStatus.SC_OK);
        JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
        closeResponse(response);
        dataNode = responseNode.get("data");
        assertEquals(1L, dataNode.size());
        assertEquals(secondDeployment.getId(), dataNode.get(0).get("id").textValue());
        assertEquals(2L, responseNode.get("total").longValue());
        assertEquals(1L, responseNode.get("start").longValue());
        assertEquals(1L, responseNode.get("size").longValue());
    } finally {
        // Always cleanup any created deployments, even if the test failed
        List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
        for (Deployment deployment : deployments) {
            repositoryService.deleteDeployment(deployment.getId(), true);
        }
    }
}
Also used : Calendar(java.util.Calendar) HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) Deployment(org.activiti.engine.repository.Deployment) JsonNode(com.fasterxml.jackson.databind.JsonNode)

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