use of org.camunda.bpm.engine.test.cmmn.tasklistener.util.MyTaskListener in project camunda-bpm-platform by camunda.
the class TaskListenerTest method testCreateListenerByExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testCreateListenerByExpression.cmmn" })
public void testCreateListenerByExpression() {
// given
String caseInstanceId = caseService.withCaseDefinitionByKey("case").setVariable("myTaskListener", new MyTaskListener()).create().getId();
// 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());
}
use of org.camunda.bpm.engine.test.cmmn.tasklistener.util.MyTaskListener in project camunda-bpm-platform by camunda.
the class TaskListenerTest method testAllListenerByExpressionExcludingDeletion.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testAllListenerByExpression.cmmn" })
public void testAllListenerByExpressionExcludingDeletion() {
// 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");
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());
}
use of org.camunda.bpm.engine.test.cmmn.tasklistener.util.MyTaskListener in project camunda-bpm-platform by camunda.
the class TaskListenerTest method testDeleteListenerByExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testDeleteListenerByExpression.cmmn" })
public void testDeleteListenerByExpression() {
// given
String caseInstanceId = caseService.withCaseDefinitionByKey("case").setVariable("myTaskListener", new MyTaskListener()).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());
}
use of org.camunda.bpm.engine.test.cmmn.tasklistener.util.MyTaskListener in project camunda-bpm-platform by camunda.
the class TaskListenerTest method testDoesNotImplementTaskListenerInterfaceByDelegateExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testDoesNotImplementTaskListenerInterfaceByDelegateExpression.cmmn" })
public void testDoesNotImplementTaskListenerInterfaceByDelegateExpression() {
try {
caseService.withCaseDefinitionByKey("case").setVariable("myTaskListener", new NotTaskListener()).create().getId();
fail("exception expected");
} catch (Exception e) {
// then
Throwable cause = e.getCause();
String message = cause.getMessage();
assertTextPresent("Delegate expression ${myTaskListener} did not resolve to an implementation of interface " + TaskListener.class.getName(), message);
}
}
use of org.camunda.bpm.engine.test.cmmn.tasklistener.util.MyTaskListener in project camunda-bpm-platform by camunda.
the class TaskListenerTest method testAssignmentListenerByExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/tasklistener/TaskListenerTest.testAssignmentListenerByExpression.cmmn" })
public void testAssignmentListenerByExpression() {
// given
String caseInstanceId = caseService.withCaseDefinitionByKey("case").setVariable("myTaskListener", new MyTaskListener()).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());
}
Aggregations