Java Code Examples for org.camunda.bpm.engine.delegate.TaskListener#EVENTNAME_ASSIGNMENT

The following examples show how to use org.camunda.bpm.engine.delegate.TaskListener#EVENTNAME_ASSIGNMENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetBusinessKeyTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testNewKeyInAssignTaskListener() {
  // given
  String listener = TaskListener.EVENTNAME_ASSIGNMENT;
  BpmnModelInstance process = createModelTaskListener(listener);
  testRule.deploy(process);

  String newBusinessKeyValue = "newBusinessKey";
  runtimeService.startProcessInstanceByKey(PROCESS_KEY, Variables.createVariables().putValue(BUSINESS_KEY_VARIABLE, newBusinessKeyValue));

  // when
  taskService.setAssignee(taskService.createTaskQuery().singleResult().getId(), "newUserId");

  // then
  checkBusinessKeyChanged(newBusinessKeyValue);
}
 
Example 2
Source File: UserTaskBpmnModelExecutionContextTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGetBpmnModelElementInstanceOnAssignment() {
  String eventName = TaskListener.EVENTNAME_ASSIGNMENT;
  deployProcess(eventName);

  runtimeService.startProcessInstanceByKey(PROCESS_ID);

  assertNull(ModelExecutionContextTaskListener.modelInstance);
  assertNull(ModelExecutionContextTaskListener.userTask);

  String taskId = taskService.createTaskQuery().singleResult().getId();
  taskService.setAssignee(taskId, "demo");

  assertModelInstance();
  assertUserTask(eventName);
}
 
Example 3
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testAssignmentTaskListenerByClass() {
  // given:
  ExtensionElements extensionElements = addExtensionElements(humanTask);
  CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);

  String className = "org.camunda.bpm.test.tasklistener.ABC";
  String event = TaskListener.EVENTNAME_ASSIGNMENT;
  taskListener.setCamundaEvent(event);
  taskListener.setCamundaClass(className);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  assertEquals(0, activity.getListeners().size());

  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  assertNotNull(taskDefinition);

  assertEquals(1, taskDefinition.getTaskListeners().size());

  List<TaskListener> createListeners = taskDefinition.getTaskListeners(event);
  assertEquals(1, createListeners.size());
  TaskListener listener = createListeners.get(0);

  assertTrue(listener instanceof ClassDelegateTaskListener);

  ClassDelegateTaskListener classDelegateListener = (ClassDelegateTaskListener) listener;
  assertEquals(className, classDelegateListener.getClassName());
  assertTrue(classDelegateListener.getFieldDeclarations().isEmpty());

}
 
Example 4
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testAssignmentTaskListenerByDelegateExpression() {
  // given:
  ExtensionElements extensionElements = addExtensionElements(humanTask);
  CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);

  String delegateExpression = "${myDelegateExpression}";
  String event = TaskListener.EVENTNAME_ASSIGNMENT;
  taskListener.setCamundaEvent(event);
  taskListener.setCamundaDelegateExpression(delegateExpression);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  assertEquals(0, activity.getListeners().size());

  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  assertNotNull(taskDefinition);

  assertEquals(1, taskDefinition.getTaskListeners().size());

  List<TaskListener> createListeners = taskDefinition.getTaskListeners(event);
  assertEquals(1, createListeners.size());
  TaskListener listener = createListeners.get(0);

  assertTrue(listener instanceof DelegateExpressionTaskListener);

  DelegateExpressionTaskListener delegateExpressionListener = (DelegateExpressionTaskListener) listener;
  assertEquals(delegateExpression, delegateExpressionListener.getExpressionText());
  assertTrue(delegateExpressionListener.getFieldDeclarations().isEmpty());

}
 
Example 5
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testAssignmentTaskListenerByExpression() {
  // given:
  ExtensionElements extensionElements = addExtensionElements(humanTask);
  CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);

  String expression = "${myExpression}";
  String event = TaskListener.EVENTNAME_ASSIGNMENT;
  taskListener.setCamundaEvent(event);
  taskListener.setCamundaExpression(expression);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  assertEquals(0, activity.getListeners().size());

  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  assertNotNull(taskDefinition);

  assertEquals(1, taskDefinition.getTaskListeners().size());

  List<TaskListener> createListeners = taskDefinition.getTaskListeners(event);
  assertEquals(1, createListeners.size());
  TaskListener listener = createListeners.get(0);

  assertTrue(listener instanceof ExpressionTaskListener);

  ExpressionTaskListener expressionListener = (ExpressionTaskListener) listener;
  assertEquals(expression, expressionListener.getExpressionText());

}