@Test public void getSingleFactValueResultFailDecision() { DMNDecisionResult failedDecision = createDecisionResultMock("Test", false, new ArrayList<>()); ValueWrapper<?> failedResult = runnerHelper.getSingleFactValueResult(null, null, failedDecision, expressionEvaluator); assertFalse(failedResult.isValid()); assertEquals("The decision " + failedDecision.getDecisionName() + " has not been successfully evaluated: " + failedDecision.getEvaluationStatus(), failedResult.getErrorMessage().get()); }
@SuppressWarnings("unchecked") protected ValueWrapper getSingleFactValueResult(FactMapping factMapping, FactMappingValue expectedResult, DMNDecisionResult decisionResult, ExpressionEvaluator expressionEvaluator) { Object resultRaw = decisionResult.getResult(); final DMNDecisionResult.DecisionEvaluationStatus evaluationStatus = decisionResult.getEvaluationStatus(); if (!SUCCEEDED.equals(evaluationStatus)) { return errorWithMessage("The decision " + decisionResult.getDecisionName() + " has not been successfully evaluated: " + evaluationStatus); } List<ExpressionElement> elementsWithoutClass = factMapping.getExpressionElementsWithoutClass(); if (resultRaw != null) { for (ExpressionElement expressionElement : elementsWithoutClass) { if (!(resultRaw instanceof Map)) { throw new ScenarioException("Wrong resultRaw structure because it is not a complex type as expected"); } Map<String, Object> result = (Map<String, Object>) resultRaw; resultRaw = result.get(expressionElement.getStep()); } } Class<?> resultClass = resultRaw != null ? resultRaw.getClass() : null; Object expectedResultRaw = expectedResult.getRawValue(); return getResultWrapper(factMapping.getClassName(), expectedResult, expressionEvaluator, expectedResultRaw, resultRaw, resultClass); }
DMNScenarioRunnerHelper extends AbstractRunnerHelper { @SuppressWarnings("unchecked") protected ValueWrapper getSingleFactValueResult(FactMapping factMapping, FactMappingValue expectedResult, DMNDecisionResult decisionResult, ExpressionEvaluator expressionEvaluator) { Object resultRaw = decisionResult.getResult(); final DMNDecisionResult.DecisionEvaluationStatus evaluationStatus = decisionResult.getEvaluationStatus(); if (!SUCCEEDED.equals(evaluationStatus)) { return errorWithMessage("The decision " + decisionResult.getDecisionName() + " has not been successfully evaluated: " + evaluationStatus); } List<ExpressionElement> elementsWithoutClass = factMapping.getExpressionElementsWithoutClass(); if (resultRaw != null) { for (ExpressionElement expressionElement : elementsWithoutClass) { if (!(resultRaw instanceof Map)) { throw new ScenarioException("Wrong resultRaw structure because it is not a complex type as expected"); } Map<String, Object> result = (Map<String, Object>) resultRaw; resultRaw = result.get(expressionElement.getStep()); } } Class<?> resultClass = resultRaw != null ? resultRaw.getClass() : null; Object expectedResultRaw = expectedResult.getRawValue(); return getResultWrapper(factMapping.getClassName(), expectedResult, expressionEvaluator, expectedResultRaw, resultRaw, resultClass); } }
DMNScenarioRunnerHelper extends AbstractRunnerHelper { @SuppressWarnings("unchecked") protected ValueWrapper getSingleFactValueResult(FactMapping factMapping, FactMappingValue expectedResult, DMNDecisionResult decisionResult, ExpressionEvaluator expressionEvaluator) { Object resultRaw = decisionResult.getResult(); final DMNDecisionResult.DecisionEvaluationStatus evaluationStatus = decisionResult.getEvaluationStatus(); if (!SUCCEEDED.equals(evaluationStatus)) { return errorWithMessage("The decision " + decisionResult.getDecisionName() + " has not been successfully evaluated: " + evaluationStatus); } List<ExpressionElement> elementsWithoutClass = factMapping.getExpressionElementsWithoutClass(); if (resultRaw != null) { for (ExpressionElement expressionElement : elementsWithoutClass) { if (!(resultRaw instanceof Map)) { throw new ScenarioException("Wrong resultRaw structure because it is not a complex type as expected"); } Map<String, Object> result = (Map<String, Object>) resultRaw; resultRaw = result.get(expressionElement.getStep()); } } Class<?> resultClass = resultRaw != null ? resultRaw.getClass() : null; Object expectedResultRaw = expectedResult.getRawValue(); return getResultWrapper(factMapping.getClassName(), expectedResult, expressionEvaluator, expectedResultRaw, resultRaw, resultClass); }  }
DMNScenarioRunnerHelper extends AbstractRunnerHelper { @SuppressWarnings("unchecked") protected ValueWrapper getSingleFactValueResult(FactMapping factMapping, FactMappingValue expectedResult, DMNDecisionResult decisionResult, ExpressionEvaluator expressionEvaluator) { Object resultRaw = decisionResult.getResult(); final DMNDecisionResult.DecisionEvaluationStatus evaluationStatus = decisionResult.getEvaluationStatus(); if (!SUCCEEDED.equals(evaluationStatus)) { return errorWithMessage("The decision " + decisionResult.getDecisionName() + " has not been successfully evaluated: " + evaluationStatus); } List<ExpressionElement> elementsWithoutClass = factMapping.getExpressionElementsWithoutClass(); if (resultRaw != null) { for (ExpressionElement expressionElement : elementsWithoutClass) { if (!(resultRaw instanceof Map)) { throw new ScenarioException("Wrong resultRaw structure because it is not a complex type as expected"); } Map<String, Object> result = (Map<String, Object>) resultRaw; resultRaw = result.get(expressionElement.getStep()); } } Class<?> resultClass = resultRaw != null ? resultRaw.getClass() : null; Object expectedResultRaw = expectedResult.getRawValue(); return getResultWrapper(factMapping.getClassName(), expectedResult, expressionEvaluator, expectedResultRaw, resultRaw, resultClass); }   }
DMNScenarioRunnerHelper extends AbstractRunnerHelper { @SuppressWarnings("unchecked") protected ValueWrapper getSingleFactValueResult(FactMapping factMapping, FactMappingValue expectedResult, DMNDecisionResult decisionResult, ExpressionEvaluator expressionEvaluator) { Object resultRaw = decisionResult.getResult(); final DMNDecisionResult.DecisionEvaluationStatus evaluationStatus = decisionResult.getEvaluationStatus(); if (!SUCCEEDED.equals(evaluationStatus)) { return errorWithMessage("The decision " + decisionResult.getDecisionName() + " has not been successfully evaluated: " + evaluationStatus); } List<ExpressionElement> elementsWithoutClass = factMapping.getExpressionElementsWithoutClass(); if (resultRaw != null) { for (ExpressionElement expressionElement : elementsWithoutClass) { if (!(resultRaw instanceof Map)) { throw new ScenarioException("Wrong resultRaw structure because it is not a complex type as expected"); } Map<String, Object> result = (Map<String, Object>) resultRaw; resultRaw = result.get(expressionElement.getStep()); } } Class<?> resultClass = resultRaw != null ? resultRaw.getClass() : null; Object expectedResultRaw = expectedResult.getRawValue(); return getResultWrapper(factMapping.getClassName(), expectedResult, expressionEvaluator, expectedResultRaw, resultRaw, resultClass); }    }