From 4c8f5c9b6a3787f28dbd3bc8e417efb940c9efca Mon Sep 17 00:00:00 2001 From: AudunSorheim Date: Tue, 6 Feb 2024 15:18:42 +0100 Subject: [PATCH] Listen to eventType utbetaling_uten_utbetaling --- src/main/kotlin/no/nav/syfo/db/UtbetalingSpleisDAO.kt | 4 ++-- .../kafka/consumers/utbetaling/UtbetalingKafkaConsumer.kt | 6 +++--- .../domain/{UtbetalingUtbetalt.kt => UtbetalingSpleis.kt} | 2 +- .../no/nav/syfo/service/SykepengerMaxDateService.kt | 2 +- src/test/kotlin/no/nav/syfo/db/UtbetalingerDAOSpek.kt | 6 +++--- .../no/nav/syfo/service/MerVeiledningVarselFinderSpek.kt | 6 +++--- .../no/nav/syfo/service/SykepengerMaxDateServiceSpek.kt | 8 +++----- .../no/nav/syfo/service/TestdataResetServiceSpek.kt | 4 ++-- 8 files changed, 18 insertions(+), 20 deletions(-) rename src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/domain/{UtbetalingUtbetalt.kt => UtbetalingSpleis.kt} (94%) diff --git a/src/main/kotlin/no/nav/syfo/db/UtbetalingSpleisDAO.kt b/src/main/kotlin/no/nav/syfo/db/UtbetalingSpleisDAO.kt index 28988f285..25194d0d0 100644 --- a/src/main/kotlin/no/nav/syfo/db/UtbetalingSpleisDAO.kt +++ b/src/main/kotlin/no/nav/syfo/db/UtbetalingSpleisDAO.kt @@ -1,14 +1,14 @@ package no.nav.syfo.db import no.nav.syfo.domain.PersonIdent -import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingUtbetalt +import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingSpleis import org.postgresql.util.PSQLException import java.sql.Date import java.sql.Timestamp import java.time.LocalDateTime import java.util.* -fun DatabaseInterface.storeSpleisUtbetaling(utbetaling: UtbetalingUtbetalt) { +fun DatabaseInterface.storeSpleisUtbetaling(utbetaling: UtbetalingSpleis) { val insertStatement = """INSERT INTO UTBETALING_SPLEIS ( ID, FNR, diff --git a/src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/UtbetalingKafkaConsumer.kt b/src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/UtbetalingKafkaConsumer.kt index a44b108fd..4017b6257 100644 --- a/src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/UtbetalingKafkaConsumer.kt +++ b/src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/UtbetalingKafkaConsumer.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.module.kotlin.readValue import no.nav.syfo.ApplicationState import no.nav.syfo.Environment import no.nav.syfo.kafka.common.* -import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingUtbetalt +import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingSpleis import no.nav.syfo.service.SykepengerMaxDateService import org.apache.kafka.clients.CommonClientConfigs.GROUP_ID_CONFIG import org.apache.kafka.clients.consumer.KafkaConsumer @@ -33,8 +33,8 @@ class UtbetalingKafkaConsumer( kafkaListener.poll(pollDurationInMillis).forEach { log.info("Received record from topic $topicUtbetaling") try { - val utbetaling: UtbetalingUtbetalt = objectMapper.readValue(it.value()) - if (utbetaling.event == "utbetaling_utbetalt") { + val utbetaling: UtbetalingSpleis = objectMapper.readValue(it.value()) + if (utbetaling.event == "utbetaling_utbetalt" || utbetaling.event == "utbetaling_uten_utbetaling") { sykepengerMaxDateService.processUtbetalingSpleisEvent(utbetaling) } } catch (e: IOException) { diff --git a/src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/domain/UtbetalingUtbetalt.kt b/src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/domain/UtbetalingSpleis.kt similarity index 94% rename from src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/domain/UtbetalingUtbetalt.kt rename to src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/domain/UtbetalingSpleis.kt index 0c9441815..80633eaa4 100644 --- a/src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/domain/UtbetalingUtbetalt.kt +++ b/src/main/kotlin/no/nav/syfo/kafka/consumers/utbetaling/domain/UtbetalingSpleis.kt @@ -2,7 +2,7 @@ package no.nav.syfo.kafka.consumers.utbetaling.domain import java.time.LocalDate -data class UtbetalingUtbetalt( +data class UtbetalingSpleis( val fødselsnummer: String, val organisasjonsnummer: String? = null, val event: String, diff --git a/src/main/kotlin/no/nav/syfo/service/SykepengerMaxDateService.kt b/src/main/kotlin/no/nav/syfo/service/SykepengerMaxDateService.kt index 0aa5824c4..678891c95 100644 --- a/src/main/kotlin/no/nav/syfo/service/SykepengerMaxDateService.kt +++ b/src/main/kotlin/no/nav/syfo/service/SykepengerMaxDateService.kt @@ -9,7 +9,7 @@ import no.nav.syfo.kafka.consumers.utbetaling.domain.* class SykepengerMaxDateService(private val databaseInterface: DatabaseInterface, private val pdlConsumer: PdlConsumer) { - suspend fun processUtbetalingSpleisEvent(utbetaling: UtbetalingUtbetalt) { + suspend fun processUtbetalingSpleisEvent(utbetaling: UtbetalingSpleis) { val fnr = utbetaling.fødselsnummer processFodselsdato(fnr) databaseInterface.storeSpleisUtbetaling(utbetaling) diff --git a/src/test/kotlin/no/nav/syfo/db/UtbetalingerDAOSpek.kt b/src/test/kotlin/no/nav/syfo/db/UtbetalingerDAOSpek.kt index 5a3454815..1ed1422b0 100644 --- a/src/test/kotlin/no/nav/syfo/db/UtbetalingerDAOSpek.kt +++ b/src/test/kotlin/no/nav/syfo/db/UtbetalingerDAOSpek.kt @@ -3,7 +3,7 @@ package no.nav.syfo.db import io.kotest.core.spec.style.DescribeSpec import no.nav.syfo.db.domain.PUtbetaling import no.nav.syfo.kafka.consumers.infotrygd.domain.InfotrygdSource.AAP_KAFKA_TOPIC -import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingUtbetalt +import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingSpleis import no.nav.syfo.testutil.EmbeddedDatabase import no.nav.syfo.testutil.dropData import org.amshove.kluent.should @@ -167,7 +167,7 @@ private fun spleisUtbetaling( tom: LocalDate = now().minusDays(1), forelopigBeregnetSluttPaSykepenger: LocalDate = now().plusDays(14), gjenstaendeSykedager: Int = 90 -) = UtbetalingUtbetalt( +) = UtbetalingSpleis( fødselsnummer = fnr, organisasjonsnummer = "234", event = "ubetaling_utbetalt", @@ -183,7 +183,7 @@ private fun spleisUtbetaling( korrelasjonsId = UUID.randomUUID().toString(), ) -private fun List.skalInneholde(spleisUtbetaling: UtbetalingUtbetalt) = +private fun List.skalInneholde(spleisUtbetaling: UtbetalingSpleis) = this.shouldMatchAtLeastOneOf { pUtbetaling: PUtbetaling -> pUtbetaling.fnr == spleisUtbetaling.fødselsnummer && pUtbetaling.utbetaltTom == spleisUtbetaling.tom && pUtbetaling.forelopigBeregnetSlutt == spleisUtbetaling.foreløpigBeregnetSluttPåSykepenger && pUtbetaling.gjenstaendeSykedager == spleisUtbetaling.gjenståendeSykedager } private fun DatabaseInterface.shouldContainForelopigBeregnetSlutt(fnr: String, forelopigBeregnetSlutt: LocalDate) = diff --git a/src/test/kotlin/no/nav/syfo/service/MerVeiledningVarselFinderSpek.kt b/src/test/kotlin/no/nav/syfo/service/MerVeiledningVarselFinderSpek.kt index 2b6aba5db..19780d79a 100644 --- a/src/test/kotlin/no/nav/syfo/service/MerVeiledningVarselFinderSpek.kt +++ b/src/test/kotlin/no/nav/syfo/service/MerVeiledningVarselFinderSpek.kt @@ -12,7 +12,7 @@ import no.nav.syfo.db.domain.PUtsendtVarsel import no.nav.syfo.db.storeFodselsdato import no.nav.syfo.db.storeSpleisUtbetaling import no.nav.syfo.db.storeUtsendtVarsel -import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingUtbetalt +import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingSpleis import no.nav.syfo.kafka.consumers.varselbus.domain.HendelseType import no.nav.syfo.planner.arbeidstakerFnr1 import no.nav.syfo.testutil.EmbeddedDatabase @@ -32,7 +32,7 @@ class MerVeiledningVarselFinderSpek : DescribeSpec({ val merVeiledningVarselFinder = MerVeiledningVarselFinder(embeddedDatabase, sykmeldingServiceMockk, pdlConsumerMockk) - val spleisUtbetalingWhichResultsToVarsel = UtbetalingUtbetalt( + val spleisUtbetalingWhichResultsToVarsel = UtbetalingSpleis( fødselsnummer = arbeidstakerFnr1, organisasjonsnummer = "234", event = "ubetaling_utbetalt", @@ -47,7 +47,7 @@ class MerVeiledningVarselFinderSpek : DescribeSpec({ utbetalingId = UUID.randomUUID().toString(), korrelasjonsId = UUID.randomUUID().toString(), ) - val spleisUtbetalingWhichResultsToVarsel2 = UtbetalingUtbetalt( + val spleisUtbetalingWhichResultsToVarsel2 = UtbetalingSpleis( fødselsnummer = arbeidstakerFnr2, organisasjonsnummer = "234", event = "ubetaling_utbetalt", diff --git a/src/test/kotlin/no/nav/syfo/service/SykepengerMaxDateServiceSpek.kt b/src/test/kotlin/no/nav/syfo/service/SykepengerMaxDateServiceSpek.kt index ea448b14d..eb4edd48e 100644 --- a/src/test/kotlin/no/nav/syfo/service/SykepengerMaxDateServiceSpek.kt +++ b/src/test/kotlin/no/nav/syfo/service/SykepengerMaxDateServiceSpek.kt @@ -7,9 +7,7 @@ import no.nav.syfo.consumer.pdl.PdlConsumer import no.nav.syfo.consumer.pdl.PdlFoedsel import no.nav.syfo.consumer.pdl.PdlHentPerson import no.nav.syfo.consumer.pdl.PdlPerson -import no.nav.syfo.db.DatabaseInterface -import no.nav.syfo.db.toList -import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingUtbetalt +import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingSpleis import no.nav.syfo.testutil.EmbeddedDatabase import no.nav.syfo.testutil.dropData import java.time.LocalDate @@ -37,7 +35,7 @@ class SykepengerMaxDateServiceSpek : DescribeSpec({ } it("Should store spleis utbetaling") { - val utbetalingUtbetalt = UtbetalingUtbetalt( + val utbetalingUtbetalt = UtbetalingSpleis( fødselsnummer = "123", organisasjonsnummer = "234", event = "ubetaling_utbetalt", @@ -61,7 +59,7 @@ class SykepengerMaxDateServiceSpek : DescribeSpec({ } it("Should ignore duplicate spleis utbetaling") { - val utbetalingUtbetalt = UtbetalingUtbetalt( + val utbetalingUtbetalt = UtbetalingSpleis( fødselsnummer = "123", organisasjonsnummer = "234", event = "ubetaling_utbetalt", diff --git a/src/test/kotlin/no/nav/syfo/service/TestdataResetServiceSpek.kt b/src/test/kotlin/no/nav/syfo/service/TestdataResetServiceSpek.kt index c0272a6d2..3e873492b 100644 --- a/src/test/kotlin/no/nav/syfo/service/TestdataResetServiceSpek.kt +++ b/src/test/kotlin/no/nav/syfo/service/TestdataResetServiceSpek.kt @@ -8,7 +8,7 @@ import no.nav.syfo.db.* import no.nav.syfo.db.domain.* import no.nav.syfo.domain.PersonIdent import no.nav.syfo.kafka.consumers.infotrygd.domain.InfotrygdSource -import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingUtbetalt +import no.nav.syfo.kafka.consumers.utbetaling.domain.UtbetalingSpleis import no.nav.syfo.kafka.consumers.varselbus.domain.HendelseType import no.nav.syfo.kafka.producers.mineside_microfrontend.MikrofrontendSynlighet import no.nav.syfo.kafka.producers.mineside_microfrontend.Tjeneste @@ -49,7 +49,7 @@ class TestdataResetServiceSpek : DescribeSpec({ arbeidsgivernotifikasjonMerkelapp = null, ) - val utbetalingUtbetalt = UtbetalingUtbetalt( + val utbetalingUtbetalt = UtbetalingSpleis( arbeidstakerFnr1, orgnummer, "utbetaling",