@Test
public void addGroupedCategoricalPredictor() {

    final List<CategoricalPredictor> categoricalPredictors = IntStream.range(0, 3).mapToObj(index -> {
        String predictorName = "predictorName-" + index;
        double coefficient = 1.23 * index;
        return PMMLModelTestUtils.getCategoricalPredictor(predictorName, index, coefficient);
    }).collect(Collectors.toList());
    ClassOrInterfaceDeclaration tableTemplate = new ClassOrInterfaceDeclaration();
    int arity = 3;
    MethodDeclaration retrieved =
            KiePMMLRegressionTableRegressionFactory.addGroupedCategoricalPredictor(categoricalPredictors,
                                                                                   tableTemplate, arity);
    String expected = String.format("evaluateCategoricalPredictor%d", arity);
    assertEquals(expected, retrieved.getNameAsString());
    BlockStmt body = retrieved.getBody().get();
    expected = String.format("{\n" +
                                     "    if (Objects.equals(%s, input))\n" +
                                     "        return %s;\n" +
                                     "    else if (Objects.equals(%s, input))\n" +
                                     "        return %s;\n" +
                                     "    else if (Objects.equals(%s, input))\n" +
                                     "        return %s;\n" +
                                     "    else\n" +
                                     "        return 0.0;\n" +
                                     "}",
                             categoricalPredictors.get(0).getValue(),
                             categoricalPredictors.get(0).getCoefficient(),
                             categoricalPredictors.get(1).getValue(),
                             categoricalPredictors.get(1).getCoefficient(),
                             categoricalPredictors.get(2).getValue(),
                             categoricalPredictors.get(2).getCoefficient()
    );
    assertEquals(expected, body.toString());
}