@Before public void initialise() { when(mockEvent.getMessage()).thenReturn(muleMessage); expressionManager = mock(ExtendedExpressionManager.class); when(expressionManager.isValid(anyString())).thenReturn(true); when(expressionManager.validate(anyString())).thenReturn(success()); when(expressionManager.evaluateBoolean(eq(TRUE_EXPRESSION), any(CoreEvent.class), any(ComponentLocation.class), anyBoolean(), anyBoolean())) .thenReturn(true); when(expressionManager.evaluateBoolean(eq(FALSE_EXPRESSION), any(CoreEvent.class), any(ComponentLocation.class), anyBoolean(), anyBoolean())) .thenReturn(false); when(muleContext.getExpressionManager()).thenReturn(expressionManager); flowConstruct = mock(FlowConstruct.class); when(flowConstruct.getMuleContext()).thenReturn(muleContext); when(flowConstruct.getName()).thenReturn("MockedFlowConstruct"); }
@Override public ValidationResult validate(String expression) { if (expression.startsWith(DEFAULT_EXPRESSION_PREFIX)) { if (!expression.endsWith(DEFAULT_EXPRESSION_POSTFIX)) { return failure("Expression string is not an expression", expression); } expression = expression.substring(2, expression.length() - 1); } try { expressionExecutor.validate(expression); } catch (CompileException e) { return failure(e.getMessage(), expression); } return success(); }
return failure(message.toString()); return success();
@Before public void initialise() { when(mockEvent.getMessage()).thenReturn(muleMessage); expressionManager = mock(ExtendedExpressionManager.class); when(expressionManager.isValid(anyString())).thenReturn(true); when(expressionManager.validate(anyString())).thenReturn(success()); when(expressionManager.evaluateBoolean(eq(TRUE_EXPRESSION), any(CoreEvent.class), any(ComponentLocation.class), anyBoolean(), anyBoolean())) .thenReturn(true); when(expressionManager.evaluateBoolean(eq(FALSE_EXPRESSION), any(CoreEvent.class), any(ComponentLocation.class), anyBoolean(), anyBoolean())) .thenReturn(false); when(muleContext.getExpressionManager()).thenReturn(expressionManager); flowConstruct = mock(FlowConstruct.class); when(flowConstruct.getMuleContext()).thenReturn(muleContext); when(flowConstruct.getName()).thenReturn("MockedFlowConstruct"); }