Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ikke sende med lenke på inaktive oppgaver #42

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ data class Varsel(
companion object {
fun fromVarsel(varsel: VarselAuthority.Varsel): Varsel {
val isMasked = varsel.innhold == null
val isInaktivertOppgave = varsel.type == VarselType.oppgave && !varsel.aktiv

return Varsel(
eventId = varsel.varselId,
forstBehandlet = varsel.opprettet,
isMasked = isMasked,
spraakkode = varsel.innhold?.spraakkode,
tekst = varsel.innhold?.tekst,
link = varsel.innhold?.link,
link = if(isInaktivertOppgave) null else varsel.innhold?.link,
eksternVarslingSendt = varsel.eksternVarslingSendt,
eksternVarslingKanaler = varsel.eksternVarslingKanaler,
type = if (varsel.type == VarselType.oppgave) VarselType.oppgave else VarselType.beskjed,
Expand Down
27 changes: 27 additions & 0 deletions src/test/kotlin/no/nav/tms/varsel/api/varsel/AlleVarslerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,31 @@ class AlleVarslerTest {
}
}

@Test
fun `Ikke sende med lenke på inaktive oppgaver`() {
val incomingVarselList = listOf(
AlleVarslerTestData.incomingVarsel(type = VarselType.beskjed),
AlleVarslerTestData.incomingVarsel(type = VarselType.innboks),
AlleVarslerTestData.incomingVarsel(type = VarselType.oppgave),
AlleVarslerTestData.incomingVarsel(type = VarselType.oppgave, aktiv = false),
AlleVarslerTestData.incomingVarsel(type = VarselType.beskjed, aktiv = false),
AlleVarslerTestData.incomingVarsel(type = VarselType.innboks, aktiv = false)
)

AlleVarsler.fromVarsler(incomingVarselList).apply {
aktive.oppgaver[0].link shouldBe "www.nav.no/test"
aktive.beskjeder.forEach() {
it.link shouldBe "www.nav.no/test"
}
inaktive.forEach() {
if(it.type == VarselType.oppgave) {
it.link shouldBe null
} else {
it.link shouldBe "www.nav.no/test"
}
}

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object AlleVarslerTestData {
varselId: String = "123143",
aktiv: Boolean = true,
innhold: VarselAuthority.Innhold? = VarselAuthority.Innhold(
link = "test . no",
link = "www.nav.no/test",
spraakkode = "nb",
tekst = "Varsel test tekst"
),
Expand Down
Loading