Search in sources :

Example 51 with Expression

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!");
}
Also used : Expression(org.activiti.engine.delegate.Expression) Test(org.junit.jupiter.api.Test)

Example 52 with Expression

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);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) Expression(org.activiti.engine.delegate.Expression) Test(org.junit.jupiter.api.Test)

Example 53 with Expression

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"));
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) Expression(org.activiti.engine.delegate.Expression) Test(org.junit.jupiter.api.Test)

Example 54 with Expression

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"));
}
Also used : Expression(org.activiti.engine.delegate.Expression) Test(org.junit.jupiter.api.Test)

Example 55 with Expression

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;
}
Also used : Expression(org.activiti.engine.delegate.Expression)

Aggregations

Expression (org.activiti.engine.delegate.Expression)61 ActivitiException (org.activiti.engine.ActivitiException)17 DelegateExecution (org.activiti.engine.delegate.DelegateExecution)13 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)12 Test (org.junit.Test)12 Test (org.junit.jupiter.api.Test)12 ExpressionManager (org.activiti.engine.impl.el.ExpressionManager)11 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)8 Condition (org.activiti.engine.impl.Condition)6 Date (java.util.Date)5 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)5 BusinessCalendar (org.activiti.engine.impl.calendar.BusinessCalendar)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)4 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ArrayList (java.util.ArrayList)3 VariableScope (org.activiti.engine.delegate.VariableScope)3 CycleBusinessCalendar (org.activiti.engine.impl.calendar.CycleBusinessCalendar)3 DueDateBusinessCalendar (org.activiti.engine.impl.calendar.DueDateBusinessCalendar)3