PMML4Result getPMML4Result(final KiePMMLMiningModel toEvaluate,
                               final LinkedHashMap<String, KiePMMLNameValueProbabilityMapTuple> inputData,
                               final PMMLRuntimeContext pmmlContext) {
        final MULTIPLE_MODEL_METHOD multipleModelMethod = toEvaluate.getSegmentation().getMultipleModelMethod();
        Object result = null;
        LinkedHashMap<String, Double> probabilityResultMap = null;
        ResultCode resultCode = OK;
        final LinkedHashMap<String, KiePMMLNameValue> toUseForPrediction = new LinkedHashMap<>();
        final LinkedHashMap<String, List<KiePMMLNameValue>> toUseForProbability = new LinkedHashMap<>();
        inputData.forEach((key, value) -> {
            toUseForPrediction.put(key, value.predictionValue);
            toUseForProbability.put(key, value.probabilityValues);
        });
        try {
            if (MINING_FUNCTION.CLASSIFICATION.equals(toEvaluate.getMiningFunction())) {
                result = multipleModelMethod.applyClassification(toUseForPrediction);
                probabilityResultMap = multipleModelMethod.applyProbability(toUseForProbability);
            } else {
                result = multipleModelMethod.applyPrediction(toUseForPrediction);
            }
        } catch (KieEnumException e) {
            logger.warn(e.getMessage());
            resultCode = FAIL;
        }
        pmmlContext.setProbabilityResultMap(probabilityResultMap);
        PMML4Result toReturn = new PMML4Result();
        toReturn.addResultVariable(toEvaluate.getTargetField(), result);
        toReturn.setResultObjectName(toEvaluate.getTargetField());
        toReturn.setResultCode(resultCode.getName());
        return toReturn;
    }
@Test
    void getPMML4ResultOK() {
        String fileName = "FILENAME";
        String name = "NAME";
        String targetField = "TARGET";
        String prediction = "FIRST_VALUE";
        KiePMMLSegmentation kiePMMLSegmentation = KiePMMLSegmentation.builder("SEGM_1", Collections.emptyList(), SELECT_FIRST).build();
        KiePMMLMiningModel kiePMMLMiningModel = KiePMMLMiningModel.builder(fileName, name, Collections.emptyList(),
                MINING_FUNCTION.ASSOCIATION_RULES)
                .withTargetField(targetField)
                .withSegmentation(kiePMMLSegmentation)
                .build();
        final LinkedHashMap<String, PMMLMiningModelEvaluator.KiePMMLNameValueProbabilityMapTuple> inputData = new LinkedHashMap<>();
        inputData.put("FIRST_KEY", new PMMLMiningModelEvaluator.KiePMMLNameValueProbabilityMapTuple(new KiePMMLNameValue("FIRST_NAME", prediction), new ArrayList<>()));
        inputData.put("SECOND_KEY", new PMMLMiningModelEvaluator.KiePMMLNameValueProbabilityMapTuple(new KiePMMLNameValue("SECOND_NAME", "SECOND_VALUE"), new ArrayList<>()));
        PMML4Result retrieved = evaluator.getPMML4Result(kiePMMLMiningModel, inputData, new PMMLRuntimeContextTest());
        assertThat(retrieved).isNotNull();
        assertThat(retrieved.getResultCode()).isEqualTo(OK.getName());
        assertThat(retrieved.getResultObjectName()).isEqualTo(targetField);
        final Map<String, Object> resultVariables = retrieved.getResultVariables();
        assertThat(resultVariables).containsKey(targetField);
        assertThat(resultVariables.get(targetField)).isEqualTo(prediction);
    }