Search in sources :

Example 1 with Functions

use of io.serverlessworkflow.api.workflow.Functions in project kogito-runtimes by kiegroup.

the class BuildExpressionsTest method testReplaceExpr.

@Test
void testReplaceExpr() {
    Workflow flow = mock(Workflow.class);
    FunctionDefinition functionDefinition = new FunctionDefinition();
    functionDefinition.setType(Type.EXPRESSION);
    functionDefinition.setOperation(".pepe");
    functionDefinition.setName("pepe");
    Functions functions = new Functions(Collections.singletonList(functionDefinition));
    when(flow.getFunctions()).thenReturn(functions);
    assertEquals("\"fn:pepe\"", ExpressionHandlerUtils.replaceExpr(flow, "\"fn:pepe\""));
    assertEquals(".pepe", ExpressionHandlerUtils.replaceExpr(flow, "fn:pepe"));
    assertEquals(".pepe", ExpressionHandlerUtils.replaceExpr(flow, "${fn:pepe}"));
    assertThrows(IllegalArgumentException.class, () -> ExpressionHandlerUtils.replaceExpr(flow, "${fn:NoPepe}"));
}
Also used : Workflow(io.serverlessworkflow.api.Workflow) FunctionDefinition(io.serverlessworkflow.api.functions.FunctionDefinition) Functions(io.serverlessworkflow.api.workflow.Functions) Test(org.junit.jupiter.api.Test)

Aggregations

Workflow (io.serverlessworkflow.api.Workflow)1 FunctionDefinition (io.serverlessworkflow.api.functions.FunctionDefinition)1 Functions (io.serverlessworkflow.api.workflow.Functions)1 Test (org.junit.jupiter.api.Test)1