-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Oppretter manuell Journalføring-oppgave dersom bruker er null på jour…
…nalpost (#1173) * Dersom bruker er null oppretter vi manuell Journalføring-oppgave med en gang og returnerer * Ktlint * Opprettet AbstractJournalhendelseRutingTask for å håndtere felles logikk for BA og KS * Justeringer etter tilbakemelding
- Loading branch information
1 parent
3df19d5
commit 4951787
Showing
5 changed files
with
166 additions
and
16 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/no/nav/familie/baks/mottak/task/AbstractJournalhendelseRutingTask.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,20 @@ | ||
package no.nav.familie.baks.mottak.task | ||
|
||
import no.nav.familie.prosessering.AsyncTaskStep | ||
import no.nav.familie.prosessering.domene.Task | ||
import no.nav.familie.prosessering.internal.TaskService | ||
|
||
abstract class AbstractJournalhendelseRutingTask( | ||
private val taskService: TaskService, | ||
) : AsyncTaskStep { | ||
fun opprettJournalføringOppgaveTask( | ||
sakssystemMarkering: String, | ||
task: Task, | ||
) { | ||
Task( | ||
type = OpprettJournalføringOppgaveTask.TASK_STEP_TYPE, | ||
payload = sakssystemMarkering, | ||
properties = task.metadata, | ||
).apply { taskService.save(this) } | ||
} | ||
} |
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
83 changes: 83 additions & 0 deletions
83
src/test/kotlin/no/nav/familie/baks/mottak/task/JournalhendelseBarnetrygdRutingTaskTest.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,83 @@ | ||
package no.nav.familie.baks.mottak.task | ||
|
||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.slot | ||
import io.mockk.verify | ||
import no.nav.familie.baks.mottak.config.featureToggle.UnleashNextMedContextService | ||
import no.nav.familie.baks.mottak.integrasjoner.BaSakClient | ||
import no.nav.familie.baks.mottak.integrasjoner.InfotrygdBarnetrygdClient | ||
import no.nav.familie.baks.mottak.integrasjoner.Journalpost | ||
import no.nav.familie.baks.mottak.integrasjoner.JournalpostClient | ||
import no.nav.familie.baks.mottak.integrasjoner.Journalposttype | ||
import no.nav.familie.baks.mottak.integrasjoner.Journalstatus | ||
import no.nav.familie.baks.mottak.integrasjoner.PdlClient | ||
import no.nav.familie.baks.mottak.journalføring.AutomatiskJournalføringBarnetrygdService | ||
import no.nav.familie.baks.mottak.journalføring.JournalpostBrukerService | ||
import no.nav.familie.kontrakter.felles.Tema | ||
import no.nav.familie.prosessering.domene.Task | ||
import no.nav.familie.prosessering.internal.TaskService | ||
import org.junit.jupiter.api.Test | ||
import java.util.Properties | ||
import kotlin.test.assertEquals | ||
|
||
class JournalhendelseBarnetrygdRutingTaskTest { | ||
private val pdlClient: PdlClient = mockk() | ||
private val baSakClient: BaSakClient = mockk() | ||
private val infotrygdBarnetrygdClient: InfotrygdBarnetrygdClient = mockk() | ||
private val taskService: TaskService = mockk() | ||
private val journalpostClient: JournalpostClient = mockk() | ||
private val unleashNextMedContextService: UnleashNextMedContextService = mockk() | ||
private val automatiskJournalføringBarnetrygdService: AutomatiskJournalføringBarnetrygdService = mockk() | ||
private val journalpostBrukerService: JournalpostBrukerService = mockk() | ||
|
||
private val journalhendelseBarnetrygdRutingTask: JournalhendelseBarnetrygdRutingTask = | ||
JournalhendelseBarnetrygdRutingTask( | ||
pdlClient = pdlClient, | ||
baSakClient = baSakClient, | ||
infotrygdBarnetrygdClient = infotrygdBarnetrygdClient, | ||
taskService = taskService, | ||
journalpostClient = journalpostClient, | ||
unleashNextMedContextService = unleashNextMedContextService, | ||
automatiskJournalføringBarnetrygdService = automatiskJournalføringBarnetrygdService, | ||
journalpostBrukerService = journalpostBrukerService, | ||
) | ||
|
||
@Test | ||
fun `doTask - skal opprette journalføring-oppgave dersom bruker er null på journalpost`() { | ||
// Arrange | ||
val journalpostId = "1" | ||
val taskSlot = slot<Task>() | ||
|
||
every { journalpostClient.hentJournalpost(journalpostId) } returns | ||
Journalpost( | ||
journalpostId = journalpostId, | ||
journalposttype = Journalposttype.I, | ||
journalstatus = Journalstatus.MOTTATT, | ||
bruker = null, | ||
) | ||
|
||
every { taskService.save(capture(taskSlot)) } returns mockk() | ||
|
||
// Act | ||
journalhendelseBarnetrygdRutingTask.doTask( | ||
Task( | ||
type = JournalhendelseKontantstøtteRutingTask.TASK_STEP_TYPE, | ||
payload = "SKAN_IM", | ||
properties = | ||
Properties().apply { | ||
this["journalpostId"] = journalpostId | ||
this["fagsakId"] = "123" | ||
this["tema"] = Tema.BAR.name | ||
}, | ||
), | ||
) | ||
|
||
// Assert | ||
val opprettetTask = taskSlot.captured | ||
|
||
verify(exactly = 1) { taskService.save(any()) } | ||
assertEquals(OpprettJournalføringOppgaveTask.TASK_STEP_TYPE, opprettetTask.type) | ||
assertEquals("Ingen bruker er satt på journalpost. Kan ikke utlede om bruker har sak i Infotrygd eller BA-sak.", opprettetTask.payload) | ||
} | ||
} |
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