Search in sources :

Example 36 with Expression

use of org.activiti.engine.delegate.Expression in project herd by FINRAOS.

the class ActivitiHelperTest method testGetExpressionVariableAsIntegerRequiredBlankValue.

@Test
public void testGetExpressionVariableAsIntegerRequiredBlankValue() {
    // Mock dependencies.
    Expression expression = mock(Expression.class);
    DelegateExecution execution = mock(DelegateExecution.class);
    when(expression.getValue(execution)).thenReturn(BLANK_TEXT);
    // Try to call the method under test.
    try {
        activitiHelper.getExpressionVariableAsInteger(expression, execution, VARIABLE_NAME, VARIABLE_REQUIRED);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("\"%s\" must be specified.", VARIABLE_NAME), e.getMessage());
    }
}
Also used : Expression(org.activiti.engine.delegate.Expression) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 37 with Expression

use of org.activiti.engine.delegate.Expression in project herd by FINRAOS.

the class ActivitiHelperTest method testGetRequiredExpressionVariableAsStringBlankValue.

@Test
public void testGetRequiredExpressionVariableAsStringBlankValue() {
    // Mock dependencies.
    Expression expression = mock(Expression.class);
    DelegateExecution execution = mock(DelegateExecution.class);
    when(expression.getValue(execution)).thenReturn(BLANK_TEXT);
    // Try to call the method under test.
    try {
        activitiHelper.getRequiredExpressionVariableAsString(expression, execution, VARIABLE_NAME);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("\"%s\" must be specified.", VARIABLE_NAME), e.getMessage());
    }
}
Also used : Expression(org.activiti.engine.delegate.Expression) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 38 with Expression

use of org.activiti.engine.delegate.Expression in project herd by FINRAOS.

the class ActivitiHelperTest method testGetExpressionVariableAsBooleanRequiredBlankValue.

@Test
public void testGetExpressionVariableAsBooleanRequiredBlankValue() {
    // Mock dependencies.
    Expression expression = mock(Expression.class);
    DelegateExecution execution = mock(DelegateExecution.class);
    when(expression.getValue(execution)).thenReturn(BLANK_TEXT);
    // Try to call the method under test.
    try {
        activitiHelper.getExpressionVariableAsBoolean(expression, execution, VARIABLE_NAME, VARIABLE_REQUIRED, NO_BOOLEAN_DEFAULT_VALUE);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("\"%s\" must be specified.", VARIABLE_NAME), e.getMessage());
    }
}
Also used : Expression(org.activiti.engine.delegate.Expression) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 39 with Expression

use of org.activiti.engine.delegate.Expression in project herd by FINRAOS.

the class ActivitiHelperTest method testGetExpressionVariableAsBooleanBlankValue.

@Test
public void testGetExpressionVariableAsBooleanBlankValue() {
    // Mock dependencies.
    Expression expression = mock(Expression.class);
    DelegateExecution execution = mock(DelegateExecution.class);
    when(expression.getValue(execution)).thenReturn(BLANK_TEXT);
    // Call the method under test.
    Boolean result = activitiHelper.getExpressionVariableAsBoolean(expression, execution, VARIABLE_NAME, NO_VARIABLE_REQUIRED, BOOLEAN_DEFAULT_VALUE);
    // Validate the result.
    assertEquals(BOOLEAN_DEFAULT_VALUE, result);
}
Also used : Expression(org.activiti.engine.delegate.Expression) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 40 with Expression

use of org.activiti.engine.delegate.Expression in project herd by FINRAOS.

the class ActivitiHelperTest method testGetExpressionVariableAsInteger.

@Test
public void testGetExpressionVariableAsInteger() {
    // Mock dependencies.
    Expression expression = mock(Expression.class);
    DelegateExecution execution = mock(DelegateExecution.class);
    when(expression.getValue(execution)).thenReturn(INTEGER_VALUE.toString());
    // Call the method under test.
    Integer result = activitiHelper.getExpressionVariableAsInteger(expression, execution, VARIABLE_NAME, NO_VARIABLE_REQUIRED);
    // Validate the result.
    assertEquals(INTEGER_VALUE, result);
}
Also used : Expression(org.activiti.engine.delegate.Expression) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

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