@Test
public void addPredictorTerm() {

    String predictorName = "predictorName";
    double coefficient = 23.12;
    String fieldRef = "fieldRef";
    int arity = 3;
    PredictorTerm predictorTerm = PMMLModelTestUtils.getPredictorTerm(predictorName, coefficient,
                                                                      Collections.singletonList(fieldRef));
    ClassOrInterfaceDeclaration tableTemplate = new ClassOrInterfaceDeclaration();
    MethodDeclaration retrieved = KiePMMLRegressionTableRegressionFactory.addPredictorTerm(predictorTerm,
                                                                                           tableTemplate, arity);
    String expected = String.format("evaluatePredictorTerm%d", arity);
    assertEquals(expected, retrieved.getNameAsString());
    BlockStmt body = retrieved.getBody().get();
    expected = String.format("{\n" +
                                     "    final AtomicReference<Double> result = new AtomicReference<>(1.0);\n" +
                                     "    List<String> fieldRefs = Arrays.asList(\"%s\");\n" +
                                     "    for (String key : resultMap.keySet()) {\n" +
                                     "        if (fieldRefs.contains(key)) {\n" +
                                     "            result.set(result.get() * (Double) resultMap.get(key));\n" +
                                     "        }\n" +
                                     "    }\n" +
                                     "    double coefficient = %s;\n" +
                                     "    return result.get() * coefficient;\n" +
                                     "}", fieldRef, coefficient);
    assertEquals(expected, body.toString());
}