Skip to content

Commit

Permalink
IS-1736: Svar moteinnkalling ikke til Arena (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
geir-waagboe authored Oct 30, 2023
1 parent dbb2760 commit b8bb3f1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ class SendDialogmeldingArenaCronjob(
val unpublishedArenaMeldinger = database.getUnpublishedArenaMeldinger()
unpublishedArenaMeldinger.forEach { (dialogmeldingId, fellesformat, msgId) ->
try {
val sendToArena = !arenaDialogmeldingService.isMeldingStoredInBehandlerdialog(msgId)
val fellesformatXml = safeUnmarshal(fellesformat)
val receivedDialogmelding = ReceivedDialogmelding.create(
dialogmeldingId = dialogmeldingId,
fellesformat = fellesformatXml,
inputMessageText = fellesformat,
)
val sendToArena = !arenaDialogmeldingService.isMeldingStoredInBehandlerdialog(msgId) &&
receivedDialogmelding.dialogmelding.innkallingMoterespons == null
if (sendToArena) {
val fellesformatXml = safeUnmarshal(fellesformat)
val receivedDialogmelding = ReceivedDialogmelding.create(
dialogmeldingId = dialogmeldingId,
fellesformat = fellesformatXml,
inputMessageText = fellesformat,
)
arenaDialogmeldingService.sendArenaDialogmeldingToMQ(
receivedDialogmelding = receivedDialogmelding,
fellesformatXml = fellesformatXml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,31 @@ class SendDialogmeldingArenaCronjobSpek : Spek({
}
verify(exactly = 0) { mqSender.sendArena(any()) }
}
it("Does not send when melding is svar på dialogmøteinnkalling") {
val fellesformatMeldingSvarMoteinnkalling =
getFileAsString("src/test/resources/dialogmelding_dialog_svar_innkalling_dialogmote.xml")
val fellesformatXmlMeldingInBehandlerdialog = safeUnmarshal(fellesformatMeldingSvarMoteinnkalling)
val receivedDialogmeldingInBehandlerdialog = ReceivedDialogmelding.create(
dialogmeldingId = UUID.randomUUID().toString(),
fellesformat = fellesformatXmlMeldingInBehandlerdialog,
inputMessageText = fellesformatMeldingSvarMoteinnkalling,
)
val dialogmeldingId = createDialogmeldingOpplysning(receivedDialogmeldingInBehandlerdialog)
database.lagreSendtKafka(dialogmeldingId)
database.lagreSendtApprec(dialogmeldingId)
database.updateSendtApprec(
dialogmeldingId = dialogmeldingId,
timestamp = Timestamp.valueOf(LocalDateTime.now().minusMinutes(11)),
)

runBlocking {
val result = sendDialogmeldingArenaCronjob.runJob()

result.updated shouldBeEqualTo 1
result.failed shouldBeEqualTo 0
}
verify(exactly = 0) { mqSender.sendArena(any()) }
}

it("Does not process dialogmelding when already checked whether it should be sent to arena") {
val fellesformatMeldingInBehandlerdialog =
Expand Down

0 comments on commit b8bb3f1

Please sign in to comment.