public static void init(final CompilationDTO<? extends Model> compilationDTO,
                            final ClassOrInterfaceDeclaration modelTemplate) {
        final ConstructorDeclaration constructorDeclaration =
                modelTemplate.getDefaultConstructor().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_DEFAULT_CONSTRUCTOR, modelTemplate.getName())));
        final String fileName = compilationDTO.getFileName();
        final String name = compilationDTO.getModelName();
        final String generatedClassName = compilationDTO.getSimpleClassName();
        final List<MiningField> miningFields = compilationDTO.getKieMiningFields();
        final List<OutputField> outputFields = compilationDTO.getKieOutputFields();
        final List<TargetField> targetFields = compilationDTO.getKieTargetFields();

        final Expression miningFunctionExpression;
        if (compilationDTO.getMINING_FUNCTION() != null) {
            MINING_FUNCTION miningFunction = compilationDTO.getMINING_FUNCTION();
            miningFunctionExpression = new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name());
        } else {
            miningFunctionExpression = new NullLiteralExpr();
        }
        final PMML_MODEL pmmlModelEnum = compilationDTO.getPMML_MODEL();
        final NameExpr pmmlMODELExpression =
                new NameExpr(pmmlModelEnum.getClass().getName() + "." + pmmlModelEnum.name());
        String targetFieldName = compilationDTO.getTargetFieldName();
        final Expression targetFieldExpression;
        if (targetFieldName != null) {
            targetFieldExpression = new StringLiteralExpr(targetFieldName);
        } else {
            targetFieldExpression = new NullLiteralExpr();
        }
        setKiePMMLModelConstructor(generatedClassName,
                                   constructorDeclaration,
                                   fileName,
                                   name,
                                   miningFields,
                                   outputFields,
                                   targetFields);
        addTransformationsInClassOrInterfaceDeclaration(modelTemplate, compilationDTO.getTransformationDictionary(),
                                                        compilationDTO.getLocalTransformations());
        final BlockStmt body = constructorDeclaration.getBody();
        CommonCodegenUtils.setAssignExpressionValue(body, "pmmlMODEL", pmmlMODELExpression);
        CommonCodegenUtils.setAssignExpressionValue(body, "miningFunction", miningFunctionExpression);
        CommonCodegenUtils.setAssignExpressionValue(body, "targetField", targetFieldExpression);

        addGetCreatedKiePMMLMiningFieldsMethod(modelTemplate, compilationDTO.getMiningSchema().getMiningFields(),
                                               compilationDTO.getFields());
        MethodCallExpr getCreatedKiePMMLMiningFieldsExpr = new MethodCallExpr();
        getCreatedKiePMMLMiningFieldsExpr.setScope(new ThisExpr());
        getCreatedKiePMMLMiningFieldsExpr.setName(GET_CREATED_KIEPMMLMININGFIELDS);
        CommonCodegenUtils.setAssignExpressionValue(body, "kiePMMLMiningFields", getCreatedKiePMMLMiningFieldsExpr);

        if (compilationDTO.getOutput() != null) {
            addGetCreatedKiePMMLOutputFieldsMethod(modelTemplate, compilationDTO.getOutput().getOutputFields());
            MethodCallExpr getCreatedKiePMMLOutputFieldsExpr = new MethodCallExpr();
            getCreatedKiePMMLOutputFieldsExpr.setScope(new ThisExpr());
            getCreatedKiePMMLOutputFieldsExpr.setName(GET_CREATED_KIEPMMLOUTPUTFIELDS);
            CommonCodegenUtils.setAssignExpressionValue(body, "kiePMMLOutputFields", getCreatedKiePMMLOutputFieldsExpr);
        }
    }
@Test
    void init() throws IOException {
        final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME,
                                                                                                     pmmlModel,
                                                                                                     model,
                                                                                                     new PMMLCompilationContextMock(), SOURCE_BASE);
        org.kie.pmml.compiler.commons.codegenfactories.KiePMMLModelFactoryUtils.init(compilationDTO, classOrInterfaceDeclaration);
        BlockStmt body = constructorDeclaration.getBody();
        String text = getFileContent(TEST_03_SOURCE);
        Statement expected = JavaParserUtils.parseConstructorBlock(text);
        assertThat(JavaParserUtils.equalsNode(expected, body)).isTrue();
    }