// simply declaring the source sets is sufficient to populate them with
// src/integrationTest/java+resources + src/integrationTest/kotlin.
sourceSets {
    integrationTest {
    }
}
kotlin {
    sourceSets {
        testIntegration {
        }
    }
}

dependencies {
    api("com.github.f4b6a3:uuid-creator:6.1.1")

    implementation project(':airbyte-cdk:bulk:core:bulk-cdk-core-base')
    implementation 'org.apache.commons:commons-lang3:3.17.0'

    // For ranges and rangesets
    implementation("com.google.guava:guava:33.3.0-jre")

    testFixturesApi testFixtures(project(':airbyte-cdk:bulk:core:bulk-cdk-core-base'))

    testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1")
    testImplementation("io.mockk:mockk:1.13.12")
    implementation "org.jetbrains.kotlin:kotlin-reflect:2.0.20"
    testFixturesImplementation "uk.org.webcompere:system-stubs-jupiter:2.1.7"

    implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
    implementation 'com.fasterxml.jackson.module:jackson-module-afterburner'

    integrationTestImplementation testFixtures(project)
}

def integrationTestTask = tasks.register('integrationTest', Test) {
    description = 'Runs the integration tests.'
    group = 'verification'
    testClassesDirs = sourceSets.integrationTest.output.classesDirs
    classpath = sourceSets.integrationTest.runtimeClasspath
    useJUnitPlatform()

    jvmArgs = project.test.jvmArgs
    systemProperties = project.test.systemProperties
    maxParallelForks = project.test.maxParallelForks
    maxHeapSize = project.test.maxHeapSize

    testLogging() {
        events 'skipped', 'started', 'passed', 'failed'
        exceptionFormat 'full'
    }
}

// These tests are lightweight enough to run on every PR.
tasks.named('check').configure {
    dependsOn integrationTest
}

project.tasks.matching {
    it.name == 'spotbugsIntegrationTestLegacy' ||
            it.name == 'spotbugsIntegrationTest' ||
            it.name == 'spotbugsTest' ||
            it.name == 'spotbugsMain' ||
            it.name == 'spotbugsTestFixtures'
}.configureEach {
    enabled = false
}

test {
    systemProperties(["mockk.junit.extension.requireParallelTesting":"true"])
}

configurations {
    integrationTestImplementation.extendsFrom testImplementation
    integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
}
