<commit_before>package org.shipkit.internal.gradle.plugin

import testutil.PluginSpecification


class PluginValidatorTest extends PluginSpecification {

    private static final String META_INF_GRADLE_PLUGINS = 'src/main/resources/META-INF/gradle-plugins'
    private static final String PLUGIN_PACKAGE = 'src/main/groovy/org/sipkit/gradle/'

    def "validate plugin properties files"() {
        given:
        project.file(META_INF_GRADLE_PLUGINS).mkdirs()
        project.file(PLUGIN_PACKAGE).mkdirs()
        def propertiesFile = project.file("$META_INF_GRADLE_PLUGINS/org.sipkit.test.properties") << "implementation-class=org.shipkit.gradle.TestPlugin"
        def pluginFile = project.file("$PLUGIN_PACKAGE/TestPlugin.java") << "TODO content"

        when:
        new PluginValidator().validate([pluginFile] as Set<File>, [propertiesFile] as Set<File>)
        then:
        true
    }

    def "validate plugin properties files (groovy plugin)"() {
        given:
        project.file(META_INF_GRADLE_PLUGINS).mkdirs()
        project.file(PLUGIN_PACKAGE).mkdirs()
        def propertiesFile = project.file("$META_INF_GRADLE_PLUGINS/org.sipkit.test.properties") << "implementation-class=org.shipkit.gradle.TestPlugin"
        def pluginFile = project.file("$PLUGIN_PACKAGE/TestPlugin.groovy") << "TODO content"

        when:
        new PluginValidator().validate([pluginFile] as Set<File>, [propertiesFile] as Set<File>)
        then:
        true
    }


    def "validate missing properties file"() {
        given:
        project.file(META_INF_GRADLE_PLUGINS).mkdirs()
        project.file(PLUGIN_PACKAGE).mkdirs()
        def pluginFile = project.file("$PLUGIN_PACKAGE/TestPlugin.java") << "TODO content"

        when:
        new PluginValidator().validate([pluginFile] as Set<File>, [] as Set<File>)
        then:
        RuntimeException ex = thrown()
        ex.message.contains 'no properties file found for plugin \'Test\''<commit_msg>using spock data tables now<commit_after>package org.shipkit.internal.gradle.plugin

import testutil.PluginSpecification


class PluginValidatorTest extends PluginSpecification {

    private static final String META_INF_GRADLE_PLUGINS = 'src/main/resources/META-INF/gradle-plugins'
    private static final String PLUGIN_PACKAGE = 'src/main/groovy/org/sipkit/gradle/'

    def "validate plugin properties files"(propertiesFileName, className, extension) {
        given:
        project.file(META_INF_GRADLE_PLUGINS).mkdirs()
        project.file(PLUGIN_PACKAGE).mkdirs()
        def propertiesFile = project.file("$META_INF_GRADLE_PLUGINS/${propertiesFileName}.properties") << "implementation-class=org.shipkit.gradle.$className"
        def pluginFile = project.file("$PLUGIN_PACKAGE/${className}.${extension}") << "TODO content"

        when:
        new PluginValidator().validate([pluginFile] as Set<File>, [propertiesFile] as Set<File>)
        then:
        noExceptionThrown()

        where:
        propertiesFileName      | className          | extension
        'org.shipkit.test'      | 'TestPlugin'       | 'java'
        'org.shipkit.test'      | 'TestPlugin'       | 'groovy'
        'org.shipkit.my-sample' | 'MySamplePlugin'   | 'java'
        'org.shipkit.my-sample' | 'MySamplePlugin'   | 'groovy'
    }


    def "validate missing properties file"() {
        given:
        project.file(META_INF_GRADLE_PLUGINS).mkdirs()
        project.file(PLUGIN_PACKAGE).mkdirs()
        def pluginFile = project.file("$PLUGIN_PACKAGE/TestPlugin.java") << "TODO content"

        when:
        new PluginValidator().validate([pluginFile] as Set<File>, [] as Set<File>)
        then:
        RuntimeException ex = thrown()
        ex.message.contains 'no properties file found for plugin \'Test\''
{'fraction_non_alphanumeric': 0.11494558003716485, 'fraction_numerical': 0.0, 'mean_word_length': 3.2528216704288937, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 13, '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': '2279702', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1116, 'n_words': 208}