public static void addListPopulationByObjectCreationExpr(final List<ObjectCreationExpr> toAdd,
                                                             final BlockStmt body,
                                                             final String listName) {
        toAdd.forEach(objectCreationExpr -> {
            NodeList<Expression> arguments = NodeList.nodeList(objectCreationExpr);
            MethodCallExpr methodCallExpr = new MethodCallExpr();
            methodCallExpr.setScope(new NameExpr(listName));
            methodCallExpr.setName("add");
            methodCallExpr.setArguments(arguments);
            ExpressionStmt expressionStmt = new ExpressionStmt();
            expressionStmt.setExpression(methodCallExpr);
            body.addStatement(expressionStmt);
        });
    }
@Test
    void addListPopulation() {
        final List<ObjectCreationExpr> toAdd = IntStream.range(0, 5)
                .mapToObj(i -> {
                    ObjectCreationExpr toReturn = new ObjectCreationExpr();
                    toReturn.setType(String.class);
                    Expression value = new StringLiteralExpr("String" + i);
                    toReturn.setArguments(NodeList.nodeList(value));
                    return toReturn;
                })
                .collect(Collectors.toList());
        BlockStmt body = new BlockStmt();
        String listName = "LIST_NAME";
        CommonCodegenUtils.addListPopulationByObjectCreationExpr(toAdd, body, listName);
        NodeList<Statement> statements = body.getStatements();
        assertThat(statements).hasSameSizeAs(toAdd);
        for (Statement statement : statements) {
            assertThat(statement).isInstanceOf(ExpressionStmt.class);
            ExpressionStmt expressionStmt = (ExpressionStmt) statement;
            assertThat(expressionStmt.getExpression()).isInstanceOf(MethodCallExpr.class);
            MethodCallExpr methodCallExpr = (MethodCallExpr) expressionStmt.getExpression();
            assertThat(methodCallExpr.getScope().get().asNameExpr().getNameAsString()).isEqualTo(listName);
            NodeList<com.github.javaparser.ast.expr.Expression> arguments = methodCallExpr.getArguments();
            assertThat(arguments).hasSize(1);
            assertThat(arguments.get(0)).isInstanceOf(ObjectCreationExpr.class);
            ObjectCreationExpr objectCreationExpr = (ObjectCreationExpr) arguments.get(0);
            assertThat(String.class.getSimpleName()).isEqualTo(objectCreationExpr.getType().asString());
            arguments = objectCreationExpr.getArguments();
            assertThat(arguments).hasSize(1);
            assertThat(arguments.get(0)).isInstanceOf(StringLiteralExpr.class);
        }
        for (ObjectCreationExpr entry : toAdd) {
            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();
                return entry.equals(arguments.get(0).asObjectCreationExpr());
            }).count();
            assertThat(matchingDeclarations).isEqualTo(1);
        }
    }