KiePMMLRegressionModelFactory { static void setConstructor(final String generatedClassName, final String nestedTable, final ConstructorDeclaration constructorDeclaration, final String targetField, final MINING_FUNCTION miningFunction, final String modelName) { ObjectCreationExpr objectCreationExpr = new ObjectCreationExpr(); objectCreationExpr.setType(nestedTable); setConstructorSuperNameInvocation(generatedClassName, constructorDeclaration, modelName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "regressionTable", objectCreationExpr); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "miningFunction", new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name())); CommonCodegenUtils.setAssignExpressionValue(body, "pmmlMODEL", new NameExpr(PMML_MODEL.REGRESSION_MODEL.getClass().getName() + "." + PMML_MODEL.REGRESSION_MODEL.name())); } private  KiePMMLRegressionModelFactory(); static KiePMMLRegressionModel getKiePMMLRegressionModelClasses(final DataDictionary dataDictionary,
                                                                          final TransformationDictionary transformationDictionary,
                                                                          final RegressionModel model); static Map<String, String> getKiePMMLRegressionModelSourcesMap(final DataDictionary dataDictionary,
                                                                          final TransformationDictionary transformationDictionary,
                                                                          final RegressionModel model,
                                                                          final String packageName);  }
@Test public void setConstructor() { ConstructorDeclaration constructorDeclaration = MODEL_TEMPLATE.getDefaultConstructor().get(); String generatedClassName = "GeneratedClassName"; String nestedTable = "NestedTable"; String targetField = "targetField"; MINING_FUNCTION miningFunction = MINING_FUNCTION.CLASSIFICATION; String modelName = "modelName"; KiePMMLRegressionModelFactory.setConstructor(generatedClassName, nestedTable, constructorDeclaration, targetField, miningFunction, modelName); Map<Integer, Expression> superInvocationExpressionsMap = new HashMap<>(); superInvocationExpressionsMap.put(0, new NameExpr(String.format("\"%s\"", modelName))); 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(PMML_MODEL.class.getName() + "." + PMML_MODEL.REGRESSION_MODEL.name())); ObjectCreationExpr objectCreationExpr = new ObjectCreationExpr(); objectCreationExpr.setType(nestedTable); assignExpressionMap.put("regressionTable", objectCreationExpr); assertTrue(commonEvaluateConstructor(constructorDeclaration, generatedClassName, superInvocationExpressionsMap, assignExpressionMap)); }