public static void addMapPopulation(final Map<String, MethodDeclaration> toAdd,
                                        final BlockStmt body,
                                        final String mapName) {
        Map<String, Expression> toAddExpr = toAdd.entrySet().stream().collect(Collectors.toMap(
                Map.Entry::getKey,
                entry -> {
                    MethodReferenceExpr methodReferenceExpr = new MethodReferenceExpr();
                    methodReferenceExpr.setScope(new ThisExpr());
                    methodReferenceExpr.setIdentifier(entry.getValue().getNameAsString());
                    return methodReferenceExpr;
                }
        ));
        addMapPopulationExpressions(toAddExpr, body, mapName);
    }
@Test
    void addMapPopulation() {
        final Map<String, MethodDeclaration> toAdd = IntStream.range(0, 5).boxed().collect(Collectors.toMap(index -> "KEY_" + index, index -> getMethodDeclaration("METHOD_" + index)));
        BlockStmt body = new BlockStmt();
        String mapName = "MAP_NAME";
        CommonCodegenUtils.addMapPopulation(toAdd, body, mapName);
        NodeList<Statement> statements = body.getStatements();
        assertThat(statements).hasSize(toAdd.size());
        for (Statement statement : statements) {
            assertThat(statement).isInstanceOf(ExpressionStmt.class);
            ExpressionStmt expressionStmt = (ExpressionStmt) statement;
            com.github.javaparser.ast.expr.Expression expression = expressionStmt.getExpression();
            assertThat(expression).isInstanceOf(MethodCallExpr.class);
            MethodCallExpr methodCallExpr = (MethodCallExpr) expression;
            final NodeList<com.github.javaparser.ast.expr.Expression> arguments = methodCallExpr.getArguments();
            assertThat(arguments).hasSize(2);
            assertThat(arguments.get(0)).isInstanceOf(StringLiteralExpr.class);
            assertThat(arguments.get(1)).isInstanceOf(MethodReferenceExpr.class);
            MethodReferenceExpr methodReferenceExpr = (MethodReferenceExpr) arguments.get(1);
            assertThat(methodReferenceExpr.getScope()).isInstanceOf(ThisExpr.class);
            final com.github.javaparser.ast.expr.Expression scope = methodCallExpr.getScope().orElse(null);
            assertThat(scope).isNotNull();
            assertThat(scope).isInstanceOf(NameExpr.class);
            assertThat(((NameExpr) scope).getNameAsString()).isEqualTo(mapName);
        }
        for (Map.Entry<String, MethodDeclaration> entry : toAdd.entrySet()) {
            int matchingDeclarations = (int) statements.stream().filter(statement -> {
                ExpressionStmt expressionStmt = (ExpressionStmt) statement;
                com.github.javaparser.ast.expr.Expression expression = expressionStmt.getExpression();
                MethodCallExpr methodCallExpr = (MethodCallExpr) expression;
                final NodeList<com.github.javaparser.ast.expr.Expression> arguments = methodCallExpr.getArguments();
                if (!entry.getKey().equals(((StringLiteralExpr) arguments.get(0)).getValue())) {
                    return false;
                }
                MethodReferenceExpr methodReferenceExpr = (MethodReferenceExpr) arguments.get(1);
                return entry.getValue().getName().asString().equals(methodReferenceExpr.getIdentifier());
            }).count();
            assertThat(matchingDeclarations).isEqualTo(1);
        }
    }