use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class ProcessDefinitionCacheTest method testDeployRevisedProcessAfterDeleteOnOtherProcessEngine.
public void testDeployRevisedProcessAfterDeleteOnOtherProcessEngine() {
// Setup both process engines
ProcessEngine processEngine1 = new StandaloneProcessEngineConfiguration().setProcessEngineName("reboot-test-schema").setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE).setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000").setJobExecutorActivate(false).buildProcessEngine();
RepositoryService repositoryService1 = processEngine1.getRepositoryService();
ProcessEngine processEngine2 = new StandaloneProcessEngineConfiguration().setProcessEngineName("reboot-test").setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE).setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000").setJobExecutorActivate(false).buildProcessEngine();
RepositoryService repositoryService2 = processEngine2.getRepositoryService();
RuntimeService runtimeService2 = processEngine2.getRuntimeService();
TaskService taskService2 = processEngine2.getTaskService();
// Deploy first version of process: start->originalTask->end on first process engine
String deploymentId = repositoryService1.createDeployment().addClasspathResource("org/activiti/engine/test/cache/originalProcess.bpmn20.xml").deploy().getId();
// Start process instance on second engine
String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId();
runtimeService2.startProcessInstanceById(processDefinitionId);
Task task = taskService2.createTaskQuery().singleResult();
assertEquals("original task", task.getName());
// Delete the deployment on second process engine
repositoryService2.deleteDeployment(deploymentId, true);
assertEquals(0, repositoryService2.createDeploymentQuery().count());
assertEquals(0, runtimeService2.createProcessInstanceQuery().count());
// deploy a revised version of the process: start->revisedTask->end on first process engine
//
// Before the bugfix, this would set the cache on the first process engine,
// but the second process engine still has the original process definition in his cache.
// Since there is a deployment delete in between, the new generated process definition id is the same
// as in the original deployment, making the second process engine using the old cached process definition.
deploymentId = repositoryService1.createDeployment().addClasspathResource("org/activiti/engine/test/cache/revisedProcess.bpmn20.xml").deploy().getId();
// Start process instance on second process engine -> must use revised process definition
repositoryService2.createProcessDefinitionQuery().singleResult().getId();
runtimeService2.startProcessInstanceByKey("oneTaskProcess");
task = taskService2.createTaskQuery().singleResult();
assertEquals("revised task", task.getName());
// cleanup
repositoryService1.deleteDeployment(deploymentId, true);
processEngine1.close();
processEngine2.close();
}
use of org.activiti.engine.task.Task 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.task.Task 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.task.Task 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());
}
use of org.activiti.engine.task.Task 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());
}
Aggregations