Skip to content

Commit

Permalink
Listen to eventType utbetaling_uten_utbetaling
Browse files Browse the repository at this point in the history
  • Loading branch information
AudunSorheim committed Feb 6, 2024
1 parent a343e6f commit 4c8f5c9
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/syfo/db/UtbetalingSpleisDAO.kt
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package no.nav.syfo.kafka.consumers.utbetaling.domain

import java.time.LocalDate

data class UtbetalingUtbetalt(
data class UtbetalingSpleis(
valdselsnummer: String,
val organisasjonsnummer: String? = null,
val event: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/test/kotlin/no/nav/syfo/db/UtbetalingerDAOSpek.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -183,7 +183,7 @@ private fun spleisUtbetaling(
korrelasjonsId = UUID.randomUUID().toString(),
)

private fun List<PUtbetaling>.skalInneholde(spleisUtbetaling: UtbetalingUtbetalt) =
private fun List<PUtbetaling>.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) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,7 +49,7 @@ class TestdataResetServiceSpek : DescribeSpec({
arbeidsgivernotifikasjonMerkelapp = null,
)

val utbetalingUtbetalt = UtbetalingUtbetalt(
val utbetalingUtbetalt = UtbetalingSpleis(
arbeidstakerFnr1,
orgnummer,
"utbetaling",
Expand Down

0 comments on commit 4c8f5c9

Please sign in to comment.