KiePMMLRegressionTableRegressionFactory { static void populateGetTargetCategory(final ClassOrInterfaceDeclaration tableTemplate, final Object targetCategory) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("getTargetCategory").get(0); final BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, methodDeclaration.getName()))); ReturnStmt returnStmt = new ReturnStmt(); if (targetCategory == null) { returnStmt.setExpression(new NameExpr("null")); } else if (targetCategory instanceof String) { returnStmt.setExpression(new StringLiteralExpr((String) targetCategory)); } else { returnStmt.setExpression(new NameExpr(targetCategory.toString())); } body.addStatement(returnStmt); } 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 populateGetTargetCategoryTargetCategoryNull() { KiePMMLRegressionTableRegressionFactory.populateGetTargetCategory(modelTemplate, null); final Expression expectedExpression = new NameExpr("null"); commonEvaluateGetTargetCategory(modelTemplate, expectedExpression); }
@Test public void populateGetTargetCategoryTargetCategoryString() { KiePMMLRegressionTableRegressionFactory.populateGetTargetCategory(modelTemplate, "CATEGORY"); final Expression expectedExpression = new StringLiteralExpr("CATEGORY"); commonEvaluateGetTargetCategory(modelTemplate, expectedExpression); }
@Test public void populateGetTargetCategoryTargetCategoryNoString() { KiePMMLRegressionTableRegressionFactory.populateGetTargetCategory(modelTemplate, 435); final Expression expectedExpression = new NameExpr("435"); commonEvaluateGetTargetCategory(modelTemplate, expectedExpression); }