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}"));
}
Aggregations