use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class BusinessProcessBeanTest method testStopTask.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testStopTask() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
// cannot stop task in absence of an association:
try {
businessProcess.stopTask();
fail();
} catch (ProcessEngineCdiException e) {
assertEquals("No task associated. Call businessProcess.startTask() first.", e.getMessage());
}
// start the process
String processInstanceId = businessProcess.startProcessByKey("businessProcessBeanTest", Collections.singletonMap("key", (Object) "value")).getId();
assertEquals("value", runtimeService.getVariable(processInstanceId, "key"));
businessProcess.startTask(taskService.createTaskQuery().singleResult().getId());
// assignee is not set to jonny
assertNull(taskService.createTaskQuery().taskAssignee("jonny").singleResult());
Task task = businessProcess.getTask();
task.setAssignee("jonny");
// if we stop the task
businessProcess.stopTask();
// THEN
// assignee is not set to jonny
assertNull(taskService.createTaskQuery().taskAssignee("jonny").singleResult());
// business process is not associated with task:
assertFalse(businessProcess.isTaskAssociated());
assertFalse(businessProcess.isAssociated());
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class BusinessProcessBeanTest method testSaveTask.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testSaveTask() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
// cannot save task in absence of an association:
try {
businessProcess.saveTask();
fail();
} catch (ProcessEngineCdiException e) {
assertEquals("No task associated. Call businessProcess.startTask() first.", e.getMessage());
}
// start the process
String processInstanceId = businessProcess.startProcessByKey("businessProcessBeanTest", Collections.singletonMap("key", (Object) "value")).getId();
assertEquals("value", runtimeService.getVariable(processInstanceId, "key"));
businessProcess.startTask(taskService.createTaskQuery().singleResult().getId());
// assignee is not set to jonny
assertNull(taskService.createTaskQuery().taskAssignee("jonny").singleResult());
Task task = businessProcess.getTask();
task.setAssignee("jonny");
assertNull(taskService.createTaskQuery().taskAssignee("jonny").singleResult());
// if we save the task
businessProcess.saveTask();
// THEN
// assignee is now set to jonny
assertNotNull(taskService.createTaskQuery().taskAssignee("jonny").singleResult());
// business process is still associated with task:
assertTrue(businessProcess.isTaskAssociated());
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class CompleteTaskTest method testCompleteTask.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testCompleteTask() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
businessProcess.startProcessByKey("keyOfTheProcess");
Task task = taskService.createTaskQuery().singleResult();
// associate current unit of work with the task:
businessProcess.startTask(task.getId());
getBeanInstance(DeclarativeProcessController.class).completeTask();
// assert that now the task is completed
assertNull(taskService.createTaskQuery().singleResult());
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ConnectProcessEnginePluginTest method testConnectorBpmnErrorThrownInScriptResourceInputMappingIsHandledByBoundaryEvent.
@Deployment(resources = "org/camunda/connect/plugin/ConnectProcessEnginePluginTest.testConnectorWithThrownExceptionInScriptResourceInputOutputMapping.bpmn")
public void testConnectorBpmnErrorThrownInScriptResourceInputMappingIsHandledByBoundaryEvent() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("throwInMapping", "in");
variables.put("exception", new BpmnError("error"));
runtimeService.startProcessInstanceByKey("testProcess", variables);
// we will only reach the user task if the BPMNError from the script was handled by the boundary event
Task task = taskService.createTaskQuery().singleResult();
assertThat(task.getName(), is("User Task"));
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ConnectProcessEnginePluginTest method testConnectorBpmnErrorThrownInScriptInputMappingIsHandledByBoundaryEvent.
@Deployment(resources = "org/camunda/connect/plugin/ConnectProcessEnginePluginTest.testConnectorWithThrownExceptionInScriptInputOutputMapping.bpmn")
public void testConnectorBpmnErrorThrownInScriptInputMappingIsHandledByBoundaryEvent() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("throwInMapping", "in");
variables.put("exception", new BpmnError("error"));
runtimeService.startProcessInstanceByKey("testProcess", variables);
// we will only reach the user task if the BPMNError from the script was handled by the boundary event
Task task = taskService.createTaskQuery().singleResult();
assertThat(task.getName(), is("User Task"));
}
Aggregations