use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class TaskPriorityExtensionsTest method testPriorityExtensionString.
@Deployment
public void testPriorityExtensionString() throws Exception {
final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("taskPriorityExtensionString");
final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertEquals(42, task.getPriority());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class UserTaskTest method testTaskPropertiesNotNull.
@Deployment
public void testTaskPropertiesNotNull() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task.getId());
assertEquals("my task", task.getName());
assertEquals("Very important", task.getDescription());
assertTrue(task.getPriority() > 0);
assertEquals("kermit", task.getAssignee());
assertEquals(processInstance.getId(), task.getProcessInstanceId());
assertEquals(processInstance.getId(), task.getExecutionId());
assertNotNull(task.getProcessDefinitionId());
assertNotNull(task.getTaskDefinitionKey());
assertNotNull(task.getCreateTime());
// the next test verifies that if an execution creates a task, that no events are created during creation of the task.
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
assertEquals(0, taskService.getTaskEvents(task.getId()).size());
}
}
use of org.activiti.engine.runtime.ProcessInstance 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());
}
use of org.activiti.engine.runtime.ProcessInstance 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());
}
use of org.activiti.engine.runtime.ProcessInstance 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());
}
Aggregations