Search in sources :

Example 6 with MyTaskListener

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

the class TaskListenerTest method testAllListenerByExpressionExcludingCompletion.

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

Example 7 with MyTaskListener

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

the class TaskListenerTest method testCompleteListenerByExpression.

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

Aggregations

Deployment (org.camunda.bpm.engine.test.Deployment)7 MyTaskListener (org.camunda.bpm.engine.test.cmmn.tasklistener.util.MyTaskListener)7 Matchers.containsString (org.hamcrest.Matchers.containsString)7 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)6 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)1 FieldInjectionTaskListener (org.camunda.bpm.engine.test.cmmn.tasklistener.util.FieldInjectionTaskListener)1 MySpecialTaskListener (org.camunda.bpm.engine.test.cmmn.tasklistener.util.MySpecialTaskListener)1 NotTaskListener (org.camunda.bpm.engine.test.cmmn.tasklistener.util.NotTaskListener)1 ExpectedException (org.junit.rules.ExpectedException)1