Search in sources :

Example 1 with ExtensionElements

use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.

the class SentryHandlerTest method sentryTransformShouldFailWithMissingVariableEvent.

@Test
public void sentryTransformShouldFailWithMissingVariableEvent() {
    // given
    ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
    CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    variableOnPart.setVariableName("aVariable");
    thrown.expect(CmmnTransformException.class);
    thrown.expectMessage("The variableOnPart of the sentry with id 'aSentry' must have one valid variable event.");
    sentryHandler.handleElement(sentry, context);
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) CamundaVariableOnPart(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart) Test(org.junit.Test)

Example 2 with ExtensionElements

use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.

the class SentryHandlerTest method sentryTransformWithSameVariableOnPartTwice.

@Test
public void sentryTransformWithSameVariableOnPartTwice() {
    // given
    ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
    CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
    variableOnPart.setVariableEvent(VariableTransition.create);
    variableOnPart.setVariableName("aVariable");
    CamundaVariableOnPart additionalVariableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    createElement(additionalVariableOnPart, null, CamundaVariableTransitionEvent.class);
    additionalVariableOnPart.setVariableEvent(VariableTransition.create);
    additionalVariableOnPart.setVariableName("aVariable");
    CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
    // then
    assertNotNull(sentryDeclaration);
    List<CmmnVariableOnPartDeclaration> variableOnParts = sentryDeclaration.getVariableOnParts();
    assertNotNull(variableOnParts);
    assertFalse(variableOnParts.isEmpty());
    assertEquals(1, variableOnParts.size());
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) CmmnVariableOnPartDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration) CamundaVariableOnPart(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart) Test(org.junit.Test)

Example 3 with ExtensionElements

use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testDeleteTaskListenerByExpression.

@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());
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 4 with ExtensionElements

use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testAssignmentTaskListenerByClass.

@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());
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) Test(org.junit.Test)

Example 5 with ExtensionElements

use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testAssignmentTaskListenerByExpression.

@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());
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Aggregations

ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)48 Test (org.junit.Test)46 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)39 CallableElement (org.camunda.bpm.engine.impl.core.model.CallableElement)24 CallableElementParameter (org.camunda.bpm.engine.impl.core.model.CallableElementParameter)20 CamundaIn (org.camunda.bpm.model.cmmn.instance.camunda.CamundaIn)14 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)12 CaseTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.CaseTaskActivityBehavior)12 HumanTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)12 ProcessTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.ProcessTaskActivityBehavior)12 ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)12 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)12 ClassDelegateTaskListener (org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener)12 DelegateExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener)12 ExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener)12 CamundaTaskListener (org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener)12 CamundaOut (org.camunda.bpm.model.cmmn.instance.camunda.CamundaOut)10 CamundaVariableOnPart (org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart)7 ConstantValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider)6 ElValueProvider (org.camunda.bpm.engine.impl.el.ElValueProvider)6