From f90b7818c7f91764f27a92952da93398cb7fe810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20Andr=C3=A9=20Lund?= Date: Mon, 16 Dec 2024 14:15:43 +0100 Subject: [PATCH] R&R bundler ikke lenger naisful-app - Tilpasser til nytt R&R versjon. --- mediator/build.gradle.kts | 2 ++ .../dagpenger/mottak/ApplicationBuilder.kt | 35 +++++++++++++++---- .../dagpenger/mottak/api/TestApplication.kt | 20 ----------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/mediator/build.gradle.kts b/mediator/build.gradle.kts index 7e6916c6..cc956e3b 100644 --- a/mediator/build.gradle.kts +++ b/mediator/build.gradle.kts @@ -24,6 +24,8 @@ dependencies { implementation(libs.bundles.postgres) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.9.0") + implementation("com.github.navikt.tbd-libs:naisful-app:2024.11.29-15.07-105481e3") + implementation(libs.bundles.jackson) implementation(libs.bundles.ktor.server) diff --git a/mediator/src/main/kotlin/no/nav/dagpenger/mottak/ApplicationBuilder.kt b/mediator/src/main/kotlin/no/nav/dagpenger/mottak/ApplicationBuilder.kt index 8a76e1f6..e8de06af 100644 --- a/mediator/src/main/kotlin/no/nav/dagpenger/mottak/ApplicationBuilder.kt +++ b/mediator/src/main/kotlin/no/nav/dagpenger/mottak/ApplicationBuilder.kt @@ -1,6 +1,11 @@ package no.nav.dagpenger.mottak +import com.github.navikt.tbd_libs.naisful.naisApp import com.github.navikt.tbd_libs.rapids_and_rivers_api.RapidsConnection +import io.micrometer.core.instrument.Clock +import io.micrometer.prometheusmetrics.PrometheusConfig +import io.micrometer.prometheusmetrics.PrometheusMeterRegistry +import io.prometheus.metrics.model.registry.PrometheusRegistry import mu.KotlinLogging import no.nav.dagpenger.mottak.Config.dokarkivTokenProvider import no.nav.dagpenger.mottak.Config.objectMapper @@ -41,12 +46,30 @@ internal class ApplicationBuilder( private val rapidsConnection = RapidApplication - .create(env = env, objectMapper = objectMapper) { engine, _ -> - engine.application.innsendingApi( - innsendingRepository = innsendingRepository, - observer = ferdigstiltInnsendingObserver, - ) - }.apply { + .create(env = env, builder = { + withKtor { preStopHook, rapid -> + naisApp( + meterRegistry = + PrometheusMeterRegistry( + PrometheusConfig.DEFAULT, + PrometheusRegistry.defaultRegistry, + Clock.SYSTEM, + ), + objectMapper = objectMapper, + applicationLogger = KotlinLogging.logger("ApplicationLogger"), + callLogger = KotlinLogging.logger("CallLogger"), + aliveCheck = rapid::isReady, + readyCheck = rapid::isReady, + preStopHook = preStopHook::handlePreStopRequest, + ) { + innsendingApi( + innsendingRepository = innsendingRepository, + observer = ferdigstiltInnsendingObserver, + ) + } + } + }) + .apply { val mediator = InnsendingMediator( innsendingRepository = innsendingRepository, diff --git a/mediator/src/test/kotlin/no/nav/dagpenger/mottak/api/TestApplication.kt b/mediator/src/test/kotlin/no/nav/dagpenger/mottak/api/TestApplication.kt index 9f8dd5e4..fd37b7a9 100644 --- a/mediator/src/test/kotlin/no/nav/dagpenger/mottak/api/TestApplication.kt +++ b/mediator/src/test/kotlin/no/nav/dagpenger/mottak/api/TestApplication.kt @@ -4,13 +4,7 @@ import com.github.navikt.tbd_libs.naisful.test.TestContext import com.github.navikt.tbd_libs.naisful.test.naisfulTestApp import io.ktor.client.request.HttpRequestBuilder import io.ktor.client.request.header -import io.ktor.client.request.request -import io.ktor.client.request.setBody -import io.ktor.client.statement.HttpResponse -import io.ktor.http.ContentType import io.ktor.http.HttpHeaders -import io.ktor.http.HttpMethod -import io.ktor.http.content.TextContent import io.ktor.server.application.Application import io.micrometer.prometheusmetrics.PrometheusConfig import io.micrometer.prometheusmetrics.PrometheusMeterRegistry @@ -58,18 +52,4 @@ internal object TestApplication { internal fun HttpRequestBuilder.autentisert(token: String = azureAd) { this.header(HttpHeaders.Authorization, "Bearer $token") } - - internal suspend fun TestContext.autentisert( - endepunkt: String, - token: String = azureAd, - httpMethod: HttpMethod = HttpMethod.Get, - body: String? = null, - ): HttpResponse = - client.request(endepunkt) { - this.method = httpMethod - body?.let { this.setBody(TextContent(it, ContentType.Application.Json)) } - this.header(HttpHeaders.Authorization, "Bearer $token") - this.header(HttpHeaders.Accept, ContentType.Application.Json.toString()) - this.header(HttpHeaders.ContentType, ContentType.Application.Json.toString()) - } }