use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class PvmTestCase method defaultManualActivation.
public Object defaultManualActivation() {
Expression expression = new FixedValue(true);
CaseControlRuleImpl caseControlRule = new CaseControlRuleImpl(expression);
return caseControlRule;
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class ScriptUtil method getScriptFromResource.
/**
* Creates a new {@link ExecutableScript} from a resource. It excepts static and dynamic resources.
* Dynamic means that the resource is an expression which will be evaluated during execution.
*
* @param language the language of the script
* @param resource the resource path of the script code or an expression which evaluates to the resource path
* @param expressionManager the expression manager to use to generate the expressions of dynamic scripts
* @param scriptFactory the script factory used to create the script
* @return the newly created script
* @throws NotValidException if language or resource are null or empty
*/
public static ExecutableScript getScriptFromResource(String language, String resource, ExpressionManager expressionManager, ScriptFactory scriptFactory) {
ensureNotEmpty(NotValidException.class, "Script language", language);
ensureNotEmpty(NotValidException.class, "Script resource", resource);
if (isDynamicScriptExpression(language, resource)) {
Expression resourceExpression = expressionManager.createExpression(resource);
return getScriptFromResourceExpression(language, resourceExpression, scriptFactory);
} else {
return getScriptFromResource(language, resource, scriptFactory);
}
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method testSentryWithIfPartWithMultipleCondition.
@Test
public void testSentryWithIfPartWithMultipleCondition() {
// given
IfPart ifPart = createElement(sentry, "abc", IfPart.class);
ConditionExpression firstConditionExpression = createElement(ifPart, "con_1", ConditionExpression.class);
Body firstBody = createElement(firstConditionExpression, null, Body.class);
String firstExpression = "${firstExpression}";
firstBody.setTextContent(firstExpression);
ConditionExpression secondConditionExpression = createElement(ifPart, "con_2", ConditionExpression.class);
Body secondBody = createElement(secondConditionExpression, null, Body.class);
String secondExpression = "${secondExpression}";
secondBody.setTextContent(secondExpression);
// when
CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
// then
assertNotNull(sentryDeclaration);
CmmnIfPartDeclaration ifPartDeclaration = sentryDeclaration.getIfPart();
assertNotNull(ifPartDeclaration);
Expression condition = ifPartDeclaration.getCondition();
assertNotNull(condition);
assertEquals(firstExpression, condition.getExpressionText());
// the second condition will be ignored!
assertTrue(sentryDeclaration.getOnParts().isEmpty());
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testTaskDefinitionPlanItemNameExpression.
@Test
public void testTaskDefinitionPlanItemNameExpression() {
// given
String name = "A HumanTask";
humanTask.setName(name);
String planItemName = "My LocalName";
planItem.setName(planItemName);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
TaskDefinition taskDefinition = behavior.getTaskDefinition();
Expression nameExpression = taskDefinition.getNameExpression();
assertNotNull(nameExpression);
assertEquals("My LocalName", nameExpression.getExpressionText());
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testTaskDefinitionDueDateExpression.
@Test
public void testTaskDefinitionDueDateExpression() {
// given
String aDueDate = "aDueDate";
humanTask.setCamundaDueDate(aDueDate);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
TaskDefinition taskDefinition = behavior.getTaskDefinition();
Expression dueDateExpression = taskDefinition.getDueDateExpression();
assertNotNull(dueDateExpression);
assertEquals(aDueDate, dueDateExpression.getExpressionText());
}
Aggregations