diff --git a/build.gradle.kts b/build.gradle.kts index f1aaa6c..12b6609 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("org.springframework.boot") version "3.2.2" @@ -21,7 +21,7 @@ repositories { } } -ext["okhttp3.version"] = "4.9.3" // Token-support tester trenger Mockwebserver. +ext["okhttp3.version"] = "4.12" // Token-support tester trenger MockWebServer. val testContainersVersion = "1.19.4" val tokenSupportVersion = "4.1.3" @@ -40,19 +40,17 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-data-jdbc") implementation("org.springframework.boot:spring-boot-starter-actuator") + implementation("io.micrometer:micrometer-registry-prometheus") + implementation("org.hibernate.validator:hibernate-validator") implementation("org.springframework.kafka:spring-kafka") - implementation("org.springframework.retry:spring-retry") - implementation("org.slf4j:slf4j-api") - implementation("org.flywaydb:flyway-core") implementation("org.postgresql:postgresql") + implementation("org.flywaydb:flyway-core") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin") implementation("org.aspectj:aspectjrt") implementation("org.aspectj:aspectjweaver") - implementation("org.hibernate.validator:hibernate-validator") - implementation("io.micrometer:micrometer-registry-prometheus") + implementation("net.logstash.logback:logstash-logback-encoder:$logstashLogbackEncoderVersion") implementation("no.nav.security:token-client-spring:$tokenSupportVersion") implementation("no.nav.security:token-validation-spring:$tokenSupportVersion") - implementation("net.logstash.logback:logstash-logback-encoder:$logstashLogbackEncoderVersion") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin") implementation("com.openhtmltopdf:openhtmltopdf-pdfbox:$openHtmlToPdfVersion") implementation("com.openhtmltopdf:openhtmltopdf-slf4j:$openHtmlToPdfVersion") implementation("com.openhtmltopdf:openhtmltopdf-svg-support:$openHtmlToPdfVersion") @@ -63,31 +61,37 @@ dependencies { testImplementation(platform("org.testcontainers:testcontainers-bom:$testContainersVersion")) testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.testcontainers:kafka") testImplementation("org.testcontainers:postgresql") + testImplementation("org.testcontainers:kafka") testImplementation("org.awaitility:awaitility") testImplementation("no.nav.security:token-validation-spring-test:$tokenSupportVersion") - testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion") testImplementation("org.amshove.kluent:kluent:$kluentVersion") } -tasks.getByName("bootJar") { - this.archiveFileName.set("app.jar") -} - -tasks.withType { +kotlin { compilerOptions { jvmTarget.set(JvmTarget.JVM_21) freeCompilerArgs.add("-Xjsr305=strict") - if (System.getenv("CI") == "true") { allWarningsAsErrors.set(true) } } } -tasks.withType { - useJUnitPlatform() - testLogging { - events("STANDARD_OUT", "STARTED", "PASSED", "FAILED", "SKIPPED") + +tasks { + test { + useJUnitPlatform() + jvmArgs("-XX:+EnableDynamicAgentLoading") + testLogging { + events("PASSED", "FAILED", "SKIPPED") + exceptionFormat = TestExceptionFormat.FULL + } + failFast = false + } +} + +tasks { + bootJar { + archiveFileName = "app.jar" } } diff --git a/src/test/kotlin/no/nav/helse/flex/ApplicationTest.kt b/src/test/kotlin/no/nav/helse/flex/ApplicationTest.kt index 933e0a2..efa4a36 100644 --- a/src/test/kotlin/no/nav/helse/flex/ApplicationTest.kt +++ b/src/test/kotlin/no/nav/helse/flex/ApplicationTest.kt @@ -2,7 +2,7 @@ package no.nav.helse.flex import org.junit.jupiter.api.Test -class ApplicationTest : Testoppsett() { +class ApplicationTest : FellesTestOppsett() { @Test fun contextLoads() { } diff --git a/src/test/kotlin/no/nav/helse/flex/Testoppsett.kt b/src/test/kotlin/no/nav/helse/flex/FellesTestOppsett.kt similarity index 94% rename from src/test/kotlin/no/nav/helse/flex/Testoppsett.kt rename to src/test/kotlin/no/nav/helse/flex/FellesTestOppsett.kt index b211ed3..ca653dd 100644 --- a/src/test/kotlin/no/nav/helse/flex/Testoppsett.kt +++ b/src/test/kotlin/no/nav/helse/flex/FellesTestOppsett.kt @@ -17,13 +17,13 @@ import org.testcontainers.containers.PostgreSQLContainer import org.testcontainers.utility.DockerImageName import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider -private class PostgreSQLContainer12 : PostgreSQLContainer("postgres:12-alpine") +private class PostgreSQLContainer14 : PostgreSQLContainer("postgres:14-alpine") @TestInstance(TestInstance.Lifecycle.PER_CLASS) @SpringBootTest @EnableMockOAuth2Server @AutoConfigureMockMvc -abstract class Testoppsett { +abstract class FellesTestOppsett { @Autowired lateinit var arkivertVedtakRepository: ArkivertVedtakRepository @@ -34,14 +34,14 @@ abstract class Testoppsett { init { VeraGreenfieldFoundryProvider.initialise() - PostgreSQLContainer12().also { + PostgreSQLContainer14().also { it.start() System.setProperty("spring.datasource.url", it.jdbcUrl) System.setProperty("spring.datasource.username", it.username) System.setProperty("spring.datasource.password", it.password) } - KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.4.1")).also { + KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.5.3")).also { it.start() System.setProperty("KAFKA_BROKERS", it.bootstrapServers) } diff --git a/src/test/kotlin/no/nav/helse/flex/HentingOgPdfGenereringTest.kt b/src/test/kotlin/no/nav/helse/flex/HentingOgPdfGenereringTest.kt index 7234b63..48f3616 100644 --- a/src/test/kotlin/no/nav/helse/flex/HentingOgPdfGenereringTest.kt +++ b/src/test/kotlin/no/nav/helse/flex/HentingOgPdfGenereringTest.kt @@ -12,7 +12,7 @@ import java.time.Instant import java.time.OffsetDateTime import java.time.ZoneId -class HentingOgPdfGenereringTest : Testoppsett() { +class HentingOgPdfGenereringTest : FellesTestOppsett() { @Autowired lateinit var arkivaren: PdfSkaperen diff --git a/src/test/kotlin/no/nav/helse/flex/IntegrasjonTest.kt b/src/test/kotlin/no/nav/helse/flex/IntegrasjonTest.kt index 63aafff..8c5f8dc 100644 --- a/src/test/kotlin/no/nav/helse/flex/IntegrasjonTest.kt +++ b/src/test/kotlin/no/nav/helse/flex/IntegrasjonTest.kt @@ -23,7 +23,7 @@ import java.util.* import java.util.concurrent.TimeUnit @TestMethodOrder(MethodOrderer.OrderAnnotation::class) -class IntegrasjonTest : Testoppsett() { +class IntegrasjonTest : FellesTestOppsett() { @Autowired lateinit var kafkaProducer: KafkaProducer diff --git a/src/test/kotlin/no/nav/helse/flex/PdfTestHjelperTest.kt b/src/test/kotlin/no/nav/helse/flex/PdfTestHjelperTest.kt index ff0d86f..49cb35d 100644 --- a/src/test/kotlin/no/nav/helse/flex/PdfTestHjelperTest.kt +++ b/src/test/kotlin/no/nav/helse/flex/PdfTestHjelperTest.kt @@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired import java.io.File import java.time.OffsetDateTime -class PdfTestHjelperTest : Testoppsett() { +class PdfTestHjelperTest : FellesTestOppsett() { @Autowired lateinit var arkivaren: PdfSkaperen