Search in sources :

Example 6 with MySpecialTaskListener

use of org.camunda.bpm.engine.test.cmmn.tasklistener.util.MySpecialTaskListener in project camunda-bpm-platform by camunda.

the class TaskListenerTest method testAssignmentListenerByDelegateExpression.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testAssignmentListenerByDelegateExpression.cmmn" })
public void testAssignmentListenerByDelegateExpression() {
    // given
    String caseInstanceId = caseService.withCaseDefinitionByKey("case").setVariable("myTaskListener", new MySpecialTaskListener()).create().getId();
    String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    String taskId = taskService.createTaskQuery().caseExecutionId(humanTaskId).singleResult().getId();
    // when
    taskService.setAssignee(taskId, "jonny");
    // then
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(caseInstanceId);
    assertEquals(4, query.count());
    assertTrue((Boolean) query.variableName("assignment").singleResult().getValue());
    assertEquals(1, query.variableName("assignmentEventCounter").singleResult().getValue());
    assertEquals(1, query.variableName("eventCounter").singleResult().getValue());
}
Also used : VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) MySpecialTaskListener(org.camunda.bpm.engine.test.cmmn.tasklistener.util.MySpecialTaskListener) Matchers.containsString(org.hamcrest.Matchers.containsString) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)6 Deployment (org.camunda.bpm.engine.test.Deployment)6 MySpecialTaskListener (org.camunda.bpm.engine.test.cmmn.tasklistener.util.MySpecialTaskListener)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6