Skip to content

Commit

Permalink
Remove tss and emottaksubscription code from processing
Browse files Browse the repository at this point in the history
  • Loading branch information
andersrognstad committed Oct 30, 2023
1 parent a416896 commit c73a419
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 74 deletions.
2 changes: 0 additions & 2 deletions src/main/kotlin/no/nav/syfo/Bootstrap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ fun launchListeners(
mqSender = mqSender,
dialogmeldingProducer = dialogmeldingProducer,
azureAdV2Client = azureAdV2Client,
smtssClient = smtssClient,
emottakService = emottakService,
)

val behandlerdialogClient = BehandlerdialogClient(
Expand Down
20 changes: 0 additions & 20 deletions src/main/kotlin/no/nav/syfo/application/DialogmeldingProcessor.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package no.nav.syfo.application

import io.ktor.client.*
import net.logstash.logback.argument.StructuredArguments
import no.nav.helse.dialogmelding.XMLDialogmelding
import no.nav.helse.eiFellesformat2.XMLMottakenhetBlokk
Expand All @@ -10,7 +9,6 @@ import no.nav.syfo.application.mq.MQSenderInterface
import no.nav.syfo.client.*
import no.nav.syfo.client.azuread.v2.AzureAdV2Client
import no.nav.syfo.client.pdl.PdlClient
import no.nav.syfo.client.SmtssClient
import no.nav.syfo.db.DatabaseInterface
import no.nav.syfo.domain.PersonIdent
import no.nav.syfo.handlestatus.*
Expand All @@ -31,8 +29,6 @@ class DialogmeldingProcessor(
val mqSender: MQSenderInterface,
val dialogmeldingProducer: DialogmeldingProducer,
val azureAdV2Client: AzureAdV2Client,
val smtssClient: SmtssClient,
val emottakService: EmottakService,
) {
val pdfgenClient = PdfgenClient(
url = env.syfopdfgen,
Expand Down Expand Up @@ -114,22 +110,6 @@ class DialogmeldingProcessor(
val innbyggerOK = pdlClient.personEksisterer(PersonIdent(receivedDialogmelding.personNrPasient))
val legeOK = pdlClient.personEksisterer(PersonIdent(receivedDialogmelding.personNrLege))

val tssId = smtssClient.findBestTss(
legePersonIdent = PersonIdent(receivedDialogmelding.personNrLege),
legekontorOrgName = receivedDialogmelding.legekontorOrgName,
dialogmeldingId = receivedDialogmelding.msgId,
)

if (tssId != null && tssId.tssid.isNotBlank()) {
emottakService.registerEmottakSubscription(
tssId = tssId,
partnerReferanse = emottakblokk.partnerReferanse,
sender = msgHead.msgInfo.sender,
msgId = msgHead.msgInfo.msgId,
loggingMeta = loggingMeta,
)
}

val navnSignerendeLege = signerendeLegeService.signerendeLegeNavn(
signerendeLegeFnr = receivedDialogmelding.personNrLege,
msgId = msgId,
Expand Down
6 changes: 0 additions & 6 deletions src/test/kotlin/no/nav/syfo/api/VedleggSystemApiSpek.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import no.nav.syfo.application.api.VedleggDTO
import no.nav.syfo.application.api.vedleggSystemApiV1Path
import no.nav.syfo.application.mq.MQSenderInterface
import no.nav.syfo.client.azuread.v2.AzureAdV2Client
import no.nav.syfo.client.SmtssClient
import no.nav.syfo.kafka.DialogmeldingProducer
import no.nav.syfo.services.EmottakService
import no.nav.syfo.util.*
import org.amshove.kluent.shouldBeEqualTo
import org.spekframework.spek2.Spek
Expand All @@ -36,17 +34,13 @@ class VedleggSystemApiSpek : Spek({
val dialogmeldingProducer = mockk<DialogmeldingProducer>(relaxed = true)
val incomingMessage = mockk<TextMessage>(relaxed = true)
val azureAdV2Client = mockk<AzureAdV2Client>(relaxed = true)
val emottakService = mockk<EmottakService>(relaxed = true)
val smtssClient = mockk<SmtssClient>(relaxed = true)

val dialogmeldingProcessor = DialogmeldingProcessor(
database = database,
env = externalMockEnvironment.environment,
mqSender = mqSender,
dialogmeldingProducer = dialogmeldingProducer,
azureAdV2Client = azureAdV2Client,
smtssClient = smtssClient,
emottakService = emottakService,
)

val blockingApplicationRunner = BlockingApplicationRunner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class BlockingApplicationRunnerSpek : Spek({
mqSender = mqSender,
dialogmeldingProducer = dialogmeldingProducer,
azureAdV2Client = azureAdV2Client,
smtssClient = smtssClient,
emottakService = emottakService,
)
val blockingApplicationRunner = BlockingApplicationRunner(
applicationState = externalMockEnvironment.applicationState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,70 +1,51 @@
package no.nav.syfo.dialogmelding
package no.nav.syfo.services

import io.mockk.*
import kotlinx.coroutines.runBlocking
import no.nav.helse.eiFellesformat2.XMLMottakenhetBlokk
import no.nav.syfo.ExternalMockEnvironment
import no.nav.syfo.application.DialogmeldingProcessor
import no.nav.syfo.application.mq.MQSenderInterface
import no.nav.syfo.client.azuread.v2.AzureAdV2Client
import no.nav.syfo.client.SmtssClient
import no.nav.syfo.client.TssId
import no.nav.syfo.client.isbehandlerdialog.BehandlerdialogClient
import no.nav.syfo.domain.PersonIdent
import no.nav.syfo.handlestatus.handleStatusOK
import no.nav.syfo.kafka.DialogmeldingProducer
import no.nav.syfo.persistering.persistRecivedMessageValidation
import no.nav.syfo.services.EmottakService
import no.nav.syfo.model.ReceivedDialogmelding
import no.nav.syfo.util.LoggingMeta
import no.nav.syfo.util.get
import no.nav.syfo.util.getFileAsString
import no.nav.syfo.util.safeUnmarshal
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe

class DialogmeldingProcessorTssSpek : Spek({
class ArenaDialogmeldingServiceSpek : Spek({

val externalMockEnvironment = ExternalMockEnvironment.instance
val database = externalMockEnvironment.database
val dialogmeldingProducer = mockk<DialogmeldingProducer>(relaxed = true)
val mqSender = mockk<MQSenderInterface>(relaxed = true)
val azureAdV2Client = mockk<AzureAdV2Client>(relaxed = true)
val emottakService = mockk<EmottakService>(relaxed = true)
val smtssClient = mockk<SmtssClient>(relaxed = true)
val mqSender = mockk<MQSenderInterface>(relaxed = true)
val behandlerdialogClient = mockk<BehandlerdialogClient>(relaxed = true)

beforeEachTest {
mockkStatic("no.nav.syfo.handlestatus.HandleStatusOKKt")
mockkStatic("no.nav.syfo.persistering.HandleRecivedMessageKt")
coJustRun {
handleStatusOK(
any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any()
)
}
justRun { persistRecivedMessageValidation(any(), any(), any()) }
}

afterEachTest {
unmockkStatic("no.nav.syfo.handlestatus.HandleStatusOKKt")
unmockkStatic("no.nav.syfo.persistering.HandleRecivedMessageKt")
clearMocks(dialogmeldingProducer, mqSender, azureAdV2Client, emottakService, smtssClient)
}

val dialogmeldingProcessor = DialogmeldingProcessor(
database = database,
env = externalMockEnvironment.environment,
val arenaDialogmeldingService = ArenaDialogmeldingService(
mqSender = mqSender,
dialogmeldingProducer = dialogmeldingProducer,
azureAdV2Client = azureAdV2Client,
smtssClient = smtssClient,
emottakService = emottakService,
behandlerdialogClient = behandlerdialogClient
)

describe("Get and handle TSS ident") {
afterEachTest {
clearMocks(mqSender, emottakService, smtssClient)
}

describe("sendArenaDialogmeldingToMQ()") {
val tssId = TssId("123")
val msgId = "37340D30-FE14-42B5-985F-A8FF8FFA0CB5"
val LEGEKONTOR_ORGNAME = "Kule helsetjenester AS"
val legekontorOrgName = "Kule helsetjenester AS"

val dialogmeldingString = getFileAsString("src/test/resources/dialogmelding_dialog_notat.xml")
val fellesformat = safeUnmarshal(dialogmeldingString)
val receivedDialogmelding = ReceivedDialogmelding.create(
dialogmeldingId = msgId,
fellesformat = fellesformat,
inputMessageText = dialogmeldingString,
)

val emottakBlokk = fellesformat.get<XMLMottakenhetBlokk>()
val personNumberDoctor = emottakBlokk.avsenderFnrFraDigSignatur
Expand All @@ -77,10 +58,10 @@ class DialogmeldingProcessorTssSpek : Spek({
coJustRun { emottakService.registerEmottakSubscription(any(), any(), any(), any(), any()) }

runBlocking {
dialogmeldingProcessor.process(msgId, dialogmeldingString)
arenaDialogmeldingService.sendArenaDialogmeldingToMQ(receivedDialogmelding, fellesformat)
}

coVerify(exactly = 1) { smtssClient.findBestTss(legePersonIdent, LEGEKONTOR_ORGNAME, msgId) }
coVerify(exactly = 1) { smtssClient.findBestTss(legePersonIdent, legekontorOrgName, msgId) }
coVerify(exactly = 1) {
emottakService.registerEmottakSubscription(
tssId,
Expand All @@ -96,10 +77,10 @@ class DialogmeldingProcessorTssSpek : Spek({
coEvery { smtssClient.findBestTss(any(), any(), any()) } returns null

runBlocking {
dialogmeldingProcessor.process(msgId, dialogmeldingString)
arenaDialogmeldingService.sendArenaDialogmeldingToMQ(receivedDialogmelding, fellesformat)
}

coVerify(exactly = 1) { smtssClient.findBestTss(legePersonIdent, LEGEKONTOR_ORGNAME, msgId) }
coVerify(exactly = 1) { smtssClient.findBestTss(legePersonIdent, legekontorOrgName, msgId) }
coVerify(exactly = 0) { emottakService.registerEmottakSubscription(any(), any(), any(), any(), any()) }
}

Expand All @@ -108,10 +89,10 @@ class DialogmeldingProcessorTssSpek : Spek({
coEvery { smtssClient.findBestTss(any(), any(), any()) } returns emptyTssId

runBlocking {
dialogmeldingProcessor.process(msgId, dialogmeldingString)
arenaDialogmeldingService.sendArenaDialogmeldingToMQ(receivedDialogmelding, fellesformat)
}

coVerify(exactly = 1) { smtssClient.findBestTss(legePersonIdent, LEGEKONTOR_ORGNAME, msgId) }
coVerify(exactly = 1) { smtssClient.findBestTss(legePersonIdent, legekontorOrgName, msgId) }
coVerify(exactly = 0) { emottakService.registerEmottakSubscription(any(), any(), any(), any(), any()) }
}
}
Expand Down

0 comments on commit c73a419

Please sign in to comment.