Java Code Examples for org.camunda.bpm.engine.impl.task.TaskDefinition#getTaskListeners()
The following examples show how to use
org.camunda.bpm.engine.impl.task.TaskDefinition#getTaskListeners() .
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: TaskEntity.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected List<TaskListener> getListenersForEvent(String event) { TaskDefinition resolvedTaskDefinition = getTaskDefinition(); if (resolvedTaskDefinition != null) { if (skipCustomListeners) { return resolvedTaskDefinition.getBuiltinTaskListeners(event); } else { return resolvedTaskDefinition.getTaskListeners(event); } } else { return null; } }
Example 2
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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 3
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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 4
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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 5
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testCompleteTaskListenerByClass() { // given: ExtensionElements extensionElements = addExtensionElements(humanTask); CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class); String className = "org.camunda.bpm.test.tasklistener.ABC"; String event = TaskListener.EVENTNAME_COMPLETE; 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 6
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testCompleteTaskListenerByDelegateExpression() { // given: ExtensionElements extensionElements = addExtensionElements(humanTask); CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class); String delegateExpression = "${myDelegateExpression}"; String event = TaskListener.EVENTNAME_COMPLETE; 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 7
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testCompleteTaskListenerByExpression() { // given: ExtensionElements extensionElements = addExtensionElements(humanTask); CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class); String expression = "${myExpression}"; String event = TaskListener.EVENTNAME_COMPLETE; 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 8
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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 9
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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 10
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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()); }
Example 11
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testUpdateTaskListenerByClass() { // given: ExtensionElements extensionElements = addExtensionElements(humanTask); CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class); String className = "org.camunda.bpm.test.tasklistener.ABC"; String event = TaskListener.EVENTNAME_UPDATE; 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 12
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testUpdateTaskListenerByDelegateExpression() { // given: ExtensionElements extensionElements = addExtensionElements(humanTask); CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class); String delegateExpression = "${myDelegateExpression}"; String event = TaskListener.EVENTNAME_UPDATE; 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 13
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testUpdateTaskListenerByExpression() { // given: ExtensionElements extensionElements = addExtensionElements(humanTask); CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class); String expression = "${myExpression}"; String event = TaskListener.EVENTNAME_UPDATE; 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 14
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testDeleteTaskListenerByClass() { // given: ExtensionElements extensionElements = addExtensionElements(humanTask); CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class); String className = "org.camunda.bpm.test.tasklistener.ABC"; String event = TaskListener.EVENTNAME_DELETE; 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 15
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testDeleteTaskListenerByDelegateExpression() { // given: ExtensionElements extensionElements = addExtensionElements(humanTask); CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class); String delegateExpression = "${myDelegateExpression}"; String event = TaskListener.EVENTNAME_DELETE; 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 16
Source File: HumanTaskPlanItemHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testDeleteTaskListenerByExpression() { // given: ExtensionElements extensionElements = addExtensionElements(humanTask); CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class); String expression = "${myExpression}"; String event = TaskListener.EVENTNAME_DELETE; 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()); }