Skip to content

Commit

Permalink
Add motetidspunkt field for dialogmotevarsel (#561)
Browse files Browse the repository at this point in the history
* Add motetidspunkt field for dialogmotevarsel

* Fix datetime in tests

---------

Co-authored-by: Anders Rognstad <[email protected]>
  • Loading branch information
luantr and andersrognstad authored Jan 13, 2025
1 parent b4a2e68 commit 5d614e7
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ package no.nav.syfo.brev.narmesteleder
import no.nav.syfo.brev.esyfovarsel.*
import no.nav.syfo.client.narmesteleder.*
import no.nav.syfo.dialogmote.domain.*
import java.time.LocalDateTime

class NarmesteLederVarselService(
private val esyfovarselProducer: EsyfovarselProducer,
) {
fun sendVarsel(
narmesteLeder: NarmesteLederRelasjonDTO,
varseltype: MotedeltakerVarselType
varseltype: MotedeltakerVarselType,
motetidspunkt: LocalDateTime?,
) {
val hendelse = NarmesteLederHendelse(
type = getNaermesteLederVarselType(varseltype),
data = VarselData(
narmesteLeder = VarselDataNarmesteLeder(narmesteLeder.narmesteLederNavn)
narmesteLeder = VarselDataNarmesteLeder(narmesteLeder.narmesteLederNavn),
motetidspunkt = motetidspunkt?.let { VarselDataMotetidspunkt(it) }
),
narmesteLederFnr = narmesteLeder.narmesteLederPersonIdentNumber,
arbeidstakerFnr = narmesteLeder.arbeidstakerPersonIdentNumber,
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/no/nav/syfo/dialogmote/VarselService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class VarselService(
narmesteLederVarselService.sendVarsel(
narmesteLeder = narmesteLeder,
varseltype = varselType,
motetidspunkt = motetidspunkt
)
}
if (isDigitalVarselEnabledForArbeidstaker) {
Expand Down
12 changes: 7 additions & 5 deletions src/test/kotlin/no/nav/syfo/dialogmote/VarselServiceSpek.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import no.nav.syfo.dialogmote.domain.MotedeltakerVarselType
import no.nav.syfo.testhelper.UserConstants
import no.nav.syfo.testhelper.UserConstants.VIRKSOMHETSNUMMER_HAS_NARMESTELEDER
import no.nav.syfo.testhelper.UserConstants.VIRKSOMHETSNUMMER_NO_NARMESTELEDER
import no.nav.syfo.testhelper.generator.DIALOGMOTE_TIDSPUNKT_FIXTURE
import no.nav.syfo.testhelper.mock.narmesteLeder
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
Expand Down Expand Up @@ -54,7 +55,7 @@ object VarselServiceSpek : Spek({
clearMocks(oppfolgingstilfelleClient)

justRun { arbeidstakerVarselService.sendVarsel(any(), any(), any(), any(), any()) }
justRun { narmesteLederVarselService.sendVarsel(any(), any()) }
justRun { narmesteLederVarselService.sendVarsel(any(), any(), any()) }
justRun { behandlerVarselService.sendVarsel(any(), any(), any(), any(), any(), any(), any(), any()) }
justRun { altinnClient.sendToVirksomhet(any()) }
}
Expand Down Expand Up @@ -104,7 +105,8 @@ object VarselServiceSpek : Spek({
verify(exactly = 1) {
narmesteLederVarselService.sendVarsel(
narmesteLeder,
MotedeltakerVarselType.INNKALT
MotedeltakerVarselType.INNKALT,
DIALOGMOTE_TIDSPUNKT_FIXTURE
)
}
}
Expand Down Expand Up @@ -156,7 +158,7 @@ object VarselServiceSpek : Spek({
altinnMelding
)
}
verify(exactly = 0) { narmesteLederVarselService.sendVarsel(any(), any()) }
verify(exactly = 0) { narmesteLederVarselService.sendVarsel(any(), any(), DIALOGMOTE_TIDSPUNKT_FIXTURE) }
}
}

Expand Down Expand Up @@ -206,7 +208,7 @@ object VarselServiceSpek : Spek({
altinnMelding
)
}
verify(exactly = 0) { narmesteLederVarselService.sendVarsel(any(), any()) }
verify(exactly = 0) { narmesteLederVarselService.sendVarsel(any(), any(), any()) }
}
}

Expand Down Expand Up @@ -253,7 +255,7 @@ object VarselServiceSpek : Spek({
altinnMelding
)
}
verify(exactly = 0) { narmesteLederVarselService.sendVarsel(any(), any()) }
verify(exactly = 0) { narmesteLederVarselService.sendVarsel(any(), any(), any()) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import io.ktor.server.testing.handleRequest
import io.ktor.server.testing.setBody
import io.mockk.*
import java.time.LocalDate
import java.time.LocalDateTime
import no.altinn.schemas.services.intermediary.receipt._2009._10.ReceiptExternal
import no.altinn.schemas.services.intermediary.receipt._2009._10.ReceiptStatusEnum
import no.altinn.services.serviceengine.correspondence._2009._10.ICorrespondenceAgencyExternalBasic
Expand All @@ -26,6 +25,7 @@ import no.nav.syfo.testhelper.*
import no.nav.syfo.testhelper.UserConstants.ARBEIDSTAKER_IKKE_VARSEL
import no.nav.syfo.testhelper.UserConstants.ENHET_NR
import no.nav.syfo.testhelper.UserConstants.VEILEDER_IDENT
import no.nav.syfo.testhelper.generator.DIALOGMOTE_TIDSPUNKT_FIXTURE
import no.nav.syfo.testhelper.generator.generateInkallingHendelse
import no.nav.syfo.testhelper.generator.generateNewDialogmoteDTO
import no.nav.syfo.testhelper.generator.generateNewDialogmoteDTOWithMissingValues
Expand Down Expand Up @@ -95,7 +95,7 @@ class PostDialogmoteApiV2AllowVarselMedFysiskBrevSpek : Spek({
val urlMoter = "$dialogmoteApiV2Basepath$dialogmoteApiPersonIdentUrlPath"

it("should return OK if request is successful even if ikke-varsle") {
val moteTidspunkt = LocalDateTime.now().plusDays(30)
val moteTidspunkt = DIALOGMOTE_TIDSPUNKT_FIXTURE
val newDialogmoteDTO = generateNewDialogmoteDTO(
personIdent = ARBEIDSTAKER_IKKE_VARSEL,
dato = moteTidspunkt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import io.ktor.server.testing.handleRequest
import io.ktor.server.testing.setBody
import io.mockk.*
import java.time.LocalDate
import java.time.LocalDateTime
import no.altinn.schemas.services.intermediary.receipt._2009._10.ReceiptExternal
import no.altinn.schemas.services.intermediary.receipt._2009._10.ReceiptStatusEnum
import no.altinn.services.serviceengine.correspondence._2009._10.ICorrespondenceAgencyExternalBasic
Expand All @@ -35,6 +34,7 @@ import no.nav.syfo.testhelper.UserConstants.ENHET_NR
import no.nav.syfo.testhelper.UserConstants.VEILEDER_IDENT
import no.nav.syfo.testhelper.dropData
import no.nav.syfo.testhelper.generateJWTNavIdent
import no.nav.syfo.testhelper.generator.DIALOGMOTE_TIDSPUNKT_FIXTURE
import no.nav.syfo.testhelper.generator.generateInkallingHendelse
import no.nav.syfo.testhelper.generator.generateNewDialogmoteDTO
import no.nav.syfo.testhelper.generator.generateNewDialogmoteDTOWithBehandler
Expand Down Expand Up @@ -118,7 +118,7 @@ class PostDialogmoteApiV2Spek : Spek({
val urlMoter = "$dialogmoteApiV2Basepath$dialogmoteApiPersonIdentUrlPath"

it("should return OK if request is successful") {
val moteTidspunkt = LocalDateTime.now().plusDays(30)
val moteTidspunkt = DIALOGMOTE_TIDSPUNKT_FIXTURE
val newDialogmoteDTO = generateNewDialogmoteDTO(
personIdent = ARBEIDSTAKER_FNR,
dato = moteTidspunkt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import no.altinn.services.serviceengine.correspondence._2009._10.ICorrespondence
import no.nav.syfo.brev.behandler.BehandlerVarselService
import no.nav.syfo.brev.behandler.kafka.BehandlerDialogmeldingProducer
import no.nav.syfo.brev.behandler.kafka.KafkaBehandlerDialogmeldingDTO
import no.nav.syfo.brev.esyfovarsel.EsyfovarselProducer
import no.nav.syfo.brev.esyfovarsel.HendelseType
import no.nav.syfo.brev.esyfovarsel.*
import no.nav.syfo.client.oppfolgingstilfelle.toLatestOppfolgingstilfelle
import no.nav.syfo.dialogmelding.DialogmeldingService
import no.nav.syfo.dialogmelding.domain.ForesporselType
Expand Down Expand Up @@ -273,9 +272,10 @@ class PostDialogmoteTidStedApiV2Spek : Spek({
}
val urlMoteUUIDPostTidSted =
"$dialogmoteApiV2Basepath/$createdDialogmoteUUID$dialogmoteApiMoteTidStedPath"
val newDialogmoteTid = newDialogmoteDTO.tidSted.tid.plusDays(1)
val newDialogmoteTidSted = EndreTidStedDialogmoteDTO(
sted = "Et annet sted",
tid = newDialogmoteDTO.tidSted.tid.plusDays(1),
tid = newDialogmoteTid,
videoLink = "https://meet.google.com/zyx",
arbeidstaker = EndreTidStedBegrunnelseDTO(
begrunnelse = "begrunnelse arbeidstaker",
Expand Down Expand Up @@ -391,7 +391,16 @@ class PostDialogmoteTidStedApiV2Spek : Spek({
) {
response.status() shouldBeEqualTo HttpStatusCode.OK
esyfovarselEndringHendelse.type = HendelseType.NL_DIALOGMOTE_NYTT_TID_STED
verify(exactly = 1) { esyfovarselProducerMock.sendVarselToEsyfovarsel(esyfovarselEndringHendelse) }
verify(exactly = 1) {
esyfovarselProducerMock.sendVarselToEsyfovarsel(
esyfovarselEndringHendelse.copy(
data = VarselData(
narmesteLeder = VarselDataNarmesteLeder("narmesteLederNavn"),
motetidspunkt = VarselDataMotetidspunkt(newDialogmoteTid)
),
)
)
}
}

with(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ fun generateNewDialogmoteTidStedDTO(

fun generateNewDialogmoteTidStedDTONoVideoLink() = NewDialogmoteTidStedDTO(
sted = "This is a very lang text that has a lot of characters and describes where the meeting will take place.",
tid = LocalDateTime.now().plusDays(30),
tid = DIALOGMOTE_TIDSPUNKT_FIXTURE,
videoLink = null
)

fun generateEndreDialogmoteTidStedDTO(
tid: LocalDateTime = LocalDateTime.now().plusDays(30),
tid: LocalDateTime = DIALOGMOTE_TIDSPUNKT_FIXTURE,
) = EndreTidStedDialogmoteDTO(
sted = "This is a very lang text that has a lot of characters and describes where the meeting will take place.",
tid = tid,
Expand All @@ -65,7 +65,7 @@ fun generateEndreDialogmoteTidStedDTO(

fun generateEndreDialogmoteTidStedDTOWithBehandler() = EndreTidStedDialogmoteDTO(
sted = "This is a very lang text that has a lot of characters and describes where the meeting will take place.",
tid = LocalDateTime.now().plusDays(30),
tid = DIALOGMOTE_TIDSPUNKT_FIXTURE,
videoLink = "https://meet.google.com/xyz",
arbeidstaker = EndreTidStedBegrunnelseDTO(
begrunnelse = "",
Expand Down Expand Up @@ -153,7 +153,7 @@ fun generateMotedeltakerArbeidsgiverDTOMissingValues() = NewDialogmotedeltakerAr
fun generateNewDialogmoteDTO(
personIdent: PersonIdent,
sted: String = "This is a very lang text that has a lot of characters and describes where the meeting will take place.",
dato: LocalDateTime = LocalDateTime.now().plusDays(30),
dato: LocalDateTime = DIALOGMOTE_TIDSPUNKT_FIXTURE,
virksomhetsnummer: String = VIRKSOMHETSNUMMER_HAS_NARMESTELEDER.value,
): NewDialogmoteDTO {
return NewDialogmoteDTO(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import no.nav.syfo.domain.PersonIdent
import no.nav.syfo.testhelper.UserConstants
import no.nav.syfo.testhelper.UserConstants.VIRKSOMHETSNUMMER_HAS_NARMESTELEDER
import java.time.LocalDateTime
import java.time.temporal.ChronoUnit
import java.util.*

val DIALOGMOTE_TIDSPUNKT_FIXTURE = LocalDateTime.now().plusDays(30L).truncatedTo(ChronoUnit.MILLIS)

fun generateNewDialogmoteTidSted() = NewDialogmoteTidSted(
sted = "This is a very lang text that has a lot of characters and describes where the meeting will take place.",
tid = LocalDateTime.now().plusDays(30),
tid = DIALOGMOTE_TIDSPUNKT_FIXTURE,
videoLink = "https://meet.google.com/xyz"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ fun generateAvlysningHendelse() =
NarmesteLederHendelse(
type = HendelseType.NL_DIALOGMOTE_AVLYST,
data = VarselData(
narmesteLeder = VarselDataNarmesteLeder("narmesteLederNavn")
narmesteLeder = VarselDataNarmesteLeder("narmesteLederNavn"),
motetidspunkt = VarselDataMotetidspunkt(DIALOGMOTE_TIDSPUNKT_FIXTURE)
),
narmesteLederFnr = NARMESTELEDER_FNR.value,
arbeidstakerFnr = ARBEIDSTAKER_FNR.value,
Expand All @@ -22,7 +23,8 @@ fun generateInkallingHendelse() =
type = HendelseType.NL_DIALOGMOTE_INNKALT,
narmesteLederFnr = NARMESTELEDER_FNR.value,
data = VarselData(
narmesteLeder = VarselDataNarmesteLeder("narmesteLederNavn")
narmesteLeder = VarselDataNarmesteLeder("narmesteLederNavn"),
motetidspunkt = VarselDataMotetidspunkt(DIALOGMOTE_TIDSPUNKT_FIXTURE)
),
arbeidstakerFnr = ARBEIDSTAKER_FNR.value,
orgnummer = VIRKSOMHETSNUMMER_HAS_NARMESTELEDER.value
Expand All @@ -33,7 +35,8 @@ fun generateEndringHendelse() =
type = HendelseType.NL_DIALOGMOTE_NYTT_TID_STED,
narmesteLederFnr = NARMESTELEDER_FNR.value,
data = VarselData(
narmesteLeder = VarselDataNarmesteLeder("narmesteLederNavn")
narmesteLeder = VarselDataNarmesteLeder("narmesteLederNavn"),
motetidspunkt = VarselDataMotetidspunkt(DIALOGMOTE_TIDSPUNKT_FIXTURE)
),
arbeidstakerFnr = ARBEIDSTAKER_FNR.value,
orgnummer = VIRKSOMHETSNUMMER_HAS_NARMESTELEDER.value
Expand All @@ -44,7 +47,8 @@ fun generateInkallingHendelseOtherVirksomhet() =
type = HendelseType.NL_DIALOGMOTE_INNKALT,
narmesteLederFnr = NARMESTELEDER_FNR.value,
data = VarselData(
narmesteLeder = VarselDataNarmesteLeder("narmesteLederNavn")
narmesteLeder = VarselDataNarmesteLeder("narmesteLederNavn"),
motetidspunkt = VarselDataMotetidspunkt(DIALOGMOTE_TIDSPUNKT_FIXTURE)
),
arbeidstakerFnr = ARBEIDSTAKER_FNR.value,
orgnummer = OTHER_VIRKSOMHETSNUMMER_HAS_NARMESTELEDER.value
Expand Down

0 comments on commit 5d614e7

Please sign in to comment.