public static org.kie.pmml.api.models.OutputField convertToKieOutputField(final OutputField toConvert,
                                                                              final Field<?> field) {
        final String name = toConvert.getName() != null ?toConvert.getName() : null;
        final OP_TYPE opType = toConvert.getOpType() != null ? OP_TYPE.byName(toConvert.getOpType().value()) : null;
        final DATA_TYPE dataFieldDataType = field != null ? DATA_TYPE.byName(field.getDataType().value()) :
                null;
        final DATA_TYPE dataType = toConvert.getDataType() != null ?
                DATA_TYPE.byName(toConvert.getDataType().value()) : dataFieldDataType;
        final String targetField = toConvert.getTargetField() != null ?toConvert.getTargetField() : null;
        final RESULT_FEATURE resultFeature = toConvert.getResultFeature() != null ?
                RESULT_FEATURE.byName(toConvert.getResultFeature().value()) : null;
        final List<String> allowedValues = field instanceof DataField ?
                convertDataFieldValues(((DataField) field).getValues()) : null;
        return new org.kie.pmml.api.models.OutputField(name,
                                                       opType,
                                                       dataType,
                                                       targetField,
                                                       resultFeature,
                                                       allowedValues);
    }
@Test
    void convertToKieOutputField() {
        final OutputField toConvert = getRandomOutputField();
        org.kie.pmml.api.models.OutputField retrieved =
                org.kie.pmml.compiler.api.utils.ModelUtils.convertToKieOutputField(toConvert, null);
        assertThat(retrieved).isNotNull();
        assertThat(retrieved.getName()).isEqualTo(toConvert.getName());
        OP_TYPE expectedOpType = OP_TYPE.byName(toConvert.getOpType().value());
        assertThat(retrieved.getOpType()).isEqualTo(expectedOpType);
        DATA_TYPE expectedDataType = DATA_TYPE.byName(toConvert.getDataType().value());
        assertThat(retrieved.getDataType()).isEqualTo(expectedDataType);
        assertThat(retrieved.getTargetField()).isEqualTo(toConvert.getTargetField());
        RESULT_FEATURE expectedResultFeature = RESULT_FEATURE.byName(toConvert.getResultFeature().value());
        assertThat(retrieved.getResultFeature()).isEqualTo(expectedResultFeature);
        toConvert.setOpType(null);
        toConvert.setTargetField(null);
        retrieved = org.kie.pmml.compiler.api.utils.ModelUtils.convertToKieOutputField(toConvert, null);
        assertThat(retrieved.getOpType()).isNull();
        assertThat(retrieved.getTargetField()).isNull();
    }