import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
  id "net.consensys.zkevm.kotlin-library-conventions"
}

dependencies {
  api(project(":coordinator:core"))
  api(project(":coordinator:clients:prover-client:serialization"))
  implementation(project(":jvm-libs:generic:persistence:db"))

  testImplementation("com.fasterxml.jackson.core:jackson-databind:${libs.versions.jackson.get()}")
  testImplementation("com.fasterxml.jackson.core:jackson-annotations:${libs.versions.jackson.get()}")
  testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:${libs.versions.jackson.get()}")
  testImplementation "io.consensys.tuweni:tuweni-units:${libs.versions.tuweni.get()}"
  testImplementation(project(":coordinator:persistence:db-common"))
  testImplementation(testFixtures(project(":coordinator:core")))
  testImplementation(testFixtures(project(":jvm-libs:generic:extensions:kotlin")))
  testImplementation(testFixtures(project(":jvm-libs:generic:persistence:db")))
  testImplementation("io.vertx:vertx-junit5")
}

sourceSets {
  integrationTest {
    kotlin {
      compileClasspath += main.output
      runtimeClasspath += main.output
    }
    compileClasspath += sourceSets.main.output + sourceSets.main.compileClasspath + sourceSets.test.compileClasspath
    runtimeClasspath += sourceSets.main.output + sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath
  }
}

task integrationTest(type: Test) { test ->
  testLogging {
    events TestLogEvent.FAILED,
        TestLogEvent.SKIPPED,
        TestLogEvent.STANDARD_ERROR,
        TestLogEvent.STANDARD_OUT
    exceptionFormat TestExceptionFormat.FULL
    showCauses true
    showExceptions true
    showStackTraces true
    showStandardStreams false
  }
  description = "Runs integration tests."
  group = "verification"
  useJUnitPlatform()

  classpath = sourceSets.integrationTest.runtimeClasspath
  testClassesDirs = sourceSets.integrationTest.output.classesDirs

  dependsOn(":localStackPostgresDbOnlyComposeUp")
}
