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

The following examples show how to use org.camunda.bpm.engine.delegate.TaskListener#EVENTNAME_CREATE . 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 5 votes vote down vote up
@Test
public void testNewKeyInStartTaskListener() {
  // given
  String listener = TaskListener.EVENTNAME_CREATE;
  BpmnModelInstance process = createModelTaskListener(listener);
  testRule.deploy(process);

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

  // then
  checkBusinessKeyChanged(newBusinessKeyValue);
}
 
Example 2
Source File: SetBusinessKeyTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testUpdateKeyNullValueInStartTaskListener() {
  // given
  String listener = TaskListener.EVENTNAME_CREATE;
  BpmnModelInstance process = createModelTaskListener(listener);
  testRule.deploy(process);

  // when
  String newBusinessKeyValue = null;
  runtimeService.startProcessInstanceByKey(PROCESS_KEY, "aBusinessKey", Variables.createVariables().putValue(BUSINESS_KEY_VARIABLE, newBusinessKeyValue));

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

  String className = "org.camunda.bpm.test.tasklistener.ABC";
  String event = TaskListener.EVENTNAME_CREATE;
  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 testCreateTaskListenerByDelegateExpression() {
  // given:
  ExtensionElements extensionElements = addExtensionElements(humanTask);
  CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);

  String delegateExpression = "${myDelegateExpression}";
  String event = TaskListener.EVENTNAME_CREATE;
  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 testCreateTaskListenerByExpression() {
  // given:
  ExtensionElements extensionElements = addExtensionElements(humanTask);
  CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);

  String expression = "${myExpression}";
  String event = TaskListener.EVENTNAME_CREATE;
  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());

}
 
Example 6
Source File: UserTaskBpmnModelExecutionContextTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldGetBpmnModelElementInstanceOnCreate() {
  String eventName = TaskListener.EVENTNAME_CREATE;
  deployProcess(eventName);

  runtimeService.startProcessInstanceByKey(PROCESS_ID);

  assertModelInstance();
  assertUserTask(eventName);
}