use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.
the class DecisionTaskPlanItemHandlerTest method testExpressionDecisionRef.
@Test
public void testExpressionDecisionRef() {
// given:
String decisionRef = "${aDecisionToCall}";
decisionTask.setDecision(decisionRef);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
DecisionTaskActivityBehavior behavior = (DecisionTaskActivityBehavior) activity.getActivityBehavior();
BaseCallableElement callableElement = behavior.getCallableElement();
ParameterValueProvider caseRefValueProvider = callableElement.getDefinitionKeyValueProvider();
assertNotNull(caseRefValueProvider);
assertTrue(caseRefValueProvider instanceof ElValueProvider);
ElValueProvider valueProvider = (ElValueProvider) caseRefValueProvider;
assertEquals(decisionRef, valueProvider.getExpression().getExpressionText());
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.
the class DecisionTaskPlanItemHandlerTest method testExpressionDecisionRefExpression.
@Test
public void testExpressionDecisionRefExpression() {
// given:
String decision = "${aDecisionToCall}";
DecisionRefExpression decisionRefExpression = createElement(decisionTask, DecisionRefExpression.class);
decisionRefExpression.setText(decision);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
DecisionTaskActivityBehavior behavior = (DecisionTaskActivityBehavior) activity.getActivityBehavior();
BaseCallableElement callableElement = behavior.getCallableElement();
ParameterValueProvider caseRefValueProvider = callableElement.getDefinitionKeyValueProvider();
assertNotNull(caseRefValueProvider);
assertTrue(caseRefValueProvider instanceof ElValueProvider);
ElValueProvider valueProvider = (ElValueProvider) caseRefValueProvider;
assertEquals(decision, valueProvider.getExpression().getExpressionText());
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.
the class DecisionTaskPlanItemHandlerTest method testConstantDecisionRef.
@Test
public void testConstantDecisionRef() {
// given:
String decisionRef = "aDecisionToCall";
decisionTask.setDecision(decisionRef);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
DecisionTaskActivityBehavior behavior = (DecisionTaskActivityBehavior) activity.getActivityBehavior();
BaseCallableElement callableElement = behavior.getCallableElement();
ParameterValueProvider decisionRefValueProvider = callableElement.getDefinitionKeyValueProvider();
assertNotNull(decisionRefValueProvider);
assertTrue(decisionRefValueProvider instanceof ConstantValueProvider);
ConstantValueProvider valueProvider = (ConstantValueProvider) decisionRefValueProvider;
assertEquals(decisionRef, valueProvider.getValue(null));
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.
the class BpmnParseUtil method parseParamValueProvider.
/**
* @throws BpmnParseException if the parameter is invalid
*/
protected static ParameterValueProvider parseParamValueProvider(Element parameterElement) {
// LIST
if ("list".equals(parameterElement.getTagName())) {
List<ParameterValueProvider> providerList = new ArrayList<ParameterValueProvider>();
for (Element element : parameterElement.elements()) {
// parse nested provider
providerList.add(parseParamValueProvider(element));
}
return new ListValueProvider(providerList);
}
// MAP
if ("map".equals(parameterElement.getTagName())) {
TreeMap<ParameterValueProvider, ParameterValueProvider> providerMap = new TreeMap<ParameterValueProvider, ParameterValueProvider>();
for (Element entryElement : parameterElement.elements("entry")) {
// entry must provide key
String keyAttribute = entryElement.attribute("key");
if (keyAttribute == null || keyAttribute.isEmpty()) {
throw new BpmnParseException("Missing attribute 'key' for 'entry' element", entryElement);
}
// parse nested provider
providerMap.put(new ElValueProvider(getExpressionManager().createExpression(keyAttribute)), parseNestedParamValueProvider(entryElement));
}
return new MapValueProvider(providerMap);
}
// SCRIPT
if ("script".equals(parameterElement.getTagName())) {
ExecutableScript executableScript = parseCamundaScript(parameterElement);
if (executableScript != null) {
return new ScriptValueProvider(executableScript);
} else {
return new NullValueProvider();
}
}
String textContent = parameterElement.getText().trim();
if (!textContent.isEmpty()) {
// EL
return new ElValueProvider(getExpressionManager().createExpression(textContent));
} else {
// NULL value
return new NullValueProvider();
}
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.
the class ProcessTaskPlanItemHandlerTest method testBusinessKeyConstant.
@Test
public void testBusinessKeyConstant() {
// given:
String businessKey = "myBusinessKey";
ExtensionElements extensionElements = addExtensionElements(processTask);
CamundaIn businessKeyElement = createElement(extensionElements, null, CamundaIn.class);
businessKeyElement.setCamundaBusinessKey(businessKey);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
ProcessTaskActivityBehavior behavior = (ProcessTaskActivityBehavior) activity.getActivityBehavior();
CallableElement callableElement = behavior.getCallableElement();
ParameterValueProvider businessKeyValueProvider = callableElement.getBusinessKeyValueProvider();
assertNotNull(businessKeyValueProvider);
assertTrue(businessKeyValueProvider instanceof ConstantValueProvider);
assertEquals(businessKey, businessKeyValueProvider.getValue(null));
}
Aggregations