Search in sources :

Example 41 with Deployment

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

the class UserTaskTest method testCompleteAfterParallelGateway.

@Deployment
public void testCompleteAfterParallelGateway() throws InterruptedException {
    // related to https://activiti.atlassian.net/browse/ACT-1054
    // start the process
    runtimeService.startProcessInstanceByKey("ForkProcess");
    List<Task> taskList = taskService.createTaskQuery().list();
    assertNotNull(taskList);
    assertEquals(2, taskList.size());
    // make sure user task exists
    Task task = taskService.createTaskQuery().taskDefinitionKey("SimpleUser").singleResult();
    assertNotNull(task);
    // attempt to complete the task and get PersistenceException pointing to "referential integrity constraint violation"
    taskService.complete(task.getId());
}
Also used : Task(org.activiti.engine.task.Task) Deployment(org.activiti.engine.test.Deployment)

Example 42 with Deployment

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

the class TransactionSubProcessTest method testNestedCancelInner.

@Deployment
public void testNestedCancelInner() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("transactionProcess");
    // after the process is started, we have compensate event subscriptions:
    assertEquals(0, createEventSubscriptionQuery().eventType("compensate").activityId("undoBookFlight").count());
    assertEquals(5, createEventSubscriptionQuery().eventType("compensate").activityId("innerTxundoBookHotel").count());
    assertEquals(1, createEventSubscriptionQuery().eventType("compensate").activityId("innerTxundoBookFlight").count());
    // the tasks are present:
    Task taskInner = taskService.createTaskQuery().taskDefinitionKey("innerTxaskCustomer").singleResult();
    Task taskOuter = taskService.createTaskQuery().taskDefinitionKey("bookFlight").singleResult();
    assertNotNull(taskInner);
    assertNotNull(taskOuter);
    // making the tx fail:
    taskService.setVariable(taskInner.getId(), "confirmed", false);
    taskService.complete(taskInner.getId());
    // now the process instance execution is sitting in the 'afterInnerCancellation' task 
    // -> has left the transaction using the cancel boundary event
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getId());
    assertTrue(activeActivityIds.contains("afterInnerCancellation"));
    // we have no more compensate event subscriptions for the inner tx
    assertEquals(0, createEventSubscriptionQuery().eventType("compensate").activityId("innerTxundoBookHotel").count());
    assertEquals(0, createEventSubscriptionQuery().eventType("compensate").activityId("innerTxundoBookFlight").count());
    // we do not have a subscription or the outer tx yet
    assertEquals(0, createEventSubscriptionQuery().eventType("compensate").activityId("undoBookFlight").count());
    // assert that the compensation handlers have been invoked:
    assertEquals(5, runtimeService.getVariable(processInstance.getId(), "innerTxundoBookHotel"));
    assertEquals(1, runtimeService.getVariable(processInstance.getId(), "innerTxundoBookFlight"));
    // if we have history, we check that the invocation of the compensation handlers is recorded in history.
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        assertEquals(5, historyService.createHistoricActivityInstanceQuery().activityId("innerTxundoBookHotel").count());
        assertEquals(1, historyService.createHistoricActivityInstanceQuery().activityId("innerTxundoBookFlight").count());
    }
    // complete the task in the outer tx
    taskService.complete(taskOuter.getId());
    // end the process instance (signal the execution still sitting in afterInnerCancellation)
    runtimeService.signal(runtimeService.createExecutionQuery().activityId("afterInnerCancellation").singleResult().getId());
    assertProcessEnded(processInstance.getId());
    assertEquals(0, runtimeService.createExecutionQuery().count());
}
Also used : Task(org.activiti.engine.task.Task) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 43 with Deployment

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

the class DisabledDefinitionInfoCacheTest method testChangeClassName.

@Deployment
public void testChangeClassName() {
    // first test without changing the class name
    Map<String, Object> varMap = new HashMap<String, Object>();
    varMap.put("count", 0);
    varMap.put("count2", 0);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());
    assertEquals(1, runtimeService.getVariable(processInstance.getId(), "count"));
    assertEquals(0, runtimeService.getVariable(processInstance.getId(), "count2"));
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    // now test with changing the class name
    varMap = new HashMap<String, Object>();
    varMap.put("count", 0);
    varMap.put("count2", 0);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
    String processDefinitionId = processInstance.getProcessDefinitionId();
    ObjectNode infoNode = dynamicBpmnService.changeServiceTaskClassName("service", "org.activiti.engine.test.bpmn.servicetask.DummyServiceTask2");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());
    assertEquals(1, runtimeService.getVariable(processInstance.getId(), "count"));
    assertEquals(0, runtimeService.getVariable(processInstance.getId(), "count2"));
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 44 with Deployment

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

the class DisabledDefinitionInfoCacheTest method testChangeFormKey.

@Deployment
public void testChangeFormKey() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test", task.getFormKey());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskFormKey("task1", "test2");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test", task.getFormKey());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 45 with Deployment

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

the class DynamicUserTaskTest method testChangeOwner.

@Deployment(resources = { "org/activiti/engine/test/bpmn/usertask/DynamicUserTaskTest.assignment.bpmn20.xml" })
public void testChangeOwner() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("ownerTest", task.getOwner());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskOwner("task1", "ownerTest2");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("ownerTest2", task.getOwner());
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

Deployment (org.activiti.engine.test.Deployment)1020 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)709 Task (org.activiti.engine.task.Task)469 HashMap (java.util.HashMap)267 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)180 Execution (org.activiti.engine.runtime.Execution)106 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)87 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)84 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)83 Date (java.util.Date)82 Job (org.activiti.engine.runtime.Job)76 JsonNode (com.fasterxml.jackson.databind.JsonNode)66 Calendar (java.util.Calendar)54 StringEntity (org.apache.http.entity.StringEntity)50 HttpGet (org.apache.http.client.methods.HttpGet)49 ActivitiException (org.activiti.engine.ActivitiException)46 DelegateTask (org.activiti.engine.delegate.DelegateTask)40 ArrayList (java.util.ArrayList)39 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)30 TaskQuery (org.activiti.engine.task.TaskQuery)29