KiePMMLRegressionTableRegressionFactory { static void populateOutputFieldsMapWithResult(final BlockStmt body, final List<KiePMMLOutputField> outputFields) { outputFields.stream() .filter(outputField -> PREDICTED_VALUE.equals(outputField.getResultFeature())) .forEach(outputField -> { StringLiteralExpr key = new StringLiteralExpr(outputField.getName()); Expression value = new NameExpr("result"); NodeList<Expression> expressions = NodeList.nodeList(key, value); body.addStatement(new MethodCallExpr(new NameExpr("outputFieldsMap"), "put", expressions)); }); } 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 populateOutputFieldsMapWithResult() { final List<KiePMMLOutputField> outputFields = new ArrayList<>(); KiePMMLOutputField predictedOutputField = getOutputField("KOF-TARGET", RESULT_FEATURE.PREDICTED_VALUE, "TARGET"); outputFields.add(predictedOutputField); final List<KiePMMLOutputField> probabilityOutputFields = IntStream.range(0, 2) .mapToObj(index -> getOutputField("KOF-PROB-" + index, RESULT_FEATURE.PROBABILITY, "PROB-" + index)) .collect(Collectors.toList()); outputFields.addAll(probabilityOutputFields); BlockStmt body = new BlockStmt(); KiePMMLRegressionTableRegressionFactory.populateOutputFieldsMapWithResult(body, outputFields); NodeList<Statement> retrieved = body.getStatements(); assertEquals(1, retrieved.size()); assertTrue(retrieved.get(0) instanceof ExpressionStmt); ExpressionStmt expressionStmt = (ExpressionStmt) retrieved.get(0); assertTrue(expressionStmt.getExpression() instanceof MethodCallExpr); MethodCallExpr methodCallExpr = (MethodCallExpr) expressionStmt.getExpression(); assertEquals("outputFieldsMap", methodCallExpr.getScope().get().asNameExpr().toString()); assertEquals("put", methodCallExpr.getName().asString()); NodeList<Expression> arguments = methodCallExpr.getArguments(); assertEquals(2, arguments.size()); assertTrue(arguments.get(0) instanceof StringLiteralExpr); StringLiteralExpr stringLiteralExpr = (StringLiteralExpr)arguments.get(0); assertEquals(predictedOutputField.getName(), stringLiteralExpr.asString()); assertTrue(arguments.get(1) instanceof NameExpr); NameExpr nameExpr = (NameExpr)arguments.get(1); assertEquals("result", nameExpr.getNameAsString()); }