static void populateMissingPredictedOutputFieldTarget(final Model model) {
        if (model.getOutput() != null && model.getMiningSchema() != null) {
            Optional<OutputField> predictedOutputField = model.getOutput().getOutputFields().stream()
                    .filter(outputField -> (outputField.getResultFeature() == null || outputField.getResultFeature().equals(ResultFeature.PREDICTED_VALUE)) && outputField.getTargetField() == null)
                    .findFirst();
            predictedOutputField.ifPresent(outputField -> {
                List<MiningField> targetFields = getMiningTargetFields(model.getMiningSchema().getMiningFields());
                if (!targetFields.isEmpty()) {
                    outputField.setTargetField(targetFields.get(0).getName());
                }
            });
        }
    }
@Test
    void populateMissingPredictedOutputFieldTarget() throws Exception {
        final InputStream inputStream = getFileInputStream(NO_OUTPUT_FIELD_TARGET_NAME_SAMPLE);
        final PMML pmml = org.jpmml.model.PMMLUtil.unmarshal(inputStream);
        final Model toPopulate = pmml.getModels().get(0);
        final OutputField outputField = toPopulate.getOutput().getOutputFields().get(0);
        assertThat(outputField.getResultFeature()).isEqualTo(ResultFeature.PREDICTED_VALUE);
        assertThat(outputField.getTargetField()).isNull();
        KiePMMLUtil.populateMissingPredictedOutputFieldTarget(toPopulate);
        final MiningField targetField = getMiningTargetFields(toPopulate.getMiningSchema().getMiningFields()).get(0);
        assertThat(outputField.getTargetField()).isNotNull();
        assertThat(outputField.getTargetField()).isEqualTo(targetField.getName());
    }