KiePMMLDroolsModelFactoryUtils { static void addFieldTypeMapPopulation(BlockStmt body, Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap) { for (Map.Entry<String, KiePMMLOriginalTypeGeneratedType> entry : fieldTypeMap.entrySet()) { KiePMMLOriginalTypeGeneratedType kiePMMLOriginalTypeGeneratedType = entry.getValue(); NodeList<Expression> expressions = NodeList.nodeList(new StringLiteralExpr(kiePMMLOriginalTypeGeneratedType.getOriginalType()), new StringLiteralExpr(kiePMMLOriginalTypeGeneratedType.getGeneratedType())); ObjectCreationExpr objectCreationExpr = new ObjectCreationExpr(); objectCreationExpr.setType(KiePMMLOriginalTypeGeneratedType.class.getName()); objectCreationExpr.setArguments(expressions); expressions = NodeList.nodeList(new StringLiteralExpr(entry.getKey()), objectCreationExpr); body.addStatement(new MethodCallExpr(new NameExpr("fieldTypeMap"), "put", expressions)); } } private  KiePMMLDroolsModelFactoryUtils(); static CompilationUnit getKiePMMLModelCompilationUnit(final DataDictionary dataDictionary,
                                                                 final Model model,
                                                                 final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap,
                                                                 final String packageName,
                                                                 final String javaTemplate,
                                                                 final String modelClassName);  }
@Test public void addFieldTypeMapPopulation() { BlockStmt blockStmt = new BlockStmt(); Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); IntStream.range(0, 3).forEach(index -> { String key = "KEY-" + index; KiePMMLOriginalTypeGeneratedType value = new KiePMMLOriginalTypeGeneratedType("ORIGINALTYPE-" + index, "GENERATEDTYPE-" + index); fieldTypeMap.put(key, value); }); KiePMMLDroolsModelFactoryUtils.addFieldTypeMapPopulation(blockStmt, fieldTypeMap); commonEvaluateFieldTypeMap(blockStmt, fieldTypeMap, fieldTypeMap.size()); }