Search in sources :

Example 1 with MySpecialTaskListener

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

the class TaskListenerTest method testCreateListenerByDelegateExpression.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testCreateListenerByDelegateExpression.cmmn" })
public void testCreateListenerByDelegateExpression() {
    // given
    String caseInstanceId = caseService.withCaseDefinitionByKey("case").setVariable("myTaskListener", new MySpecialTaskListener()).create().getId();
    String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    // when
    // then
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(caseInstanceId);
    assertEquals(4, query.count());
    assertTrue((Boolean) query.variableName("create").singleResult().getValue());
    assertEquals(1, query.variableName("createEventCounter").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)

Example 2 with MySpecialTaskListener

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

the class TaskListenerTest method testDeleteListenerByDelegateExpression.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testDeleteListenerByDelegateExpression.cmmn" })
public void testDeleteListenerByDelegateExpression() {
    // given
    String caseInstanceId = caseService.withCaseDefinitionByKey("case").setVariable("myTaskListener", new MySpecialTaskListener()).create().getId();
    String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    // when
    terminate(humanTaskId);
    // then
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(caseInstanceId);
    assertEquals(4, query.count());
    assertTrue((Boolean) query.variableName("delete").singleResult().getValue());
    assertEquals(1, query.variableName("deleteEventCounter").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)

Example 3 with MySpecialTaskListener

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

the class TaskListenerTest method testCompleteListenerByDelegateExpression.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testCompleteListenerByDelegateExpression.cmmn" })
public void testCompleteListenerByDelegateExpression() {
    // given
    String caseInstanceId = caseService.withCaseDefinitionByKey("case").setVariable("myTaskListener", new MySpecialTaskListener()).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 : 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)

Example 4 with MySpecialTaskListener

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

the class TaskListenerTest method testAllListenerByDelegateExpressionExcludingDeletion.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testAllListenerByDelegateExpression.cmmn" })
public void testAllListenerByDelegateExpressionExcludingDeletion() {
    // given
    String caseInstanceId = caseService.withCaseDefinitionByKey("case").setVariable("myTaskListener", new MySpecialTaskListener()).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");
    caseService.withCaseExecution(humanTaskId).complete();
    // 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("complete").singleResult().getValue());
    assertEquals(1, query.variableName("completeEventCounter").singleResult().getValue());
    assertEquals(3, 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)

Example 5 with MySpecialTaskListener

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

the class TaskListenerTest method testAllListenerByDelegateExpressionExcludingCompletion.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testAllListenerByDelegateExpression.cmmn" })
public void testAllListenerByDelegateExpressionExcludingCompletion() {
    // given
    String caseInstanceId = caseService.withCaseDefinitionByKey("case").setVariable("myTaskListener", new MySpecialTaskListener()).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 : 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