@Test
public void getApplyExpressionMethodDeclaration() {

    Apply apply = applySupplier.get();
    int methodArity = new Random().nextInt(20);
    String methodName = String.format(METHOD_NAME_TEMPLATE, apply.getClass().getSimpleName(), methodArity);
    MethodDeclaration retrieved = ExpressionFunctionUtils.getApplyExpressionMethodDeclaration(methodName, apply,
                                                                                              OBJECT_CLASS,
                                                                                              DEFAULT_PARAMETERTYPE_MAP);
    String expected = String.format("java.lang.Object %s(java.util.List<org.kie.pmml.commons.model.tuples.KiePMMLNameValue> param1) {\n" +
                                            "    java.lang.Object variableapplyVariableConstant1 = 34.6;\n" +
                                            "    java.util.Optional<org.kie.pmml.commons.model.tuples" +
                                            ".KiePMMLNameValue> kiePMMLNameValue = param1.stream().filter((org" +
                                            ".kie.pmml.commons.model.tuples.KiePMMLNameValue lmbdParam) -> java" +
                                            ".util.Objects.equals(\"FIELD_REF\", lmbdParam.getName())).findFirst" +
                                            "();\n" +
                                            "    java.lang.Object variableapplyVariableFieldRef2 = (java.lang" +
                                            ".Object) kiePMMLNameValue.map(org.kie.pmml.commons.model.tuples" +
                                            ".KiePMMLNameValue::getValue).orElse(null);\n" +
                                            "    java.lang.Object applyVariable = this.FUNCTION_NAME(param1, " +
                                            "variableapplyVariableConstant1, variableapplyVariableFieldRef2);\n" +
                                            "    return applyVariable;\n" +
                                            "}", methodName);
    assertEquals(expected, retrieved.toString());
    //
    ParameterField parameterField = new ParameterField(FieldName.create("FIELD_REF"));
    LinkedHashMap<String, ClassOrInterfaceType> modifiedParametersMap = new LinkedHashMap<>(DEFAULT_PARAMETERTYPE_MAP);
    modifiedParametersMap.put(parameterField.getName().toString(), parseClassOrInterfaceType(getBoxedClassName(parameterField)));
    retrieved = ExpressionFunctionUtils.getApplyExpressionMethodDeclaration(methodName, apply,
                                                                                              OBJECT_CLASS,
                                                                            modifiedParametersMap);
    expected = String.format("java.lang.Object %s(java.util.List<org.kie.pmml.commons.model.tuples.KiePMMLNameValue> " +
            "param1, java.lang.Object FIELD_REF) {\n" +
            "    java.lang.Object variableapplyVariableConstant1 = 34.6;\n" +
            "    java.lang.Object variableapplyVariableFieldRef2 = FIELD_REF != null ? (java.lang.Object) org.kie" +
            ".pmml.commons.utils.ConverterTypeUtil.convert(java.lang.Object.class, FIELD_REF) : (java.lang" +
            ".Object) null;\n" +
            "    java.lang.Object applyVariable = this.FUNCTION_NAME(param1, variableapplyVariableConstant1, " +
            "variableapplyVariableFieldRef2);\n" +
            "    return applyVariable;\n" +
            "}", methodName);
    assertEquals(expected, retrieved.toString());
}