diff --git a/src/test/kotlin/no/nav/syfo/api/JobApiSpek.kt b/src/test/kotlin/no/nav/syfo/api/JobApiSpek.kt index 02233c220..cf2701cf1 100644 --- a/src/test/kotlin/no/nav/syfo/api/JobApiSpek.kt +++ b/src/test/kotlin/no/nav/syfo/api/JobApiSpek.kt @@ -1,11 +1,13 @@ package no.nav.syfo.api import io.kotest.core.spec.style.DescribeSpec -import io.ktor.http.* -import io.ktor.server.application.* -import io.ktor.server.plugins.contentnegotiation.* -import io.ktor.server.routing.* -import io.ktor.server.testing.* +import io.ktor.http.HttpMethod +import io.ktor.http.isSuccess +import io.ktor.server.application.install +import io.ktor.server.plugins.contentnegotiation.ContentNegotiation +import io.ktor.server.routing.routing +import io.ktor.server.testing.TestApplicationEngine +import io.ktor.server.testing.handleRequest import io.mockk.coEvery import io.mockk.coVerify import io.mockk.justRun @@ -14,13 +16,22 @@ import no.nav.syfo.api.job.registerJobTriggerApi import no.nav.syfo.api.job.urlPathJobTrigger import no.nav.syfo.db.domain.PPlanlagtVarsel import no.nav.syfo.db.domain.VarselType -import no.nav.syfo.getTestEnv import no.nav.syfo.job.VarselSender -import no.nav.syfo.kafka.producers.brukernotifikasjoner.BrukernotifikasjonKafkaProducer -import no.nav.syfo.service.* +import no.nav.syfo.service.AccessControlService +import no.nav.syfo.service.MerVeiledningVarselFinder +import no.nav.syfo.service.MerVeiledningVarselService import no.nav.syfo.service.microfrontend.MikrofrontendService -import no.nav.syfo.testutil.EmbeddedDatabase -import no.nav.syfo.testutil.mocks.* +import no.nav.syfo.testutil.mocks.fnr1 +import no.nav.syfo.testutil.mocks.fnr2 +import no.nav.syfo.testutil.mocks.fnr3 +import no.nav.syfo.testutil.mocks.fnr4 +import no.nav.syfo.testutil.mocks.fnr5 +import no.nav.syfo.testutil.mocks.orgnummer +import no.nav.syfo.testutil.mocks.userAccessStatus1 +import no.nav.syfo.testutil.mocks.userAccessStatus2 +import no.nav.syfo.testutil.mocks.userAccessStatus3 +import no.nav.syfo.testutil.mocks.userAccessStatus4 +import no.nav.syfo.testutil.mocks.userAccessStatus5 import no.nav.syfo.util.contentNegotationFeature import org.amshove.kluent.shouldBeEqualTo import java.time.LocalDate @@ -28,18 +39,13 @@ import java.time.LocalDateTime import java.util.* class JobApiSpek : DescribeSpec({ - val testEnv = getTestEnv() timeout = 20000L describe("JobTriggerApi test") { - val embeddedDatabase by lazy { EmbeddedDatabase() } val accessControlService = mockk() - val brukernotifikasjonKafkaProducer = mockk() val merVeiledningVarselFinder = mockk(relaxed = true) - val dokarkivService = mockk() val merVeiledningVarselService = mockk() - val sykmeldingService = mockk() val mikrofrontendService = mockk() coEvery { accessControlService.getUserAccessStatus(fnr1) } returns userAccessStatus1 @@ -100,32 +106,13 @@ class JobApiSpek : DescribeSpec({ LocalDateTime.now(), ), ) - coEvery { - sykmeldingService.checkSykmeldingStatusForVirksomhet( - any(), - any(), - any(), - ) - } returns SykmeldingStatus(isSykmeldtIJobb = false, sendtArbeidsgiver = true) - coEvery { brukernotifikasjonKafkaProducer.sendBeskjed(any(), any(), any(), any(), any()) } returns Unit - coEvery { dokarkivService.getJournalpostId(any(), any(), any()) } returns "1" - coEvery { sykmeldingService.isPersonSykmeldtPaDato(any(), any()) } returns true - coEvery { merVeiledningVarselFinder.isBrukerYngreEnn67Ar(any()) } returns true justRun { mikrofrontendService.findAndCloseExpiredMikrofrontends() } - val sendVarselService = - SendVarselService( - accessControlService, - testEnv.urlEnv, - merVeiledningVarselService, - merVeiledningVarselFinder, - ) val varselSender = VarselSender( - embeddedDatabase, - sendVarselService, merVeiledningVarselFinder, + merVeiledningVarselService ) with(TestApplicationEngine()) { @@ -138,7 +125,7 @@ class JobApiSpek : DescribeSpec({ it("esyfovarsel-job trigger utsending av 2 varsler digitalt og 3 varsler som brev") { with(handleRequest(HttpMethod.Post, urlPathJobTrigger)) { response.status()?.isSuccess() shouldBeEqualTo true - coVerify(exactly = 5) { merVeiledningVarselService.sendVarselTilArbeidstaker(any(), any(), any()) } + coVerify(exactly = 5) { merVeiledningVarselService.sendVarselTilArbeidstaker(any(), any()) } } } }