class AbstractRunnerHelper {

    protected ScenarioResult fillResult(FactMappingValue expectedResult,
                                        Supplier<ValueWrapper<?>> resultSupplier,
                                        ExpressionEvaluator expressionEvaluator) {
        ValueWrapper<?> resultValue = resultSupplier.get();

        if (resultValue.isValid()) {
            // result is satisfied so clean up previous error state
            expectedResult.resetStatus();
        } else if (resultValue.getErrorMessage().isPresent()) {
            // propagate error message
            expectedResult.setExceptionMessage(resultValue.getErrorMessage().get());
        } else {
            try {
                // set actual as proposed value
                expectedResult.setErrorValue(expressionEvaluator.fromObjectToExpression(resultValue.getValue()));
            } catch (Exception e) {
                // otherwise generic error message
                expectedResult.setExceptionMessage(e.getMessage());
            }
        }

        return new ScenarioResult(expectedResult, resultValue.getValue()).setResult(resultValue.isValid());
    }

}