use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class BusinessProcessBeanTest method testResolveTaskBean.
@Test
@Deployment(resources = "org/activiti/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testResolveTaskBean() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
assertNull(getBeanInstance(Task.class));
assertNull(getBeanInstance("taskId"));
businessProcess.startProcessByKey("businessProcessBeanTest");
String taskId = taskService.createTaskQuery().singleResult().getId();
businessProcess.startTask(taskId);
// assert that now we can resolve the Task-bean
assertEquals(taskId, getBeanInstance(Task.class).getId());
assertEquals(taskId, getBeanInstance("taskId"));
taskService.complete(taskService.createTaskQuery().singleResult().getId());
}
use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class CamelVariableTransferTest method testCamelPropertiesAll.
// check that at least all properties are passed from camel to activiti when copyVariablesFromProperties=true is simply true
@Deployment
public void testCamelPropertiesAll() throws Exception {
ProducerTemplate tpl = camelContext.createProducerTemplate();
Exchange exchange = camelContext.getEndpoint("direct:startAllProperties").createExchange();
tpl.send("direct:startAllProperties", exchange);
assertNotNull(taskService);
assertNotNull(runtimeService);
assertEquals(1, taskService.createTaskQuery().count());
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId());
assertEquals("sampleValueForProperty1", variables.get("property1"));
assertEquals("sampleValueForProperty2", variables.get("property2"));
assertEquals("sampleValueForProperty3", variables.get("property3"));
}
use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class CamelVariableTransferTest method testCamelHeadersAll.
@Deployment(resources = { "org/activiti/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml" })
public void testCamelHeadersAll() throws Exception {
ProducerTemplate tpl = camelContext.createProducerTemplate();
Exchange exchange = camelContext.getEndpoint("direct:startAllProperties").createExchange();
tpl.send("direct:startAllProperties", exchange);
assertNotNull(taskService);
assertNotNull(runtimeService);
assertEquals(1, taskService.createTaskQuery().count());
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId());
assertEquals("sampleValueForProperty1", variables.get("property1"));
assertEquals("sampleValueForProperty2", variables.get("property2"));
assertEquals("sampleValueForProperty3", variables.get("property3"));
}
use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class BusinessProcess method startTask.
// -------------------------------------
/**
* Associates the task with the provided taskId with the current conversation.
* <p/>
*
* @param taskId
* the id of the task
*
* @return the resumed task
*
* @throws ActivitiCdiException
* if no such task is found
*/
public Task startTask(String taskId) {
Task currentTask = associationManager.getTask();
if (currentTask != null && currentTask.getId().equals(taskId)) {
return currentTask;
}
Task task = processEngine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
if (task == null) {
throw new ActivitiCdiException("Cannot resume task with id '" + taskId + "', no such task.");
}
associationManager.setTask(task);
associateExecutionById(task.getExecutionId());
return task;
}
use of org.activiti.engine.task.Task in project Activiti by Activiti.
the class MultiInstanceTest method testSequentialCallActivityWithList.
@Deployment(resources = "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testSequentialCallActivityWithList.bpmn20.xml")
public void testSequentialCallActivityWithList() {
ArrayList<String> list = new ArrayList<String>();
list.add("one");
list.add("two");
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("list", list);
String procId = runtimeService.startProcessInstanceByKey("parentProcess", variables).getId();
Task task1 = taskService.createTaskQuery().processVariableValueEquals("element", "one").singleResult();
Task task2 = taskService.createTaskQuery().processVariableValueEquals("element", "two").singleResult();
assertNotNull(task1);
assertNotNull(task2);
HashMap<String, Object> subVariables = new HashMap<String, Object>();
subVariables.put("x", "y");
taskService.complete(task1.getId(), subVariables);
taskService.complete(task2.getId(), subVariables);
Task task3 = taskService.createTaskQuery().processDefinitionKey("midProcess").singleResult();
assertNotNull(task3);
taskService.complete(task3.getId(), null);
Task task4 = taskService.createTaskQuery().processDefinitionKey("parentProcess").singleResult();
assertNotNull(task4);
taskService.complete(task4.getId(), null);
assertProcessEnded(procId);
}
Aggregations