static void populateMissingMiningTargetField(final Model model, final List<DataField> dataFields) {
        List<MiningField> miningTargetFields = getMiningTargetFields(model.getMiningSchema().getMiningFields());
        if (miningTargetFields.isEmpty()) {
            Optional<DataField> targetDataField = getTargetDataField(model);
            targetDataField.ifPresent(dataField -> {
                dataFields.add(dataField);
                MiningField targetMiningField = getTargetMiningField(dataField);
                model.getMiningSchema().addMiningFields(targetMiningField);
                correctTargetFields(targetMiningField, model.getTargets());
            });
        }
    }
@Test
    void populateMissingMiningTargetField() throws Exception {
        final InputStream inputStream = getFileInputStream(NO_TARGET_FIELD_SAMPLE);
        final PMML pmml = org.jpmml.model.PMMLUtil.unmarshal(inputStream);
        final Model toPopulate = pmml.getModels().get(0);
        List<MiningField> miningTargetFields = getMiningTargetFields(toPopulate.getMiningSchema().getMiningFields());
        assertThat(miningTargetFields).isEmpty();
        assertThat(toPopulate.getTargets().getTargets().get(0).getField()).isNull();
        KiePMMLUtil.populateMissingMiningTargetField(toPopulate, pmml.getDataDictionary().getDataFields());
        miningTargetFields = getMiningTargetFields(toPopulate.getMiningSchema().getMiningFields());
        assertThat(miningTargetFields).hasSize(1);
        final MiningField targetField = miningTargetFields.get(0);
        assertThat(pmml.getDataDictionary()
                .getDataFields()
                .stream()
                .anyMatch(dataField -> dataField.getName().equals(targetField.getName()))).isTrue();
        assertThat(toPopulate.getTargets().getTargets().get(0).getField()).isEqualTo(targetField.getName());
    }