static void manageInvalidValues(final KiePMMLMiningField miningField, final ParameterInfo parameterInfo,
                                    final List<ParameterInfo> toRemove) {
        INVALID_VALUE_TREATMENT_METHOD invalidValueTreatmentMethod =
                miningField.getInvalidValueTreatmentMethod() != null ?
                        miningField.getInvalidValueTreatmentMethod()
                        : INVALID_VALUE_TREATMENT_METHOD.RETURN_INVALID;
        Object originalValue = parameterInfo.getValue();
        switch (invalidValueTreatmentMethod) {
            case RETURN_INVALID:
                throw new KiePMMLInputDataException("Invalid value " + originalValue + " for " + miningField.getName());
            case AS_MISSING:
                toRemove.add(parameterInfo);
                break;
            case AS_IS:
                break;
            case AS_VALUE:
                String invalidValueReplacement = miningField.getInvalidValueReplacement();
                if (invalidValueReplacement == null) {
                    throw new KiePMMLInputDataException("Missing required invalidValueReplacement for " + miningField.getName());
                } else {
                    Object requiredValue =
                            miningField.getDataType().getActualValue(invalidValueReplacement);
                    parameterInfo.setType(miningField.getDataType().getMappedClass());
                    parameterInfo.setValue(requiredValue);
                }
                break;
            default:
                throw new KiePMMLException("Unmanaged INVALID_VALUE_TREATMENT_METHOD " + invalidValueTreatmentMethod);
        }
    }
@Test
    void manageInvalidValuesNotReturnInvalid() {
        final ParameterInfo parameterInfo = new ParameterInfo();
        // AS_MISSING
        KiePMMLMiningField miningField = KiePMMLMiningField.builder("FIELD", null)
                .withInvalidValueTreatmentMethod(INVALID_VALUE_TREATMENT_METHOD.AS_MISSING)
                .build();
        List<ParameterInfo> toRemove = new ArrayList<>();
        PreProcess.manageInvalidValues(miningField, parameterInfo, toRemove);
        assertThat(toRemove).hasSize(1);
        assertThat(toRemove).contains(parameterInfo);
        // AS_IS
        miningField = KiePMMLMiningField.builder("FIELD", null)
                .withInvalidValueTreatmentMethod(INVALID_VALUE_TREATMENT_METHOD.AS_IS)
                .build();
        toRemove = new ArrayList<>();
        PreProcess.manageInvalidValues(miningField, parameterInfo, toRemove);
        assertThat(toRemove).isEmpty();
        // AS_VALUE with replacement
        String invalidValueReplacement = "REPLACEMENT";
        miningField = KiePMMLMiningField.builder("FIELD", null)
                .withDataType(DATA_TYPE.STRING)
                .withInvalidValueTreatmentMethod(INVALID_VALUE_TREATMENT_METHOD.AS_VALUE)
                .withInvalidValueReplacement(invalidValueReplacement)
                .build();
        toRemove = new ArrayList<>();
        assertThat(parameterInfo.getValue()).isNull();
        assertThat(parameterInfo.getType()).isNull();
        PreProcess.manageInvalidValues(miningField, parameterInfo, toRemove);
        assertThat(toRemove).isEmpty();
        assertThat(parameterInfo.getValue()).isEqualTo(invalidValueReplacement);
        assertThat(parameterInfo.getType()).isEqualTo(String.class);
    }