public static OP_TYPE getOpType(final List<Field<?>> fields, final Model model, final String targetFieldName) {
        return Stream.of(getOpTypeFromTargets(model.getTargets(), targetFieldName),
                         getOpTypeFromMiningFields(model.getMiningSchema(), targetFieldName),
                         getOpTypeFromFields(fields, targetFieldName))
                .filter(Optional::isPresent)
                .map(Optional::get)
                .findFirst()
                .orElseThrow(() -> new KiePMMLInternalException(String.format("Failed to find OpType for field" +
                                                                                      " %s", targetFieldName)));
    }
@Test
    void getOpTypeByTargetsNotFound() {
        assertThatExceptionOfType(KiePMMLInternalException.class).isThrownBy(() -> {
            final Model model = new RegressionModel();
            final DataDictionary dataDictionary = new DataDictionary();
            final MiningSchema miningSchema = new MiningSchema();
            final Targets targets = new Targets();
            IntStream.range(0, 3).forEach(i -> {
                String fieldName = "field" + i;
                final DataField dataField = getRandomDataField();
                dataField.setName(fieldName);
                dataDictionary.addDataFields(dataField);
                final MiningField miningField = getRandomMiningField();
                miningField.setName(dataField.getName());
                miningSchema.addMiningFields(miningField);
                final Target targetField = getRandomTarget();
                targetField.setField(dataField.getName());
                targets.addTargets(targetField);
            });
            model.setMiningSchema(miningSchema);
            model.setTargets(targets);
            org.kie.pmml.compiler.api.utils.ModelUtils.getOpType(getFieldsFromDataDictionary(dataDictionary), model,
                                                                 "NOT_EXISTING");
        });
    }