@Test
public void getKiePMMLModelCompilationUnit() {

    DataDictionary dataDictionary = new DataDictionary();
    String targetFieldString = "target.field";
    FieldName targetFieldName = FieldName.create(targetFieldString);
    dataDictionary.addDataFields(new DataField(targetFieldName, OpType.CONTINUOUS, DataType.DOUBLE));
    String modelName = "ModelName";
    Model model = new TreeModel();
    model.setModelName(modelName);
    model.setMiningFunction(MiningFunction.CLASSIFICATION);
    MiningField targetMiningField = new MiningField(targetFieldName);
    targetMiningField.setUsageType(MiningField.UsageType.TARGET);
    MiningSchema miningSchema = new MiningSchema();
    miningSchema.addMiningFields(targetMiningField);
    model.setMiningSchema(miningSchema);
    Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>();
    fieldTypeMap.put(targetFieldString, new KiePMMLOriginalTypeGeneratedType(targetFieldString,
                                                                             getSanitizedClassName(targetFieldString)));
    String packageName = "net.test";
    CompilationUnit retrieved = KiePMMLDroolsModelFactoryUtils.getKiePMMLModelCompilationUnit(dataDictionary,
                                                                                              model, fieldTypeMap
            , packageName, TEMPLATE_SOURCE, TEMPLATE_CLASS_NAME);
    assertEquals(packageName, retrieved.getPackageDeclaration().get().getNameAsString());
    ConstructorDeclaration constructorDeclaration =
            retrieved.getClassByName(modelName).get().getDefaultConstructor().get();
    MINING_FUNCTION miningFunction = MINING_FUNCTION.CLASSIFICATION;
    PMML_MODEL pmmlModel = PMML_MODEL.byName(model.getClass().getSimpleName());
    Map<String, Expression> assignExpressionMap = new HashMap<>();
    assignExpressionMap.put("targetField", new StringLiteralExpr(targetFieldString));
    assignExpressionMap.put("miningFunction",
                            new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name()));
    assignExpressionMap.put("pmmlMODEL", new NameExpr(pmmlModel.getClass().getName() + "." + pmmlModel.name()));
    assertTrue(commonEvaluateAssignExpr(constructorDeclaration.getBody(), assignExpressionMap));
    int expectedMethodCallExprs = assignExpressionMap.size() + fieldTypeMap.size() + 1; // The last "1" is for
    // the super invocation
    commonEvaluateFieldTypeMap(constructorDeclaration.getBody(), fieldTypeMap, expectedMethodCallExprs);
}