Skip to content

Commit

Permalink
Sleng på test for å hente vedtaksliste for fnr i body for samordning …
Browse files Browse the repository at this point in the history
…i vedtak
  • Loading branch information
sebassonav committed Dec 4, 2024
1 parent 4135498 commit e66586f
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package no.nav.etterlatte.vedtaksvurdering
import io.kotest.matchers.shouldBe
import io.ktor.client.request.get
import io.ktor.client.request.header
import io.ktor.client.request.post
import io.ktor.client.request.setBody
import io.ktor.http.ContentType
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpStatusCode
Expand All @@ -17,6 +19,7 @@ import no.nav.etterlatte.ktor.startRandomPort
import no.nav.etterlatte.ktor.token.issueSystembrukerToken
import no.nav.etterlatte.libs.common.behandling.BehandlingType
import no.nav.etterlatte.libs.common.behandling.SakType
import no.nav.etterlatte.libs.common.person.Folkeregisteridentifikator
import no.nav.etterlatte.libs.common.sak.VedtakSak
import no.nav.etterlatte.libs.common.tidspunkt.Tidspunkt
import no.nav.etterlatte.libs.common.vedtak.Attestasjon
Expand All @@ -25,12 +28,14 @@ import no.nav.etterlatte.libs.common.vedtak.VedtakFattet
import no.nav.etterlatte.libs.common.vedtak.VedtakSamordningDto
import no.nav.etterlatte.libs.common.vedtak.VedtakStatus
import no.nav.etterlatte.libs.common.vedtak.VedtakType
import no.nav.etterlatte.libs.ktor.route.FoedselsnummerDTO
import no.nav.security.mock.oauth2.MockOAuth2Server
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import java.time.LocalDate
import java.time.Month
import java.time.YearMonth
import java.time.temporal.ChronoUnit
Expand Down Expand Up @@ -77,6 +82,30 @@ class SamordningsvedtakRouteTest {
}
}

@Test
fun `Kan returnere vedtaksliste for fnr i body`() {
val fomDate = LocalDate.now()
val fnr = Folkeregisteridentifikator.of(FNR_2)
coEvery { vedtakSamordningService.hentVedtaksliste(sakType = SakType.OMSTILLINGSSTOENAD, fomDato = fomDate, fnr = fnr) } returns
listOf(samordningVedtak())
testApplication {
val client =
runServer(mockOAuth2Server) {
samordningSystembrukerVedtakRoute(vedtakSamordningService)
}

val response =
client.post("/api/samordning/vedtak?sakstype=${SakType.OMSTILLINGSSTOENAD}&fomDato=$fomDate") {
header(HttpHeaders.ContentType, ContentType.Application.Json.toString())
header(HttpHeaders.Authorization, "Bearer ${token(listOf("dummy", "samordning-read"))}")
setBody(FoedselsnummerDTO(fnr.value))
}

response.status shouldBe HttpStatusCode.OK
coVerify { vedtakSamordningService.hentVedtaksliste(sakType = SakType.OMSTILLINGSSTOENAD, fomDato = fomDate, fnr = fnr) }
}
}

private fun token(roles: List<String>): String = mockOAuth2Server.issueSystembrukerToken(mittsystem = "pensjon-pen", roles = roles)
}

Expand Down

0 comments on commit e66586f

Please sign in to comment.