static void setStaticGetter(final RegressionCompilationDTO compilationDTO,
                                final LinkedHashMap<String,
                                        KiePMMLTableSourceCategory> regressionTablesMap,
                                final MethodDeclaration staticGetterMethod,
                                final String variableName) {
        final BlockStmt classificationTableBody =
                staticGetterMethod.getBody().orElseThrow(() -> new KiePMMLException(String.format(MISSING_BODY_TEMPLATE, staticGetterMethod)));
        final VariableDeclarator variableDeclarator =
                getVariableDeclarator(classificationTableBody, TO_RETURN).orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_IN_BODY, TO_RETURN, classificationTableBody)));
        final BlockStmt newBody = new BlockStmt();
        final Map<String, Expression> regressionTableCategoriesMap = new LinkedHashMap<>();
        regressionTablesMap.forEach((className, tableSourceCategory) -> {
            MethodCallExpr methodCallExpr = new MethodCallExpr();
            methodCallExpr.setScope(new NameExpr(className));
            methodCallExpr.setName(KiePMMLRegressionTableFactory.GETKIEPMML_TABLE);
            regressionTableCategoriesMap.put(tableSourceCategory.getCategory(), methodCallExpr);
        });
        // populate map
        String categoryTableMapName = String.format(VARIABLE_NAME_TEMPLATE, CATEGORICAL_TABLE_MAP, variableName);
        createPopulatedLinkedHashMap(newBody, categoryTableMapName, Arrays.asList(String.class.getSimpleName(),
                                                                                  KiePMMLRegressionTable.class.getName()),
                                     regressionTableCategoriesMap);
        final MethodCallExpr initializer = variableDeclarator.getInitializer()
                .orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_INITIALIZER_TEMPLATE,
                                                                      TO_RETURN, classificationTableBody)))
                .asMethodCallExpr();
        final MethodCallExpr builder = getChainedMethodCallExprFrom("builder", initializer);
        builder.setArgument(0, new StringLiteralExpr(variableName));
        final REGRESSION_NORMALIZATION_METHOD regressionNormalizationMethod =
                compilationDTO.getDefaultREGRESSION_NORMALIZATION_METHOD();
        getChainedMethodCallExprFrom("withRegressionNormalizationMethod", initializer).setArgument(0,
                                                                                                   new NameExpr(regressionNormalizationMethod.getClass().getSimpleName() + "." + regressionNormalizationMethod.name()));

        OP_TYPE opType = compilationDTO.getOP_TYPE();
        getChainedMethodCallExprFrom("withOpType", initializer).setArgument(0,
                                                                            new NameExpr(opType.getClass().getSimpleName() + "." + opType.name()));
        getChainedMethodCallExprFrom("withCategoryTableMap", initializer).setArgument(0,
                                                                                      new NameExpr(categoryTableMapName));

        boolean isBinary = compilationDTO.isBinary(regressionTablesMap.size());
        final Expression probabilityMapFunctionExpression =
                getProbabilityMapFunctionExpression(compilationDTO.getModelNormalizationMethod(), isBinary);

        getChainedMethodCallExprFrom("withProbabilityMapFunction", initializer).setArgument(0,
                                                                                            probabilityMapFunctionExpression);
        getChainedMethodCallExprFrom("withIsBinary", initializer).setArgument(0, getExpressionForObject(isBinary));

        getChainedMethodCallExprFrom("withTargetField", initializer).setArgument(0,
                                                                                 getExpressionForObject(compilationDTO.getTargetFieldName()));
        getChainedMethodCallExprFrom("withTargetCategory", initializer).setArgument(0,
                                                                                    getExpressionForObject(null));
        classificationTableBody.getStatements().forEach(newBody::addStatement);
        staticGetterMethod.setBody(newBody);
    }
@Test
    void setStaticGetter() throws IOException {
        String variableName = "variableName";
        RegressionTable regressionTableProf = getRegressionTable(3.5, "professional");
        RegressionTable regressionTableCler = getRegressionTable(27.4, "clerical");
        OutputField outputFieldCat = getOutputField("CAT-1", ResultFeature.PROBABILITY, "CatPred-1");
        OutputField outputFieldNum = getOutputField("NUM-1", ResultFeature.PROBABILITY, "NumPred-0");
        OutputField outputFieldPrev = getOutputField("PREV", ResultFeature.PREDICTED_VALUE, null);

        String targetField = "targetField";
        DataField dataField = new DataField();
        dataField.setName(targetField);
        dataField.setOpType(OpType.CATEGORICAL);
        DataDictionary dataDictionary = new DataDictionary();
        dataDictionary.addDataFields(dataField);
        RegressionModel regressionModel = new RegressionModel();
        regressionModel.setNormalizationMethod(RegressionModel.NormalizationMethod.CAUCHIT);
        regressionModel.addRegressionTables(regressionTableProf, regressionTableCler);
        regressionModel.setModelName(getGeneratedClassName("RegressionModel"));
        Output output = new Output();
        output.addOutputFields(outputFieldCat, outputFieldNum, outputFieldPrev);
        regressionModel.setOutput(output);
        MiningField miningField = new MiningField();
        miningField.setUsageType(MiningField.UsageType.TARGET);
        miningField.setName(dataField.getName());
        MiningSchema miningSchema = new MiningSchema();
        miningSchema.addMiningFields(miningField);
        regressionModel.setMiningSchema(miningSchema);
        PMML pmml = new PMML();
        pmml.setDataDictionary(dataDictionary);
        pmml.addModels(regressionModel);
        final CommonCompilationDTO<RegressionModel> source =
                CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME,
                                                                       pmml,
                                                                       regressionModel,
                                                                       new PMMLCompilationContextMock(),
                                                                       "FILENAME");
        final RegressionCompilationDTO compilationDTO =
                RegressionCompilationDTO.fromCompilationDTORegressionTablesAndNormalizationMethod(source,
                                                                                                  regressionModel.getRegressionTables(),
                                                                                                  regressionModel.getNormalizationMethod());

        final LinkedHashMap<String,
                KiePMMLTableSourceCategory> regressionTablesMap = new LinkedHashMap<>();

        regressionModel.getRegressionTables().forEach(regressionTable -> {
            String key = "defpack." + regressionTable.getTargetCategory().toString().toUpperCase();
            KiePMMLTableSourceCategory value = new KiePMMLTableSourceCategory("",
                    regressionTable.getTargetCategory().toString());
            regressionTablesMap.put(key, value);
        });
        final MethodDeclaration staticGetterMethod = STATIC_GETTER_METHOD.clone();
        KiePMMLClassificationTableFactory.setStaticGetter(compilationDTO,
                regressionTablesMap,
                staticGetterMethod,
                variableName);
        String text = getFileContent(TEST_02_SOURCE);
        MethodDeclaration expected = JavaParserUtils.parseMethod(text);
        assertThat(JavaParserUtils.equalsNode(expected, staticGetterMethod)).isTrue();
    }