use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.
the class CaseTaskPlanItemHandlerTest method testBusinessKeyConstant.
@Test
public void testBusinessKeyConstant() {
// given:
String businessKey = "myBusinessKey";
ExtensionElements extensionElements = addExtensionElements(caseTask);
CamundaIn businessKeyElement = createElement(extensionElements, null, CamundaIn.class);
businessKeyElement.setCamundaBusinessKey(businessKey);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior();
CallableElement callableElement = behavior.getCallableElement();
ParameterValueProvider businessKeyValueProvider = callableElement.getBusinessKeyValueProvider();
assertNotNull(businessKeyValueProvider);
assertTrue(businessKeyValueProvider instanceof ConstantValueProvider);
assertEquals(businessKey, businessKeyValueProvider.getValue(null));
}
use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.
the class CaseVariableListenerHandlerTest method testDelegateExpressionDelegateHandling.
@Test
public void testDelegateExpressionDelegateHandling() {
ExtensionElements extensionElements = SpecUtil.createElement(modelInstance, caseTask, null, ExtensionElements.class);
CamundaVariableListener variableListener = SpecUtil.createElement(modelInstance, extensionElements, null, CamundaVariableListener.class);
variableListener.setCamundaDelegateExpression("${expression}");
variableListener.setCamundaEvent(CaseVariableListener.CREATE);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
List<VariableListener<?>> listeners = activity.getVariableListenersLocal(CaseVariableListener.CREATE);
Assert.assertEquals(1, listeners.size());
DelegateExpressionCaseVariableListener listener = (DelegateExpressionCaseVariableListener) listeners.get(0);
Assert.assertEquals("${expression}", listener.getExpressionText());
Assert.assertEquals(0, activity.getVariableListenersLocal(CaseVariableListener.UPDATE).size());
Assert.assertEquals(0, activity.getVariableListenersLocal(CaseVariableListener.DELETE).size());
}
use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.
the class CaseVariableListenerHandlerTest method testClassDelegateHandling.
@Test
public void testClassDelegateHandling() {
ExtensionElements extensionElements = SpecUtil.createElement(modelInstance, caseTask, null, ExtensionElements.class);
CamundaVariableListener variableListener = SpecUtil.createElement(modelInstance, extensionElements, null, CamundaVariableListener.class);
CamundaField field = SpecUtil.createElement(modelInstance, variableListener, null, CamundaField.class);
field.setCamundaName("fieldName");
field.setCamundaStringValue("a string value");
variableListener.setCamundaClass("a.class.Name");
// when
CmmnActivity activity = handler.handleElement(planItem, context);
List<VariableListener<?>> listeners = activity.getVariableListenersLocal(CaseVariableListener.CREATE);
Assert.assertEquals(1, listeners.size());
ClassDelegateCaseVariableListener listener = (ClassDelegateCaseVariableListener) listeners.get(0);
Assert.assertEquals("a.class.Name", listener.getClassName());
Assert.assertEquals(1, listener.getFieldDeclarations().size());
Assert.assertEquals("fieldName", listener.getFieldDeclarations().get(0).getName());
Object fieldValue = listener.getFieldDeclarations().get(0).getValue();
assertTrue(fieldValue instanceof Expression);
Expression expressionValue = (Expression) fieldValue;
assertEquals("a string value", expressionValue.getExpressionText());
Assert.assertEquals(listener, activity.getVariableListenersLocal(CaseVariableListener.UPDATE).get(0));
Assert.assertEquals(listener, activity.getVariableListenersLocal(CaseVariableListener.DELETE).get(0));
}
use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method sentryTransformWithMultipleVariableEvent.
@Test
public void sentryTransformWithMultipleVariableEvent() {
// given
ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
CamundaVariableTransitionEvent transitionEvent = createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
transitionEvent.setTextContent("create");
CamundaVariableTransitionEvent additionalTransitionEvent = createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
additionalTransitionEvent.setTextContent("delete");
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());
// when there are multiple variable events then, only first variable event is considered.
assertEquals(VariableTransition.create.name(), transformedVariableOnPart.getVariableEvent());
}
use of org.camunda.bpm.model.cmmn.instance.ExtensionElements in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method sentryTransformWithMultipleVariableOnPart.
@Test
public void sentryTransformWithMultipleVariableOnPart() {
// 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.update);
additionalVariableOnPart.setVariableName("bVariable");
CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
// then
assertNotNull(sentryDeclaration);
List<CmmnVariableOnPartDeclaration> variableOnParts = sentryDeclaration.getVariableOnParts();
assertNotNull(variableOnParts);
assertFalse(variableOnParts.isEmpty());
assertEquals(2, variableOnParts.size());
}
Aggregations