Search in sources :

Example 1 with MyTaskListener

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());
}
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 2 with MyTaskListener

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());
}
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 3 with MyTaskListener

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());
}
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 4 with MyTaskListener

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);
    }
}
Also used : MySpecialTaskListener(org.camunda.bpm.engine.test.cmmn.tasklistener.util.MySpecialTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) FieldInjectionTaskListener(org.camunda.bpm.engine.test.cmmn.tasklistener.util.FieldInjectionTaskListener) NotTaskListener(org.camunda.bpm.engine.test.cmmn.tasklistener.util.NotTaskListener) MyTaskListener(org.camunda.bpm.engine.test.cmmn.tasklistener.util.MyTaskListener) NotTaskListener(org.camunda.bpm.engine.test.cmmn.tasklistener.util.NotTaskListener) Matchers.containsString(org.hamcrest.Matchers.containsString) ExpectedException(org.junit.rules.ExpectedException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with MyTaskListener

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());
}
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