From 3b594a2b34ccd63c7b4d9a898515b802e8e457ca Mon Sep 17 00:00:00 2001 From: Thomas Johansen Date: Fri, 25 Oct 2024 11:32:05 +0200 Subject: [PATCH] Oppdatert etter flytting av kotlin-clients --- .../api-start-stopp-perioder/build.gradle.kts | 6 +- apps/bekreftelse-api/build.gradle.kts | 2 +- apps/bekreftelse-tjeneste/build.gradle.kts | 2 +- apps/bekreftelse-utgang/build.gradle.kts | 2 +- apps/hendelselogg-backup/build.gradle.kts | 5 +- gradle/libs.versions.toml | 13 +- lib/aareg-client/build.gradle.kts | 77 ++-------- .../no/nav/paw/aareg/AaregClientTest.kt | 41 +----- lib/pdl-client/build.gradle.kts | 81 +++-------- .../no/nav/paw/{ => pdl}/MockPdlClient.kt | 3 +- .../kotlin/no/nav/paw/pdl/PdlClientTest.kt | 131 +++++++++++------- settings.gradle.kts | 4 + 12 files changed, 140 insertions(+), 227 deletions(-) rename lib/pdl-client/src/test/kotlin/no/nav/paw/{ => pdl}/MockPdlClient.kt (92%) diff --git a/apps/api-start-stopp-perioder/build.gradle.kts b/apps/api-start-stopp-perioder/build.gradle.kts index 53c7fd3d..12db9db9 100644 --- a/apps/api-start-stopp-perioder/build.gradle.kts +++ b/apps/api-start-stopp-perioder/build.gradle.kts @@ -93,8 +93,8 @@ jib { environment = mapOf( "IMAGE_WITH_VERSION" to "${image ?: project.name}:${project.version}", "OTEL_INSTRUMENTATION_METHODS_INCLUDE" to ("io.ktor.server.routing.Routing[interceptor,executeResult];" + - "io.ktor.server.netty.NettyApplicationCallHandler[handleRequest,exceptionCaught];") + - "io.ktor.serialization.jackson.JacksonConverter[deserialize,serializeNullable]" + "io.ktor.server.netty.NettyApplicationCallHandler[handleRequest,exceptionCaught];") + + "io.ktor.serialization.jackson.JacksonConverter[deserialize,serializeNullable]" ) jvmFlags = listOf("-XX:ActiveProcessorCount=4", "-XX:+UseZGC", "-XX:+ZGenerational") } @@ -107,7 +107,7 @@ mapOf( "${layout.projectDirectory}/src/main/resources/openapi/opplysninger.yaml" to "${generatedCodePackageName}.opplysningermottatt", "${layout.projectDirectory}/src/main/resources/openapi/startstopp.yaml" to "${generatedCodePackageName}.startstopp" ).map { (openApiDocFile, pkgName) -> - val taskName = "generate${pkgName.capitalized()}" + val taskName = "generate${pkgName.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }}" tasks.register(taskName, GenerateTask::class) { generatorName.set("kotlin-server") library = "ktor" diff --git a/apps/bekreftelse-api/build.gradle.kts b/apps/bekreftelse-api/build.gradle.kts index d9bfb148..5167a589 100644 --- a/apps/bekreftelse-api/build.gradle.kts +++ b/apps/bekreftelse-api/build.gradle.kts @@ -35,7 +35,7 @@ dependencies { // Serialization implementation(libs.ktor.serialization.jackson) - implementation(libs.ktor.serialization.json) + implementation(libs.ktor.serialization.kotlinx.json) implementation(libs.jackson.datatypeJsr310) // Authentication diff --git a/apps/bekreftelse-tjeneste/build.gradle.kts b/apps/bekreftelse-tjeneste/build.gradle.kts index 46209f64..2df5503c 100644 --- a/apps/bekreftelse-tjeneste/build.gradle.kts +++ b/apps/bekreftelse-tjeneste/build.gradle.kts @@ -26,7 +26,7 @@ dependencies { // Serialization implementation(libs.ktor.serialization.jackson) - implementation(libs.ktor.serialization.json) + implementation(libs.ktor.serialization.kotlinx.json) implementation(libs.jackson.datatypeJsr310) // Tooling diff --git a/apps/bekreftelse-utgang/build.gradle.kts b/apps/bekreftelse-utgang/build.gradle.kts index 184dbf02..17e810f8 100644 --- a/apps/bekreftelse-utgang/build.gradle.kts +++ b/apps/bekreftelse-utgang/build.gradle.kts @@ -25,7 +25,7 @@ dependencies { // Serialization implementation(libs.ktor.serialization.jackson) - implementation(libs.ktor.serialization.json) + implementation(libs.ktor.serialization.kotlinx.json) implementation(libs.jackson.datatypeJsr310) // Tooling diff --git a/apps/hendelselogg-backup/build.gradle.kts b/apps/hendelselogg-backup/build.gradle.kts index 5c07e06a..9dafa297 100644 --- a/apps/hendelselogg-backup/build.gradle.kts +++ b/apps/hendelselogg-backup/build.gradle.kts @@ -1,4 +1,3 @@ -import org.gradle.configurationcache.extensions.capitalized import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.openapitools.generator.gradle.plugin.tasks.GenerateTask @@ -107,7 +106,7 @@ val generatedCodeOutputDir = "${layout.buildDirectory.get()}/generated/" mapOf( "${layout.projectDirectory}/src/main/resources/openapi/Brukerstoette.yaml" to "${generatedCodePackageName}.brukerstoette" ).map { (openApiDocFile, pkgName) -> - val taskName = "generate${pkgName.capitalized()}" + val taskName = "generate${pkgName.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }}" tasks.register(taskName, GenerateTask::class) { generatorName.set("kotlin-server") library = "ktor" @@ -142,7 +141,7 @@ mapOf( mapOf( "${layout.projectDirectory}/src/main/resources/openapi/oppslags-api.yaml" to "${generatedCodePackageName}.oppslagsapi" ).map { (openApiDocFile, pkgName) -> - val taskName = "generate${pkgName.capitalized()}" + val taskName = "generate${pkgName.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }}" tasks.register(taskName, GenerateTask::class) { generatorName.set("kotlin") library = "jvm-ktor" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index de4edb13..06f0d234 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,13 +1,14 @@ [versions] pawPdlClientVersion = "24.10.18.41-1" pawAaregClientVersion = "24.07.04.18-1" +noNavSecurityVersion = "5.0.5" +noNavCommonVersion = "3.2024.05.23_05.46-2b29fa343e8e" arbeidssokerregisteretVersion = "1.9348086045.48-1" bekreftelseSchemaVersion = "24.10.21.12-1" arrowVersion = "1.2.4" arrowJacksonIntegrationVersion = "0.14.1" -noNavCommonVersion = "3.2024.05.23_05.46-2b29fa343e8e" -noNavSecurityVersion = "5.0.5" comSksamuelHopliteVersion = "2.8.2" +graphqlClientVersion = "7.1.1" orgApacheKafkaVersion = "3.7.0" ioConfluentKafkaVersion = "7.7.1" orgApacheAvroVersion = "1.12.0" @@ -27,6 +28,8 @@ coroutinesVersion = "1.9.0" postgresDriverVersion = "42.7.4" flywayVersion = "10.20.0" hikariVersion = "6.0.0" +kotlinxCoroutinesVersion = "1.8.1" +kotlinxSerializationJsonVersion = "1.7.3" ktorVersion = "2.3.12" [libraries] @@ -36,6 +39,8 @@ arrow-core-serialization = { group = "io.arrow-kt", name = "arrow-core-serializa arrow-integration-jackson = { group = "io.arrow-kt", name = "arrow-integrations-jackson-module", version.ref = "arrowJacksonIntegrationVersion" } logbackClassic = { group = "ch.qos.logback", name = "logback-classic", version.ref = "logbackVersion" } logstashLogbackEncoder = { group = "net.logstash.logback", name = "logstash-logback-encoder", version.ref = "logstashVersion" } +kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutinesVersion" } +kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerializationJsonVersion" } ktor-client-contentNegotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktorVersion" } ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktorVersion" } ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktorVersion" } @@ -57,7 +62,7 @@ ktor-server-testJvm = { group = "io.ktor", name = "ktor-server-tests-jvm", versi ktor-serialization-core = { group = "io.ktor", name = "ktor-serialization", version.ref = "ktorVersion" } ktor-serialization-jvm = { group = "io.ktor", name = "ktor-serialization-jvm", version.ref = "ktorVersion" } ktor-serialization-jackson = { group = "io.ktor", name = "ktor-serialization-jackson", version.ref = "ktorVersion" } -ktor-serialization-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktorVersion" } +ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktorVersion" } opentelemetry-api = { group = "io.opentelemetry", name = "opentelemetry-api", version.ref = "otelTargetSdkVersion" } opentelemetry-ktor = { group = "io.opentelemetry.instrumentation", name = "opentelemetry-ktor-2.0", version.ref = "otelInstrumentationKtorVersion" } opentelemetry-annotations = { group = "io.opentelemetry.instrumentation", name = "opentelemetry-instrumentation-annotations", version.ref = "otelInstrumentationVersion" } @@ -80,6 +85,8 @@ nav-common-log = { group = "no.nav.common", name = "log", version.ref = "noNavCo nav-common-auditLog = { group = "no.nav.common", name = "audit-log", version.ref = "noNavCommonVersion" } nav-security-tokenValidationKtorV2 = { group = "no.nav.security", name = "token-validation-ktor-v2", version.ref = "noNavSecurityVersion" } nav-security-tokenClientCore = { group = "no.nav.security", name = "token-client-core", version.ref = "noNavSecurityVersion" } +graphql-client = { group = "com.expediagroup", name = "graphql-kotlin-client", version.ref = "graphqlClientVersion" } +graphql-ktor-client = { group = "com.expediagroup", name = "graphql-kotlin-ktor-client", version.ref = "graphqlClientVersion" } hoplite-core = { group = "com.sksamuel.hoplite", name = "hoplite-core", version.ref = "comSksamuelHopliteVersion" } hoplite-toml = { group = "com.sksamuel.hoplite", name = "hoplite-toml", version.ref = "comSksamuelHopliteVersion" } hoplite-yaml = { group = "com.sksamuel.hoplite", name = "hoplite-yaml", version.ref = "comSksamuelHopliteVersion" } diff --git a/lib/aareg-client/build.gradle.kts b/lib/aareg-client/build.gradle.kts index c2f92199..69f076e3 100644 --- a/lib/aareg-client/build.gradle.kts +++ b/lib/aareg-client/build.gradle.kts @@ -1,77 +1,28 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - plugins { kotlin("jvm") kotlin("plugin.serialization") - id("org.jmailen.kotlinter") - id("maven-publish") - java -} - -group = "no.nav.paw" - -tasks { - withType { - kotlinOptions.jvmTarget = "11" - } - test { - useJUnitPlatform() - } } +val jvmMajorVersion: String by project -java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 +dependencies { + api(libs.kotlinx.serialization.json) - withSourcesJar() -} + implementation(libs.ktor.client.contentNegotiation) + implementation(libs.ktor.client.okhttp) + implementation(libs.ktor.serialization.kotlinx.json) + implementation(libs.ktor.client.logging) -repositories { - mavenCentral() - mavenNav("*") + testImplementation(libs.bundles.testLibsWithUnitTesting) + testImplementation(libs.ktor.client.mock) } -publishing { - publications { - create("mavenJava") { - from(components["java"]) - } - } - repositories { - mavenNav("paw-kotlin-clients") +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(jvmMajorVersion)) } } -dependencies { - val ktorVersion: String by project - val mockkVersion: String by project - val kotlinSerializationVersion: String by project - val junitJupiterVersion: String by project - val slf4jVersion: String by project - - api("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializationVersion") - - implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion") - implementation("io.ktor:ktor-client-core:$ktorVersion") - implementation("io.ktor:ktor-client-okhttp:$ktorVersion") - implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion") - implementation("io.ktor:ktor-client-logging:$ktorVersion") - - testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion") - testImplementation("io.ktor:ktor-client-mock:$ktorVersion") - testImplementation("io.mockk:mockk:$mockkVersion") - testImplementation("org.slf4j:slf4j-simple:$slf4jVersion") -} - -fun RepositoryHandler.mavenNav(repo: String): MavenArtifactRepository { - val githubPassword: String by project - - return maven { - setUrl("https://maven.pkg.github.com/navikt/$repo") - credentials { - username = "x-access-token" - password = githubPassword - } - } +tasks.withType().configureEach { + useJUnitPlatform() } diff --git a/lib/aareg-client/src/test/kotlin/no/nav/paw/aareg/AaregClientTest.kt b/lib/aareg-client/src/test/kotlin/no/nav/paw/aareg/AaregClientTest.kt index fe56a82a..cab5633d 100644 --- a/lib/aareg-client/src/test/kotlin/no/nav/paw/aareg/AaregClientTest.kt +++ b/lib/aareg-client/src/test/kotlin/no/nav/paw/aareg/AaregClientTest.kt @@ -1,48 +1,21 @@ package no.nav.paw.aareg +import io.kotest.core.spec.style.FreeSpec +import io.kotest.matchers.collections.shouldContain import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Test -class AaregClientTest { +class AaregClientTest : FreeSpec({ /* API Description: https://navikt.github.io/aareg/tjenester/integrasjon/api/ */ - @Test - fun `Returnerer gyldig objekt når alt er oK`() { + "Returnerer gyldig objekt når alt er ok" { val response = runBlocking { mockAaregClient(MockResponse.arbeidsforhold) .hentArbeidsforhold("ident", "call-id") } - assertTrue(response.any { it.arbeidsgiver.organisasjonsnummer == "896929119" }) + + response.map { it.arbeidsgiver.organisasjonsnummer } shouldContain "896929119" } -// -// @Test -// fun test_OK_svar_Med_Uventet_JSON() { -// val response = runBlocking { -// mockAaregClient(MockResponse.error) -// .hentArbeidsforhold("hei", "54-56 That's My Number") -// } -// val empty = emptyList() -// assertEquals(empty, response) -// } -// -// @Test -// fun test_Server_Error() { -// val response = runBlocking { -// mockAaregClient("blablabla", HttpStatusCode.InternalServerError) -// .hentArbeidsforhold("hei", "123456") -// } -// val empty = emptyList() -// assertEquals(empty, response) -// } -// -// @Test -// fun realDeal() { -// val client = AaregClient(url = "blah") { "tja" } -// val response = runBlocking { client.hentArbeidsforhold("hei", "Number 2") } -// assertEquals(emptyList(), response) -// } -} +}) diff --git a/lib/pdl-client/build.gradle.kts b/lib/pdl-client/build.gradle.kts index ff6baaa4..8d8945b3 100644 --- a/lib/pdl-client/build.gradle.kts +++ b/lib/pdl-client/build.gradle.kts @@ -1,28 +1,23 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -group = "no.nav.paw" - plugins { kotlin("jvm") kotlin("plugin.serialization") id("com.expediagroup.graphql") - id("org.jmailen.kotlinter") - id("maven-publish") } -tasks { - withType { - kotlinOptions.jvmTarget = "21" - } - test { - useJUnitPlatform() - } - lintKotlinMain { - exclude("no/nav/paw/pdl/graphql/generated/**/*.kt") - } - formatKotlinMain { - exclude("no/nav/paw/pdl/graphql/generated/**/*.kt") - } +val jvmMajorVersion: String by project + +dependencies { + api(libs.kotlinx.serialization.json) + + implementation(libs.ktor.client.contentNegotiation) + implementation(libs.ktor.client.okhttp) + implementation(libs.ktor.serialization.kotlinx.json) + implementation(libs.ktor.client.logging) + api(libs.graphql.ktor.client) + + testImplementation(libs.bundles.testLibsWithUnitTesting) + testImplementation(libs.ktor.client.mock) + testImplementation(libs.kotlinx.coroutines.core) } java { @@ -32,21 +27,6 @@ java { } } -repositories { - mavenCentral() - mavenNav("*") -} - -publishing { - publications { - create("mavenJava") { - from(components["java"]) - } - } - repositories { - mavenNav("paw-kotlin-clients") - } -} graphql { client { @@ -57,35 +37,6 @@ graphql { } } -dependencies { - val coroutinesVersion: String by project - val kotlinSerializationVersion: String by project - val ktorVersion: String by project - val mockkVersion: String by project - val graphQLKotlinVersion: String by project - - api("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializationVersion") - - implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion") - implementation("io.ktor:ktor-client-core:$ktorVersion") - implementation("io.ktor:ktor-client-okhttp:$ktorVersion") - implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion") - api("com.expediagroup:graphql-kotlin-ktor-client:$graphQLKotlinVersion") - - testImplementation("io.ktor:ktor-client-mock:$ktorVersion") - testImplementation("io.mockk:mockk:$mockkVersion") - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") - testImplementation(kotlin("test")) -} - -fun RepositoryHandler.mavenNav(repo: String): MavenArtifactRepository { - val githubPassword: String by project - - return maven { - setUrl("https://maven.pkg.github.com/navikt/$repo") - credentials { - username = "x-access-token" - password = githubPassword - } - } +tasks.withType().configureEach { + useJUnitPlatform() } diff --git a/lib/pdl-client/src/test/kotlin/no/nav/paw/MockPdlClient.kt b/lib/pdl-client/src/test/kotlin/no/nav/paw/pdl/MockPdlClient.kt similarity index 92% rename from lib/pdl-client/src/test/kotlin/no/nav/paw/MockPdlClient.kt rename to lib/pdl-client/src/test/kotlin/no/nav/paw/pdl/MockPdlClient.kt index 81cc189d..3a02813e 100644 --- a/lib/pdl-client/src/test/kotlin/no/nav/paw/MockPdlClient.kt +++ b/lib/pdl-client/src/test/kotlin/no/nav/paw/pdl/MockPdlClient.kt @@ -1,4 +1,4 @@ -package no.nav.paw +package no.nav.paw.pdl import io.ktor.client.HttpClient import io.ktor.client.engine.mock.MockEngine @@ -7,7 +7,6 @@ import io.ktor.http.ContentType import io.ktor.http.HttpHeaders import io.ktor.http.HttpStatusCode import io.ktor.http.headersOf -import no.nav.paw.pdl.PdlClient fun mockPdlClient(content: String): PdlClient { val mockEngine = diff --git a/lib/pdl-client/src/test/kotlin/no/nav/paw/pdl/PdlClientTest.kt b/lib/pdl-client/src/test/kotlin/no/nav/paw/pdl/PdlClientTest.kt index 67c3a3e7..7725b0b7 100644 --- a/lib/pdl-client/src/test/kotlin/no/nav/paw/pdl/PdlClientTest.kt +++ b/lib/pdl-client/src/test/kotlin/no/nav/paw/pdl/PdlClientTest.kt @@ -1,33 +1,35 @@ package no.nav.paw.pdl +import io.kotest.assertions.throwables.shouldThrow +import io.kotest.core.spec.style.FreeSpec +import io.kotest.matchers.collections.shouldContain +import io.kotest.matchers.shouldBe import kotlinx.coroutines.runBlocking -import no.nav.paw.mockPdlClient import no.nav.paw.pdl.graphql.generated.enums.Oppholdstillatelse -import java.util.UUID -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertFailsWith -import kotlin.test.assertTrue - -class PdlClientTest { - private val callId = UUID.randomUUID().toString() - private val navConsumerId = "nav-consumer-id" - - @Test - fun `Forventer gyldig respons fra hentAktorId`() { +import java.util.* + +class PdlClientTest : FreeSpec({ + + val callId = UUID.randomUUID().toString() + val navConsumerId = "nav-consumer-id" + + "Forventer gyldig respons fra hentAktorId" { val respons = readResource("hentIdenter-response.json") val pdlClient = mockPdlClient(respons) - val resultat = runBlocking { pdlClient.hentAktorId("2649500819544", callId, navConsumerId, "B123") } + val resultat = runBlocking { + pdlClient.hentAktorId("2649500819544", callId, navConsumerId, "B123") + } val forventet = "2649500819544" - assertEquals(forventet, resultat) + + resultat shouldBe forventet } - @Test - fun `Forventer feilmelding fra hentIdenter`() { + "Forventer feilmelding fra hentIdenter" { val respons = readResource("error-response.json") val pdlClient = mockPdlClient(respons) - assertFailsWith( + + shouldThrow( block = { runBlocking { pdlClient.hentIdenter( @@ -41,73 +43,100 @@ class PdlClientTest { ) } - @Test - fun `Forventer gyldig respons fra hentIdenter`() { + "Forventer gyldig respons fra hentIdenter" { val respons = readResource("hentIdenter-response.json") val pdlClient = mockPdlClient(respons) - val resultat = - runBlocking { - pdlClient.hentIdenter( - ident = "2649500819544", - callId = callId, - navConsumerId = navConsumerId, - behandlingsnummer = "B123", - ) - } + val resultat = runBlocking { + pdlClient.hentIdenter( + ident = "2649500819544", + callId = callId, + navConsumerId = navConsumerId, + behandlingsnummer = "B123", + ) + } val forventet = "09127821914" - assertEquals(forventet, resultat!!.first().ident) + + resultat!!.first().ident shouldBe forventet } - @Test - fun `Forventer gyldig respons fra hentOpphold`() { + "Forventer gyldig respons fra hentOpphold" { val respons = readResource("hentOpphold-response.json") val pdlClient = mockPdlClient(respons) - val resultat = runBlocking { pdlClient.hentOpphold("2649500819544", callId, navConsumerId, "B123") } + val resultat = runBlocking { + pdlClient.hentOpphold("2649500819544", callId, navConsumerId, "B123") + } val forventet = Oppholdstillatelse.PERMANENT - assertEquals(forventet, resultat!!.first().type) + + resultat!!.first().type shouldBe forventet } - @Test - fun `Forventer gyldig respons fra hentPerson`() { + "Forventer gyldig respons fra hentPerson" { val respons = readResource("hentPerson-response.json") val pdlClient = mockPdlClient(respons) - val resultat = runBlocking { pdlClient.hentPerson("2649500819544", callId, null, navConsumerId, behandlingsnummer = "B123") } + val resultat = runBlocking { + pdlClient.hentPerson( + "2649500819544", + callId, + null, + navConsumerId, + behandlingsnummer = "B123" + ) + } val forventet = Oppholdstillatelse.PERMANENT - assertEquals(forventet, resultat!!.opphold.first().type) + + resultat!!.opphold.first().type shouldBe forventet } - @Test - fun `Forventer gyldig respons fra hentPersonBolk`() { + "Forventer gyldig respons fra hentPersonBolk" { val respons = readResource("hentPersonBolk-response.json") val pdlClient = mockPdlClient(respons) - val resultat = runBlocking { pdlClient.hentPersonBolk(listOf("2649500819544"), callId, null, navConsumerId, false, "B123") } + val resultat = runBlocking { + pdlClient.hentPersonBolk( + listOf("2649500819544"), + callId, + null, + navConsumerId, + false, + "B123" + ) + } val forventet = Oppholdstillatelse.PERMANENT - assertEquals(forventet, resultat!!.first().person!!.opphold.first().type) + + resultat!!.first().person!!.opphold.first().type shouldBe forventet } - @Test - fun `Forventer gyldig respons fra hentForenkletStatus`() { + "Forventer gyldig respons fra hentForenkletStatus" { val respons = readResource("hentForenkletStatus-response.json") val pdlClient = mockPdlClient(respons) - val resultat = runBlocking { pdlClient.hentForenkletStatus("2649500819544", callId, null, navConsumerId, "B123") } + val resultat = + runBlocking { pdlClient.hentForenkletStatus("2649500819544", callId, null, navConsumerId, "B123") } val forventet = "bosattEtterFolkeregisterloven" - assertTrue { resultat!!.folkeregisterpersonstatus.any { it.forenkletStatus == forventet } } + + resultat!!.folkeregisterpersonstatus.map { it.forenkletStatus } shouldContain forventet } - @Test - fun `Forventer gyldig respons fra hentForenkletStatusBolk`() { + "Forventer gyldig respons fra hentForenkletStatusBolk" { val respons = readResource("hentForenkletStatusBolk-response.json") val pdlClient = mockPdlClient(respons) - val resultat = runBlocking { pdlClient.hentForenkletStatusBolk(listOf("2649500819544"), callId, null, navConsumerId, "B123") } + val resultat = runBlocking { + pdlClient.hentForenkletStatusBolk( + listOf("2649500819544"), + callId, + null, + navConsumerId, + "B123" + ) + } val forventet = "bosattEtterFolkeregisterloven" - assertTrue { resultat!!.first().person!!.folkeregisterpersonstatus.any { it.forenkletStatus == forventet } } + + resultat!!.first().person!!.folkeregisterpersonstatus.map { it.forenkletStatus } shouldContain forventet } -} +}) private fun readResource(filename: String) = ClassLoader.getSystemResource(filename).readText() diff --git a/settings.gradle.kts b/settings.gradle.kts index 35e9e66f..d01decaf 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,9 +1,11 @@ plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" kotlin("jvm") version "2.0.21" apply false + kotlin("plugin.serialization") version "2.0.21" apply false id("com.google.cloud.tools.jib") version "3.4.4" apply false id("org.openapi.generator") version "7.9.0" apply false id("com.github.davidmc24.gradle.plugin.avro") version "1.9.1" apply false + id("com.expediagroup.graphql") version "7.1.1" apply false } rootProject.name = "paw-arbeidssoekerregisteret-monorepo-intern" @@ -14,6 +16,8 @@ include( "lib:kafka", "lib:kafka-streams", "lib:kafka-key-generator-client", + "lib:pdl-client", + "lib:aareg-client", "test:test-data-lib", "test:kafka-streams-test-functions", "domain:bekreftelse-interne-hendelser",