use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class DynamicServiceTaskTest method testChangeExpression.
@Deployment
public void testChangeExpression() {
// first test without changing the class name
DummyTestBean testBean = new DummyTestBean();
Map<String, Object> varMap = new HashMap<String, Object>();
varMap.put("bean", testBean);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("executed").singleResult();
assertNotNull(historicVariableInstance);
assertTrue((Boolean) historicVariableInstance.getValue());
}
assertProcessEnded(processInstance.getId());
// now test with changing the class name
testBean = new DummyTestBean();
varMap = new HashMap<String, Object>();
varMap.put("bean2", testBean);
processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
String processDefinitionId = processInstance.getProcessDefinitionId();
ObjectNode infoNode = dynamicBpmnService.changeServiceTaskExpression("service", "${bean2.test(execution)}");
dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("executed").singleResult();
assertNotNull(historicVariableInstance);
assertTrue((Boolean) historicVariableInstance.getValue());
}
assertProcessEnded(processInstance.getId());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class DynamicServiceTaskTest 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(0, runtimeService.getVariable(processInstance.getId(), "count"));
assertEquals(1, 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 DynamicServiceTaskTest method testChangeDelegateExpression.
@Deployment
public void testChangeDelegateExpression() {
// first test without changing the class name
DummyTestDelegateBean testBean = new DummyTestDelegateBean();
Map<String, Object> varMap = new HashMap<String, Object>();
varMap.put("bean", testBean);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("executed").singleResult();
assertNotNull(historicVariableInstance);
assertTrue((Boolean) historicVariableInstance.getValue());
}
assertProcessEnded(processInstance.getId());
// now test with changing the class name
testBean = new DummyTestDelegateBean();
varMap = new HashMap<String, Object>();
varMap.put("bean2", testBean);
processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
String processDefinitionId = processInstance.getProcessDefinitionId();
ObjectNode infoNode = dynamicBpmnService.changeServiceTaskDelegateExpression("service", "${bean2}");
dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("executed").singleResult();
assertNotNull(historicVariableInstance);
assertTrue((Boolean) historicVariableInstance.getValue());
}
assertProcessEnded(processInstance.getId());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class CallActivityTest method testInstantiateChildProcess.
public void testInstantiateChildProcess() throws Exception {
BpmnModel childBpmnModel = loadBPMNModel(CHILD_PROCESS_RESOURCE);
Deployment childDeployment = processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
ProcessInstance childProcessInstance = runtimeService.startProcessInstanceByKey("childProcess");
assertNotNull(childProcessInstance);
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class CallActivityTest method testInstantiateSubprocess.
public void testInstantiateSubprocess() throws Exception {
BpmnModel mainBpmnModel = loadBPMNModel(MAIN_PROCESS_RESOURCE);
BpmnModel childBpmnModel = loadBPMNModel(CHILD_PROCESS_RESOURCE);
Deployment childDeployment = processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
Deployment masterDeployment = processEngine.getRepositoryService().createDeployment().name("masterProcessDeployment").addBpmnModel("masterProcess.bpmn20.xml", mainBpmnModel).deploy();
suspendProcessDefinitions(childDeployment);
try {
ProcessInstance masterProcessInstance = runtimeService.startProcessInstanceByKey("masterProcess");
fail("Exception expected");
} catch (ActivitiException ae) {
assertTextPresent("Cannot start process instance. Process definition Child Process", ae.getMessage());
}
}
Aggregations