Search in sources :

Example 86 with Deployment

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

the class SubTaskTest method testSubTaskDeleteOnProcessInstanceDelete.

public void testSubTaskDeleteOnProcessInstanceDelete() {
    Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml").deploy();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.setAssignee(task.getId(), "test");
    Task subTask1 = taskService.newTask();
    subTask1.setName("Sub task 1");
    subTask1.setParentTaskId(task.getId());
    subTask1.setAssignee("test");
    taskService.saveTask(subTask1);
    Task subTask2 = taskService.newTask();
    subTask2.setName("Sub task 2");
    subTask2.setParentTaskId(task.getId());
    subTask2.setAssignee("test");
    taskService.saveTask(subTask2);
    List<Task> tasks = taskService.createTaskQuery().taskAssignee("test").list();
    assertThat(tasks).hasSize(3);
    runtimeService.deleteProcessInstance(processInstance.getId(), "none");
    tasks = taskService.createTaskQuery().taskAssignee("test").list();
    assertThat(tasks).hasSize(0);
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list();
        assertThat(historicTasks).hasSize(3);
        historyService.deleteHistoricProcessInstance(processInstance.getId());
        historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list();
        assertThat(historicTasks).hasSize(0);
    }
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : Task(org.activiti.engine.task.Task) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Deployment(org.activiti.engine.repository.Deployment) ProcessInstance(org.activiti.engine.runtime.ProcessInstance)

Example 87 with Deployment

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

the class VerifyDatabaseOperationsTest method tearDown.

@Override
protected void tearDown() throws Exception {
    processEngineConfiguration.getPerformanceSettings().setEnableEagerExecutionTreeFetching(oldExecutionTreeFetchValue);
    processEngineConfiguration.getPerformanceSettings().setEnableExecutionRelationshipCounts(oldExecutionRelationshipCountValue);
    processEngineConfiguration.setEnableProcessDefinitionInfoCache(oldenableProcessDefinitionInfoCacheValue);
    ((DefaultHistoryManager) processEngineConfiguration.getHistoryManager()).setHistoryLevel(oldHistoryLevel);
    ((CommandExecutorImpl) processEngineConfiguration.getCommandExecutor()).setFirst(oldFirstCommandInterceptor);
    ;
    processEngineConfiguration.addSessionFactory(oldDbSqlSessionFactory);
    // Validate (cause this tended to be screwed up)
    List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().list();
    for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
        assertThat(historicActivityInstance.getStartTime() != null).isTrue();
        assertThat(historicActivityInstance.getEndTime() != null).isTrue();
    }
    ActivitiProfiler.getInstance().reset();
    for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId(), true);
    }
    super.tearDown();
}
Also used : DefaultHistoryManager(org.activiti.engine.impl.history.DefaultHistoryManager) CommandExecutorImpl(org.activiti.engine.impl.cfg.CommandExecutorImpl) Deployment(org.activiti.engine.repository.Deployment) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance)

Example 88 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)

Example 89 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();
    assertThat(deployments).hasSize(1);
    deployment = deployments.get(0);
    assertThat(deployment.getName()).isEqualTo("strings");
    assertThat(deployment.getDeploymentTime()).isNotNull();
    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");
    assertThat(new HashSet<String>(resourceNames)).isEqualTo(expectedResourceNames);
    InputStream resourceStream = repositoryService.getResourceAsStream(deploymentId, "org/activiti/test/HelloWorld.string");
    assertThat(IoUtil.readInputStream(resourceStream, "test")).isEqualTo("hello world".getBytes());
    resourceStream = repositoryService.getResourceAsStream(deploymentId, "org/activiti/test/TheAnswer.string");
    assertThat(IoUtil.readInputStream(resourceStream, "test")).isEqualTo("42".getBytes());
    repositoryService.deleteDeployment(deploymentId);
}
Also used : InputStream(java.io.InputStream) Deployment(org.activiti.engine.repository.Deployment) HashSet(java.util.HashSet)

Example 90 with Deployment

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

the class ProcessRuntimeImplTest method should_throwActivitiObjectNotFoundException_when_canReadFalse.

@Test
public void should_throwActivitiObjectNotFoundException_when_canReadFalse() {
    String processDefinitionId = "processDefinitionId";
    String processDefinitionKey = "processDefinitionKey";
    ProcessDefinitionEntityImpl processDefinition = new ProcessDefinitionEntityImpl();
    processDefinition.setId(processDefinitionId);
    processDefinition.setKey(processDefinitionKey);
    processDefinition.setAppVersion(1);
    List<ProcessDefinition> findProcessDefinitionResult = singletonList(processDefinition);
    Deployment latestDeploymentEntity = new DeploymentEntityImpl();
    DeploymentImpl deployment = new DeploymentImpl();
    deployment.setVersion(1);
    given(deploymentConverter.from(latestDeploymentEntity)).willReturn(deployment);
    given(commandExecutor.execute(any())).willReturn(findProcessDefinitionResult).willReturn(latestDeploymentEntity);
    given(securityPoliciesManager.canRead(processDefinitionKey)).willReturn(false);
    Throwable exception = catchThrowable(() -> processRuntime.processDefinition(processDefinitionId));
    assertThat(exception).isInstanceOf(ActivitiObjectNotFoundException.class).hasMessage("Unable to find process definition for the given id:'processDefinitionId'");
}
Also used : ProcessDefinitionEntityImpl(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl) Deployment(org.activiti.engine.repository.Deployment) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) DeploymentImpl(org.activiti.api.runtime.model.impl.DeploymentImpl) DeploymentEntityImpl(org.activiti.engine.impl.persistence.entity.DeploymentEntityImpl) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) Test(org.junit.jupiter.api.Test)

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