use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.
the class ExpressionResolverTest method resolveExpressionsMap_should_replaceExpressionByValue_when_stringContainsAnExpression.
@Test
public void resolveExpressionsMap_should_replaceExpressionByValue_when_stringContainsAnExpression() {
// given
Expression nameExpression = buildExpression("${name}");
given(expressionEvaluator.evaluate(nameExpression, expressionManager, delegateInterceptor)).willReturn("John");
Expression placeExpression = buildExpression("${place}");
given(expressionEvaluator.evaluate(placeExpression, expressionManager, delegateInterceptor)).willReturn("London");
// when
Map<String, Object> result = expressionResolver.resolveExpressionsMap(expressionEvaluator, singletonMap("welcomeMessage", "Welcome to ${place}, ${name}!"));
// then
assertThat(result).containsEntry("welcomeMessage", "Welcome to London, John!");
}
use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.
the class ExpressionResolverTest method resolveExpressionsMap_should_keepExpressionContent_when_MapContainsAnExpressionUnableToBeResolved.
@Test
public void resolveExpressionsMap_should_keepExpressionContent_when_MapContainsAnExpressionUnableToBeResolved() {
// given
Expression playerExpression = buildExpression("${player}");
given(expressionEvaluator.evaluate(playerExpression, expressionManager, delegateInterceptor)).willThrow(new ActivitiException("Invalid property"));
Map<String, Object> players = map("Red", "John", "Green", "Peter", "Blue", "Mary", "Yellow", "${player}");
// when
Map<String, Object> result = expressionResolver.resolveExpressionsMap(expressionEvaluator, singletonMap("players", players));
// then
assertThat(result).containsEntry("players", players);
}
use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.
the class ExpressionResolverTest method resolveExpressionsMap_should_keepExpressionContent_when_ListContainsAnExpressionUnableToBeResolved.
@Test
public void resolveExpressionsMap_should_keepExpressionContent_when_ListContainsAnExpressionUnableToBeResolved() {
// given
Expression placeExpression = buildExpression("${place}");
given(expressionEvaluator.evaluate(placeExpression, expressionManager, delegateInterceptor)).willThrow(new ActivitiException("Invalid property"));
// when
Map<String, Object> result = expressionResolver.resolveExpressionsMap(expressionEvaluator, singletonMap("places", asList("${place}", "Paris", "Berlin")));
// then
assertThat(result).containsEntry("places", asList("${place}", "Paris", "Berlin"));
}
use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.
the class ExpressionResolverTest method resolveExpressionsMap_should_replaceExpressionByValue_when_ListContainsAnExpression.
@Test
public void resolveExpressionsMap_should_replaceExpressionByValue_when_ListContainsAnExpression() {
// given
Expression placeExpression = buildExpression("${place}");
given(expressionEvaluator.evaluate(placeExpression, expressionManager, delegateInterceptor)).willReturn("London");
// when
Map<String, Object> result = expressionResolver.resolveExpressionsMap(expressionEvaluator, singletonMap("places", asList("${place}", "Paris", "Berlin")));
// then
assertThat(result).containsEntry("places", asList("London", "Paris", "Berlin"));
}
use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.
the class ExpressionResolverTest method buildExpression.
private Expression buildExpression(String expressionContent) {
Expression expression = mock(Expression.class);
given(expressionManager.createExpression(expressionContent)).willReturn(expression);
return expression;
}
Aggregations