Search in sources :

Example 41 with Deployment

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

the class DeploymentCategoryTest method testDeploymentCategory.

public void testDeploymentCategory() {
    String noCategoryDeploymentId = null;
    String deploymentOneId = null;
    String deploymentTwoV1Id = null;
    String deploymentTwoV2Id = null;
    String deploymentTwoNoCategory = null;
    try {
        noCategoryDeploymentId = repositoryService.createDeployment().name("0").addClasspathResource("org/activiti/engine/test/service/oneTaskProcess.bpmn20.xml").deploy().getId();
        deploymentOneId = repositoryService.createDeployment().name("1").category("one").addClasspathResource("org/activiti/engine/test/repository/one.bpmn20.xml").deploy().getId();
        deploymentTwoV1Id = repositoryService.createDeployment().name("2v1").category("two").addClasspathResource("org/activiti/engine/test/repository/two.bpmn20.xml").deploy().getId();
        deploymentTwoV2Id = repositoryService.createDeployment().name("2v2").category("two").addClasspathResource("org/activiti/engine/test/repository/two.bpmn20.xml").deploy().getId();
        DeploymentQuery query = repositoryService.createDeploymentQuery();
        assertEquals(4, query.list().size());
        Set<String> deploymentNames = getDeploymentNames(repositoryService.createDeploymentQuery().deploymentCategory("one").list());
        Set<String> expectedDeploymentNames = new HashSet<String>();
        expectedDeploymentNames.add("1");
        assertEquals(expectedDeploymentNames, deploymentNames);
        deploymentNames = getDeploymentNames(repositoryService.createDeploymentQuery().deploymentCategoryNotEquals("two").list());
        expectedDeploymentNames.add("0");
        assertEquals(expectedDeploymentNames, deploymentNames);
        deploymentTwoNoCategory = repositoryService.createDeployment().name("noCategory").addClasspathResource("org/activiti/engine/test/repository/two.bpmn20.xml").deploy().getId();
        Deployment deploymentNoCategory = repositoryService.createDeploymentQuery().deploymentId(deploymentTwoNoCategory).singleResult();
        assertNull(deploymentNoCategory.getCategory());
        repositoryService.setDeploymentCategory(deploymentTwoNoCategory, "newCategory");
        deploymentNoCategory = repositoryService.createDeploymentQuery().deploymentId(deploymentTwoNoCategory).singleResult();
        assertEquals("newCategory", deploymentNoCategory.getCategory());
    } finally {
        if (noCategoryDeploymentId != null)
            undeploy(noCategoryDeploymentId);
        if (deploymentOneId != null)
            undeploy(deploymentOneId);
        if (deploymentTwoV1Id != null)
            undeploy(deploymentTwoV1Id);
        if (deploymentTwoV2Id != null)
            undeploy(deploymentTwoV2Id);
        if (deploymentTwoNoCategory != null)
            undeploy(deploymentTwoNoCategory);
    }
}
Also used : DeploymentQuery(org.activiti.engine.repository.DeploymentQuery) Deployment(org.activiti.engine.repository.Deployment) HashSet(java.util.HashSet)

Example 42 with Deployment

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

the class ModelQueryTest method testByDeploymentId.

public void testByDeploymentId() {
    Deployment deployment = repositoryService.createDeployment().addString("test", "test").deploy();
    assertEquals(0, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
    assertEquals(0, repositoryService.createModelQuery().deployed().count());
    assertEquals(1, repositoryService.createModelQuery().notDeployed().count());
    Model model = repositoryService.createModelQuery().singleResult();
    model.setDeploymentId(deployment.getId());
    repositoryService.saveModel(model);
    assertEquals(1, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
    assertEquals(1, repositoryService.createModelQuery().deployed().count());
    assertEquals(0, repositoryService.createModelQuery().notDeployed().count());
    // Cleanup
    repositoryService.deleteDeployment(deployment.getId(), true);
    // After cleanup the model should still exist
    assertEquals(0, repositoryService.createDeploymentQuery().count());
    assertEquals(0, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
    assertEquals(1, repositoryService.createModelQuery().notDeployed().count());
    assertEquals(1, repositoryService.createModelQuery().count());
}
Also used : Model(org.activiti.engine.repository.Model) Deployment(org.activiti.engine.repository.Deployment)

Example 43 with Deployment

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

the class DeploymentQueryTest method testVerifyDeploymentProperties.

public void testVerifyDeploymentProperties() {
    List<Deployment> deployments = repositoryService.createDeploymentQuery().orderByDeploymentName().asc().list();
    Deployment deploymentOne = deployments.get(0);
    assertEquals("org/activiti/engine/test/repository/one.bpmn20.xml", deploymentOne.getName());
    assertEquals(deploymentOneId, deploymentOne.getId());
    Deployment deploymentTwo = deployments.get(1);
    assertEquals("org/activiti/engine/test/repository/two.bpmn20.xml", deploymentTwo.getName());
    assertEquals(deploymentTwoId, deploymentTwo.getId());
    deployments = repositoryService.createDeploymentQuery().deploymentNameLike("%one%").orderByDeploymentName().asc().list();
    assertEquals("org/activiti/engine/test/repository/one.bpmn20.xml", deployments.get(0).getName());
    assertEquals(1, deployments.size());
    assertEquals(2, repositoryService.createDeploymentQuery().orderByDeploymentId().asc().list().size());
    assertEquals(2, repositoryService.createDeploymentQuery().orderByDeploymenTime().asc().list().size());
}
Also used : Deployment(org.activiti.engine.repository.Deployment)

Example 44 with Deployment

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

the class DeploymentPersistenceTest method testDeploymentPersistence.

public void testDeploymentPersistence() {
    Deployment deployment = repositoryService.createDeployment().name("strings").addString("org/activiti/test/HelloWorld.string", "hello world").addString("org/activiti/test/TheAnswer.string", "42").deploy();
    List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
    assertEquals(1, deployments.size());
    deployment = deployments.get(0);
    assertEquals("strings", deployment.getName());
    assertNotNull(deployment.getDeploymentTime());
    String deploymentId = deployment.getId();
    List<String> resourceNames = repositoryService.getDeploymentResourceNames(deploymentId);
    Set<String> expectedResourceNames = new HashSet<String>();
    expectedResourceNames.add("org/activiti/test/HelloWorld.string");
    expectedResourceNames.add("org/activiti/test/TheAnswer.string");
    assertEquals(expectedResourceNames, new HashSet<String>(resourceNames));
    InputStream resourceStream = repositoryService.getResourceAsStream(deploymentId, "org/activiti/test/HelloWorld.string");
    assertTrue(Arrays.equals("hello world".getBytes(), IoUtil.readInputStream(resourceStream, "test")));
    resourceStream = repositoryService.getResourceAsStream(deploymentId, "org/activiti/test/TheAnswer.string");
    assertTrue(Arrays.equals("42".getBytes(), IoUtil.readInputStream(resourceStream, "test")));
    repositoryService.deleteDeployment(deploymentId);
}
Also used : InputStream(java.io.InputStream) Deployment(org.activiti.engine.repository.Deployment) HashSet(java.util.HashSet)

Example 45 with Deployment

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

the class MultiTenantProcessEngineTest method startProcessInstances.

private void startProcessInstances(String userId) {
    System.out.println();
    System.out.println("Starting process instance for user " + userId);
    tenantInfoHolder.setCurrentUserId(userId);
    Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/engine/test/cfg/multitenant/oneTaskProcess.bpmn20.xml").addClasspathResource("org/activiti/engine/test/cfg/multitenant/jobTest.bpmn20.xml").deploy();
    System.out.println("Process deployed! Deployment id is " + deployment.getId());
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("data", "Hello from " + userId);
    ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", vars);
    List<Task> tasks = processEngine.getTaskService().createTaskQuery().processInstanceId(processInstance.getId()).list();
    System.out.println("Got " + tasks.size() + " tasks");
    System.out.println("Got " + processEngine.getHistoryService().createHistoricProcessInstanceQuery().count() + " process instances in the system");
    // Start a process instance with a Job
    processEngine.getRuntimeService().startProcessInstanceByKey("jobTest");
    tenantInfoHolder.clearCurrentUserId();
    tenantInfoHolder.clearCurrentTenantId();
}
Also used : Task(org.activiti.engine.task.Task) HashMap(java.util.HashMap) Deployment(org.activiti.engine.repository.Deployment) ProcessInstance(org.activiti.engine.runtime.ProcessInstance)

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