static void populateOutputFields(final PMML4Result toUpdate,
                                     final ProcessingDTO processingDTO) {
        logger.debug("populateOutputFields {} {}", toUpdate, processingDTO);
        for (KiePMMLOutputField outputField : processingDTO.getOutputFields()) {
            Object variableValue = outputField.evaluate(processingDTO);
            if (variableValue != null) {
                String variableName = outputField.getName();
                toUpdate.addResultVariable(variableName, variableValue);
                processingDTO.addKiePMMLNameValue(new KiePMMLNameValue(variableName, variableValue));
            }
        }
    }
@Test
    void populateTransformedOutputFieldWithApplyDerivedFieldFromApply() {
        // <DerivedField name="CUSTOM_FIELD" optype="continuous" dataType="double">
        //     <Apply function="+">
        //        <Constant>64.0</Constant>
        //        <Constant>36.0</Constant>
        //      </Apply>
        // </DerivedField>
        final KiePMMLConstant kiePMMLConstant1 = new KiePMMLConstant(PARAM_2, Collections.emptyList(), 64.0, null);
        final KiePMMLConstant kiePMMLConstant2 = new KiePMMLConstant(PARAM_2, Collections.emptyList(), 36, null);
        final KiePMMLApply kiePMMLApplyRef = KiePMMLApply.builder("NAMEREF", Collections.emptyList(), "+")
                .withKiePMMLExpressions(Arrays.asList(kiePMMLConstant1, kiePMMLConstant2))
                .build();
        final KiePMMLDerivedField derivedField = KiePMMLDerivedField.builder(CUSTOM_FIELD, Collections.emptyList(),
                DATA_TYPE.DOUBLE,
                OP_TYPE.CONTINUOUS,
                kiePMMLApplyRef).build();
        //     <Apply function="/">
        //        <FieldRef>CUSTOM_FIELD</FieldRef>
        //        <Constant>5.0</Constant>
        //      </Apply>
        final KiePMMLFieldRef kiePMMLFieldRef = new KiePMMLFieldRef(CUSTOM_FIELD, Collections.emptyList(), null);
        final KiePMMLConstant kiePMMLConstant3 = new KiePMMLConstant(PARAM_2, Collections.emptyList(), value2, null);
        KiePMMLApply kiePMMLApply = KiePMMLApply.builder("NAME", Collections.emptyList(), "/")
                .withKiePMMLExpressions(Arrays.asList(kiePMMLFieldRef, kiePMMLConstant3))
                .build();

        KiePMMLOutputField outputField = KiePMMLOutputField.builder(OUTPUT_NAME, Collections.emptyList())
                .withResultFeature(RESULT_FEATURE.TRANSFORMED_VALUE)
                .withKiePMMLExpression(kiePMMLApply)
                .build();

        // From TransformationDictionary
        KiePMMLTransformationDictionary transformationDictionary = KiePMMLTransformationDictionary.builder(
                "transformationDictionary", Collections.emptyList())
                .withDerivedFields(Collections.singletonList(derivedField))
                .build();
        KiePMMLTestingModel kiePMMLModel1 = testingModelBuilder(outputField)
                .withKiePMMLTransformationDictionary(transformationDictionary)
                .build();
        ProcessingDTO processingDTO1 = buildProcessingDTOWithEmptyNameValues(kiePMMLModel1);
        PMML4Result toUpdate1 = new PMML4Result();

        PostProcess.populateOutputFields(toUpdate1, processingDTO1);

        assertThat(toUpdate1.getResultVariables()).isNotEmpty();
        assertThat(toUpdate1.getResultVariables()).containsKey(OUTPUT_NAME);
        assertThat(toUpdate1.getResultVariables().get(OUTPUT_NAME)).isEqualTo(value1 / value2);

        // From LocalTransformations
        KiePMMLLocalTransformations localTransformations = KiePMMLLocalTransformations.builder("localTransformations"
        , Collections.emptyList())
                .withDerivedFields(Collections.singletonList(derivedField))
                .build();
        KiePMMLTestingModel kiePMMLModel2 = testingModelBuilder(outputField)
                .withKiePMMLLocalTransformations(localTransformations)
                .build();
        ProcessingDTO processingDTO2 = buildProcessingDTOWithEmptyNameValues(kiePMMLModel2);
        PMML4Result toUpdate2 = new PMML4Result();

        PostProcess.populateOutputFields(toUpdate2, processingDTO2);

        assertThat(toUpdate2.getResultVariables()).isNotEmpty();
        assertThat(toUpdate2.getResultVariables()).containsKey(OUTPUT_NAME);
        assertThat(toUpdate2.getResultVariables().get(OUTPUT_NAME)).isEqualTo(value1 / value2);
    }