AbstractRunnerHelper { protected ValueWrapper getResultWrapper(String className, FactMappingValue expectedResult, ExpressionEvaluator expressionEvaluator, Object expectedResultRaw, Object resultRaw, Class<?> resultClass) { try { boolean evaluationSucceed = expressionEvaluator.evaluateUnaryExpression((String) expectedResultRaw, resultRaw, resultClass); if (evaluationSucceed) { return of(resultRaw); } else if (isCollection(className)) { return errorWithMessage("Impossible to find elements in the collection to satisfy the conditions"); } else { return errorWithValidValue(resultRaw, expectedResultRaw); } } catch (Exception e) { expectedResult.setExceptionMessage(e.getMessage()); return errorWithMessage(e.getMessage()); } }  void run(KieContainer kieContainer,
                    ScesimModelDescriptor scesimModelDescriptor,
                    ScenarioWithIndex scenarioWithIndex,
                    ExpressionEvaluatorFactory expressionEvaluatorFactory,
                    ClassLoader classLoader,
                    ScenarioRunnerData scenarioRunnerData,
                    Settings settings,
                    Background background);  }
@Test public void getResultWrapper() { ExpressionEvaluator expressionEvaluatorMock = mock(ExpressionEvaluator.class); Object resultRaw = "test"; Object expectedResultRaw = ""; String collectionError = "Impossible to find elements in the collection to satisfy the conditions"; String genericErrorMessage = "errorMessage"; when(expressionEvaluatorMock.evaluateUnaryExpression(any(), any(), any(Class.class))).thenReturn(true); ValueWrapper valueWrapper = abstractRunnerHelper.getResultWrapper(String.class.getCanonicalName(), new FactMappingValue(), expressionEvaluatorMock, expectedResultRaw, resultRaw, String.class); assertTrue(valueWrapper.isValid()); when(expressionEvaluatorMock.evaluateUnaryExpression(any(), any(), any(Class.class))).thenReturn(false); valueWrapper = abstractRunnerHelper.getResultWrapper(String.class.getCanonicalName(), new FactMappingValue(), expressionEvaluatorMock, expectedResultRaw, resultRaw, String.class); assertFalse(valueWrapper.isValid()); assertEquals(resultRaw, valueWrapper.getValue()); valueWrapper = abstractRunnerHelper.getResultWrapper(List.class.getCanonicalName(), new FactMappingValue(), expressionEvaluatorMock, expectedResultRaw, resultRaw, List.class); assertEquals(collectionError, valueWrapper.getErrorMessage().get()); valueWrapper = abstractRunnerHelper.getResultWrapper(Map.class.getCanonicalName(), new FactMappingValue(), expressionEvaluatorMock, expectedResultRaw, resultRaw, Map.class); assertEquals(collectionError, valueWrapper.getErrorMessage().get()); when(expressionEvaluatorMock.evaluateUnaryExpression(any(), any(), any(Class.class))).thenThrow(new IllegalArgumentException(genericErrorMessage)); FactMappingValue expectedResult5 = new FactMappingValue(); valueWrapper = abstractRunnerHelper.getResultWrapper(Map.class.getCanonicalName(), expectedResult5, expressionEvaluatorMock, expectedResultRaw, resultRaw, Map.class); assertEquals(genericErrorMessage, valueWrapper.getErrorMessage().get()); assertEquals(genericErrorMessage, expectedResult5.getExceptionMessage()); }