### Question:
DefaultExpressionEvaluator implements ExpressionEvaluator { @Override public <T> T evaluate(Expression expression, ExecutionContext context, Class<T> expectedType) { Object expressionValue = evaluateExpression(expression, context); if (!expressionValue.getClass().isAssignableFrom(expectedType)) { throw new IllegalArgumentException("the expression " + expression + "did not evaluate to expected result type: " + expectedType); } return expectedType.cast(expressionValue); }  @Override T evaluate(Expression expression, ExecutionContext context, Class<T> expectedType);  }### Answer:
@Test public void shouldEvaluatePropertyPredicate() { BrainslugExecutionContext executionContext = testContext(); DefaultExpressionEvaluator evaluator = new DefaultExpressionEvaluator(); PropertyPredicate predicateSpy = spy(new PropertyPredicate() { @Override public boolean isFulfilled(FlowInstanceProperties executionProperties) { Assertions.assertThat(executionProperties).isNotNull(); return false; } }); PredicateExpression predicateDefintion = new PredicateExpression<PropertyPredicate>(predicateSpy); boolean result = evaluator.evaluate(predicateDefintion, executionContext, Boolean.class); verify(predicateSpy).isFulfilled(any(ExecutionProperties.class)); Assertions.assertThat(result).isFalse(); }
@Test public void shouldEvaluateContextPredicate() { DefaultExpressionEvaluator evaluator = new DefaultExpressionEvaluator(); BrainslugExecutionContext executionContext = testContext(); ContextPredicate predicateSpy = spy(new ContextPredicate() { @Override public boolean isFulfilled(ExecutionContext executionContext) { Assertions.assertThat(executionContext).isNotNull(); return true; } }); PredicateExpression predicateDefintion = new PredicateExpression<ContextPredicate>(predicateSpy); boolean result = evaluator.evaluate(predicateDefintion, executionContext, Boolean.class); verify(predicateSpy).isFulfilled(any(ExecutionContext.class)); Assertions.assertThat(result).isTrue(); }