static BlockStmt getDefineFunctionVariableDeclaration(final DefineFunction defineFunction) {
        final MethodDeclaration methodDeclaration =
                DEFINE_FUNCTION_TEMPLATE.getMethodsByName(GETKIEPMMLDEFINEFUNCTION).get(0).clone();
        final BlockStmt defineFunctionBody =
                methodDeclaration.getBody().orElseThrow(() -> new KiePMMLException(String.format(MISSING_BODY_TEMPLATE, methodDeclaration)));
        final VariableDeclarator variableDeclarator =
                getVariableDeclarator(defineFunctionBody, DEFINE_FUNCTION).orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_IN_BODY, DEFINE_FUNCTION, defineFunctionBody)));
        variableDeclarator.setName(defineFunction.getName());
        final BlockStmt toReturn = new BlockStmt();
        int counter = 0;
        final NodeList<Expression> parameterFieldArguments = new NodeList<>();
        for (ParameterField parameterField: defineFunction.getParameterFields()) {
            String nestedVariableName = String.format(VARIABLE_NAME_TEMPLATE, defineFunction.getName(), counter);
            parameterFieldArguments.add(new NameExpr(nestedVariableName));
            BlockStmt toAdd = getParameterFieldVariableDeclaration(nestedVariableName, parameterField);
            toAdd.getStatements().forEach(toReturn::addStatement);
            counter ++;
        }
        String kiePMMLExpression = String.format("%s_Expression", defineFunction.getName());
        BlockStmt toAdd = getKiePMMLExpressionBlockStmt(kiePMMLExpression, defineFunction.getExpression());
        toAdd.getStatements().forEach(toReturn::addStatement);


        final ObjectCreationExpr objectCreationExpr = variableDeclarator.getInitializer()
                .orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_INITIALIZER_TEMPLATE, DEFINE_FUNCTION, toReturn)))
                .asObjectCreationExpr();
        final StringLiteralExpr nameExpr = new StringLiteralExpr(defineFunction.getName());
        objectCreationExpr.getArguments().set(0, nameExpr);
        final Expression dataTypeExpression = getExpressionForDataType(defineFunction.getDataType());
        final Expression opTypeExpression = getExpressionForOpType(defineFunction.getOpType());
        objectCreationExpr.getArguments().set(2, dataTypeExpression);
        objectCreationExpr.getArguments().set(3, opTypeExpression);
        objectCreationExpr.getArguments().get(4).asMethodCallExpr().setArguments(parameterFieldArguments);
        objectCreationExpr.getArguments().set(5, new NameExpr(kiePMMLExpression));
        defineFunctionBody.getStatements().forEach(toReturn::addStatement);
        return toReturn;
    }
@Test
    void getDefineFunctionVariableDeclaration() throws IOException {
        ParameterField parameterField1 = new ParameterField(PARAM_1);
        parameterField1.setDataType(DataType.DOUBLE);
        parameterField1.setOpType(OpType.CONTINUOUS);
        parameterField1.setDisplayName("displayName1");
        ParameterField parameterField2 = new ParameterField(PARAM_2);
        parameterField2.setDataType(DataType.DOUBLE);
        parameterField2.setOpType(OpType.CONTINUOUS);
        parameterField2.setDisplayName("displayName2");
        Constant constant = new Constant();
        constant.setValue(value1);
        FieldRef fieldRef = new FieldRef();
        fieldRef.setField("FIELD_REF");
        Apply apply = new Apply();
        apply.setFunction("/");
        apply.addExpressions(constant, fieldRef);
        DefineFunction defineFunction = new DefineFunction();
        defineFunction.setName(CUSTOM_FUNCTION);
        defineFunction.addParameterFields(parameterField1, parameterField2);
        defineFunction.setDataType(DataType.DOUBLE);
        defineFunction.setOpType(OpType.CONTINUOUS);
        defineFunction.setExpression(apply);
        String dataType1 = getDATA_TYPEString(parameterField1.getDataType());
        String dataType2 = getDATA_TYPEString(parameterField2.getDataType());
        String dataType3 = getDATA_TYPEString(defineFunction.getDataType());
        String opType1 = getOP_TYPEString(parameterField1.getOpType());
        String opType2 = getOP_TYPEString(parameterField2.getOpType());
        String opType3 = getOP_TYPEString(defineFunction.getOpType());
        BlockStmt retrieved = KiePMMLDefineFunctionFactory.getDefineFunctionVariableDeclaration(defineFunction);
        String text = getFileContent(TEST_01_SOURCE);
        Statement expected = JavaParserUtils
                .parseBlock(String.format(text,parameterField1.getName(),
                                          dataType1,
                                          opType1,
                                          parameterField1.getDisplayName(),parameterField2.getName(),
                                          dataType2,
                                          opType2,
                                          parameterField2.getDisplayName(),
                                          constant.getValue(),fieldRef.getField(),
                                          apply.getFunction(),
                                          apply.getInvalidValueTreatment().value(),
                                          dataType3,
                                          opType3));
        assertThat(JavaParserUtils.equalsNode(expected, retrieved)).isTrue();
        List<Class<?>> imports = Arrays.asList(KiePMMLParameterField.class,
                                               KiePMMLConstant.class,
                                               KiePMMLFieldRef.class,
                                               KiePMMLApply.class,
                                               KiePMMLDefineFunction.class,
                                               Arrays.class,
                                               Collections.class);
        commonValidateCompilationWithImports(retrieved, imports);
    }