<commit_before>package net.dean.gbs

import org.testng.annotations.Test as test
import java.nio.file.Paths
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.SimpleFileVisitor
import java.nio.file.attribute.BasicFileAttributes
import java.nio.file.FileVisitResult
import java.io.IOException
import org.testng.Assert

public class CreationTest {
    public test fun basicCreate() {
        val (proj, path) = newProject()
        proj.license = License.APACHE
        proj.add(Language.JAVA)
        proj.build.logging = LoggingFramework.SLF4J
        proj.build.testing = TestingFramework.TESTNG
        proj.build.projectContext.add(Repository.MAVEN_CENTRAL)
        // Random plugin
        proj.build.addGradlePlugin(Dependency("net.swisstech", "gradle-dropwizard", scope = Scope.CLASSPATH))
        proj.build.plugins.add("application")

        // Render and export the project
        Exporter().export(proj, path, ProjectRenderer().render(proj))
        validateGradleBuild(path)
    }

    /**
     * Executes "gradle build" in a given directory and asserts that the exit code of that process is equal to 0.
     */
    private fun validateGradleBuild(rootPath: Path) {
        val command = array("gradle", "build")
        val dir = rootPath.toFile()
        println("Executing command '${command.join(" ")}' in directory '${dir.getAbsolutePath()}'")
        val process = ProcessBuilder()
                .directory(dir)
                .command(*command)
                .inheritIO()
                .start()
        // Should have an exit value of 0
        val exitCode = process.waitFor()
        println("Finished")
        Assert.assertEquals(exitCode, 0)
    }

    /**
     * Returns a Pair of a Project to its root Pat based on the calling method. The group will be
     * "com.example.$callingMethodName" and its base path will be "build/projects/$callingMethodName".
     *
     * stackOffset is the amount of indicies to increase the base count by. A stackOffset of 0 would result in the
     * method that directly called this method, 1 would be the method that called the other method, etc.
     */
    private fun newProject(stackOffset: Int = 0): Pair<Project, Path> {
        val name = Thread.currentThread().getStackTrace()[2 + stackOffset].getMethodName()
        val path = Paths.get("build/projects/$name")
        val proj = Project(name, "com.example.$name")
        // Delete the files before generating it so that if we want to examine the crated files after creation, we can.
        delete(path)
        return proj to path
    }<commit_msg>newProject() now accepts a name parameter<commit_after>package net.dean.gbs

import org.testng.annotations.Test as test
import java.nio.file.Paths
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.SimpleFileVisitor
import java.nio.file.attribute.BasicFileAttributes
import java.nio.file.FileVisitResult
import java.io.IOException
import org.testng.Assert

public class CreationTest {
    public test fun basicCreate() {
        val (proj, path) = newProject("basic")
        proj.license = License.APACHE
        proj.add(Language.JAVA)
        proj.build.logging = LoggingFramework.SLF4J
        proj.build.testing = TestingFramework.TESTNG
        proj.build.projectContext.add(Repository.MAVEN_CENTRAL)
        // Random plugin
        proj.build.addGradlePlugin(Dependency("net.swisstech", "gradle-dropwizard", scope = Scope.CLASSPATH))
        proj.build.plugins.add("application")

        // Render and export the project
        Exporter().export(proj, path, ProjectRenderer().render(proj))
        validateGradleBuild(path)
    }

    /**
     * Executes "gradle build" in a given directory and asserts that the exit code of that process is equal to 0.
     */
    private fun validateGradleBuild(rootPath: Path) {
        val command = array("gradle", "build")
        val dir = rootPath.toFile()
        println("Executing command '${command.join(" ")}' in directory '${dir.getAbsolutePath()}'")
        val process = ProcessBuilder()
                .directory(dir)
                .command(*command)
                .inheritIO()
                .start()
        // Should have an exit value of 0
        val exitCode = process.waitFor()
        println("Finished")
        Assert.assertEquals(exitCode, 0)
    }

    /**
     * Returns a Pair of a Project to its root Pat based on the calling method. The group will be
     * "com.example.$callingMethodName" and its base path will be "build/projects/$callingMethodName".
     *
     * stackOffset is the amount of indicies to increase the base count by. A stackOffset of 0 would result in the
     * method that directly called this method, 1 would be the method that called the other method, etc.
     */
    private fun newProject(name: String): Pair<Project, Path> {
        val path = Paths.get("build/projects/$name")
        val proj = Project(name, "com.example.$name")
        // Delete the files before generating it so that if we want to examine the crated files after creation, we can.
        delete(path)
        return proj to path
    }
{'fraction_non_alphanumeric': 0.09723842862699339, 'fraction_numerical': 0.0027226760015558148, 'mean_word_length': 2.7295141406816534, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5928929', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1387, 'n_words': 442}