KiePMMLRegressionTableRegressionFactory { static MethodDeclaration getNumericPredictorWithoutExponentTemplate(final NumericPredictor numericPredictor, final ClassOrInterfaceDeclaration evaluateTemplateClass) { final MethodDeclaration toReturn = evaluateTemplateClass.getMethodsByName("evaluateNumericWithoutExponent").get(0); final BlockStmt body = toReturn.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE , toReturn.getName()))); VariableDeclarator variableDeclarator = getVariableDeclarator(body, COEFFICIENT) .orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_VARIABLE_IN_BODY, COEFFICIENT, body))); variableDeclarator.setInitializer(String.valueOf(numericPredictor.getCoefficient().doubleValue())); return toReturn; } private  KiePMMLRegressionTableRegressionFactory(); static LinkedHashMap<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables,
                                                                                        final RegressionModel.NormalizationMethod normalizationMethod,
                                                                                        final List<KiePMMLOutputField> outputFields,
                                                                                        final String targetField,
                                                                                        final String packageName); static Map.Entry<String, String> getRegressionTable(final RegressionTable regressionTable,
                                                               final RegressionModel.NormalizationMethod normalizationMethod,
                                                               final List<KiePMMLOutputField> outputFields,
                                                               final String targetField,
                                                               final String packageName); static final String KIE_PMML_REGRESSION_TABLE_REGRESSION_TEMPLATE_JAVA; static final String KIE_PMML_REGRESSION_TABLE_REGRESSION_TEMPLATE; }
@Test public void getNumericPredictorWithoutExponentTemplate() { String predictorName = "predictorName"; int exponent = 2; double coefficient = 1.23; NumericPredictor numericPredictor = PMMLModelTestUtils.getNumericPredictor(predictorName, exponent, coefficient); CompilationUnit templateEvaluate = getFromFileName(KIE_PMML_EVALUATE_METHOD_TEMPLATE_JAVA); CompilationUnit cloneEvaluate = templateEvaluate.clone(); ClassOrInterfaceDeclaration evaluateTemplateClass = cloneEvaluate.getClassByName(KIE_PMML_EVALUATE_METHOD_TEMPLATE) .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND)); MethodDeclaration retrieved = KiePMMLRegressionTableRegressionFactory.getNumericPredictorWithoutExponentTemplate(numericPredictor, evaluateTemplateClass); BlockStmt body = retrieved.getBody().get(); String expected = String.format("{\n" + " double coefficient = %s;\n" + " " return input * coefficient;\n" + "}", coefficient); assertEquals(expected, body.toString()); }