-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IS-2542: Add support for sending manglende medvirkning varsel (#531)
- Loading branch information
1 parent
0b3e2d8
commit 76b8c26
Showing
7 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/no/nav/syfo/service/ManglendeMedvirkningVarselService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package no.nav.syfo.service | ||
|
||
import no.nav.syfo.consumer.distribuerjournalpost.DistibusjonsType | ||
import no.nav.syfo.kafka.consumers.varselbus.domain.ArbeidstakerHendelse | ||
import no.nav.syfo.utils.dataToVarselData | ||
import org.slf4j.LoggerFactory | ||
|
||
class ManglendeMedvirkningVarselService( | ||
private val senderFacade: SenderFacade, | ||
) { | ||
|
||
suspend fun sendVarselTilArbeidstaker(varselHendelse: ArbeidstakerHendelse) { | ||
val data = dataToVarselData(varselHendelse.data) | ||
requireNotNull(data.journalpost) | ||
requireNotNull(data.journalpost.id) | ||
|
||
log.info("Sending [SM_FORHANDSVARSEL_MANGLENDE_MEDVIRKNING] with uuid ${data.journalpost.uuid} to print") | ||
senderFacade.sendBrevTilFysiskPrint( | ||
uuid = data.journalpost.uuid, | ||
varselHendelse = varselHendelse, | ||
journalpostId = data.journalpost.id, | ||
distribusjonsType = DistibusjonsType.VIKTIG, | ||
) | ||
} | ||
|
||
companion object { | ||
private val log = LoggerFactory.getLogger(ManglendeMedvirkningVarselService::class.qualifiedName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/test/kotlin/no/nav/syfo/service/ManglendeMedvirkningVarselServiceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package no.nav.syfo.service | ||
|
||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.core.spec.style.DescribeSpec | ||
import io.mockk.clearAllMocks | ||
import io.mockk.coVerify | ||
import io.mockk.mockk | ||
import no.nav.syfo.consumer.distribuerjournalpost.DistibusjonsType | ||
import no.nav.syfo.kafka.consumers.varselbus.domain.ArbeidstakerHendelse | ||
import no.nav.syfo.kafka.consumers.varselbus.domain.HendelseType | ||
import no.nav.syfo.kafka.consumers.varselbus.domain.VarselData | ||
import no.nav.syfo.kafka.consumers.varselbus.domain.VarselDataJournalpost | ||
import org.amshove.kluent.shouldBeEqualTo | ||
import java.io.IOException | ||
|
||
class ManglendeMedvirkningVarselServiceTest : DescribeSpec({ | ||
val senderFacade = mockk<SenderFacade>(relaxed = true) | ||
val manglendeMedvirkningVarselService = ManglendeMedvirkningVarselService(senderFacade) | ||
val journalpostId = "620049753" | ||
val journalpostUuid = "bda0b55a-df72-4888-a5a5-6bfa74cacafe" | ||
val hendelse = ArbeidstakerHendelse( | ||
type = HendelseType.SM_FORHANDSVARSEL_MANGLENDE_MEDVIRKNING, | ||
ferdigstill = false, | ||
data = varselData(journalpostId = journalpostId, journalpostUuid = journalpostUuid), | ||
arbeidstakerFnr = SM_FNR, | ||
orgnummer = null, | ||
) | ||
|
||
beforeTest { | ||
clearAllMocks() | ||
} | ||
|
||
describe("Varsel ang. manglende medvirkning") { | ||
it("Sender varsel til fysisk print") { | ||
manglendeMedvirkningVarselService.sendVarselTilArbeidstaker(hendelse) | ||
|
||
coVerify(exactly = 1) { | ||
senderFacade.sendBrevTilFysiskPrint( | ||
journalpostUuid, | ||
hendelse, | ||
journalpostId, | ||
DistibusjonsType.VIKTIG, | ||
) | ||
} | ||
} | ||
|
||
it("Får IOException dersom mangende journalpostid") { | ||
val feilendeHendelse = hendelse.copy( | ||
data = VarselData( | ||
journalpost = VarselDataJournalpost(uuid = "something", id = null) | ||
) | ||
) | ||
|
||
val exception = shouldThrow<IOException> { | ||
manglendeMedvirkningVarselService.sendVarselTilArbeidstaker(feilendeHendelse) | ||
} | ||
|
||
exception.message shouldBeEqualTo "ArbeidstakerHendelse har feil format" | ||
} | ||
} | ||
}) |