use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method sentryTransformShouldFailWithMissingVariableName.
@Test
public void sentryTransformShouldFailWithMissingVariableName() {
// given
ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
variableOnPart.setVariableEvent(VariableTransition.create);
thrown.expect(CmmnTransformException.class);
thrown.expectMessage("The variableOnPart of the sentry with id 'aSentry' must have variable name.");
sentryHandler.handleElement(sentry, context);
}
use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method sentryTransformShouldFailWithInvalidVariableEvent.
@Test
public void sentryTransformShouldFailWithInvalidVariableEvent() {
// given
ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
CamundaVariableTransitionEvent transitionEvent = createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
transitionEvent.setTextContent("invalid");
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);
}
use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method sentryTransformWithVariableOnPart.
// variableOnParts
@Test
public void sentryTransformWithVariableOnPart() {
// 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");
CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
// then
assertNotNull(sentryDeclaration);
List<CmmnVariableOnPartDeclaration> variableOnParts = sentryDeclaration.getVariableOnParts();
assertNotNull(variableOnParts);
assertFalse(variableOnParts.isEmpty());
assertEquals(1, variableOnParts.size());
CmmnVariableOnPartDeclaration transformedVariableOnPart = variableOnParts.get(0);
assertEquals("aVariable", transformedVariableOnPart.getVariableName());
assertEquals(VariableTransition.create.name(), transformedVariableOnPart.getVariableEvent());
}
use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testAssignmentTaskListenerByDelegateExpression.
@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());
}
use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testCompleteTaskListenerByDelegateExpression.
@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());
}
Aggregations