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 {
  implementation project(":jvm-libs:generic:extensions:futures")
  implementation project(":jvm-libs:generic:extensions:kotlin")
  implementation project(':jvm-libs:generic:persistence:db')
  implementation project(":transaction-exclusion-api:core")
  implementation "com.fasterxml.jackson.core:jackson-databind:${libs.versions.jackson.get()}"
  implementation "io.vertx:vertx-pg-client:${libs.versions.vertx.get()}"

  testImplementation(testFixtures(project(":transaction-exclusion-api: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")
}
