static void setConstructor(final Model model,
                               final ConstructorDeclaration constructorDeclaration,
                               final SimpleName tableName,
                               final String targetField,
                               final MINING_FUNCTION miningFunction,
                               final String kModulePackageName) {
        constructorDeclaration.setName(tableName);
        final BlockStmt body = constructorDeclaration.getBody();
        CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField));
        CommonCodegenUtils.setAssignExpressionValue(body, "miningFunction",
                                                    new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name()));
        PMML_MODEL pmmlModel = PMML_MODEL.byName(model.getClass().getSimpleName());
        CommonCodegenUtils.setAssignExpressionValue(body, "pmmlMODEL", new NameExpr(pmmlModel.getClass().getName() +
                                                                                            "." + pmmlModel.name()));
        CommonCodegenUtils.setAssignExpressionValue(body, "kModulePackageName",
                                                    new StringLiteralExpr(kModulePackageName));
    }
@Test
    void setConstructor() {
        Model model = new TreeModel();
        PMML_MODEL pmmlModel = PMML_MODEL.byName(model.getClass().getSimpleName());
        ConstructorDeclaration constructorDeclaration = MODEL_TEMPLATE.getDefaultConstructor().get();
        SimpleName tableName = new SimpleName("TABLE_NAME");
        String targetField = "TARGET_FIELD";
        MINING_FUNCTION miningFunction = MINING_FUNCTION.CLASSIFICATION;
        String kModulePackageName = getSanitizedPackageName("kModulePackageName");
        KiePMMLDroolsModelFactoryUtils.setConstructor(model, constructorDeclaration, tableName, targetField,
                miningFunction,
                kModulePackageName);
        Map<Integer, Expression> superInvocationExpressionsMap = new HashMap<>();
        Map<String, Expression> assignExpressionMap = new HashMap<>();
        assignExpressionMap.put("targetField", new StringLiteralExpr(targetField));
        assignExpressionMap.put("miningFunction",
                new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name()));
        assignExpressionMap.put("pmmlMODEL", new NameExpr(pmmlModel.getClass().getName() + "." + pmmlModel.name()));
        assignExpressionMap.put("kModulePackageName", new StringLiteralExpr(kModulePackageName));
        assertThat(commonEvaluateConstructor(constructorDeclaration, tableName.asString(),
                superInvocationExpressionsMap,
                assignExpressionMap)).isTrue();
    }