Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/EY-5030-behan…
Browse files Browse the repository at this point in the history
…dling-som-brev-proxy

# Conflicts:
#	apps/etterlatte-behandling/src/test/kotlin/integration/BehandlingIntegrationTest.kt
  • Loading branch information
tvsignal committed Feb 25, 2025
1 parent e03b8a2 commit a5190be
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ internal class ApplicationContext(
// TODO: slette disse
val aldersovergangDaoProxy: IAldersovergangDao? = AldersovergangDaoProxy(config, httpClient()),
val opplysningDaoProxy: IOpplysningDao? = OpplysningDaoProxy(config, httpClient()),
grunnlagServiceOverride: GrunnlagService? = null,
) {
val httpPort = env.getOrDefault(HTTP_PORT, "8080").toInt()
val saksbehandlerGroupIdsByKey = AzureGroup.entries.associateWith { env.requireEnvValue(it.envKey) }
Expand Down Expand Up @@ -394,7 +395,7 @@ internal class ApplicationContext(
.AldersovergangService(aldersovergangDao)

val grunnlagService: GrunnlagService =
GrunnlagServiceImpl(
grunnlagServiceOverride ?: GrunnlagServiceImpl(
pdlTjenesterKlient,
opplysningDao,
GrunnlagHenter(pdlTjenesterKlient),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import no.nav.etterlatte.brev.model.Mottaker
import no.nav.etterlatte.brev.model.Spraak
import no.nav.etterlatte.brev.model.Status
import no.nav.etterlatte.common.Enheter
import no.nav.etterlatte.grunnlag.GrunnlagService
import no.nav.etterlatte.grunnlag.IOpplysningDao
import no.nav.etterlatte.inTransaction
import no.nav.etterlatte.ktor.runServerWithModule
import no.nav.etterlatte.libs.common.Enhetsnummer
Expand All @@ -62,6 +64,7 @@ import no.nav.etterlatte.libs.common.vedtak.VedtakFattet
import no.nav.etterlatte.libs.common.vedtak.VedtakInnholdDto
import no.nav.etterlatte.libs.common.vedtak.VedtakStatus
import no.nav.etterlatte.libs.common.vedtak.VedtakType
import no.nav.etterlatte.libs.testdata.grunnlag.GrunnlagTestData
import no.nav.etterlatte.libs.testdata.grunnlag.SOEKER_FOEDSELSNUMMER
import no.nav.etterlatte.module
import no.nav.etterlatte.nyKontekstMedBrukerOgDatabase
Expand All @@ -84,15 +87,13 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {
private lateinit var behandlingDao: BehandlingDao
private lateinit var sakSkrivDao: SakSkrivDao
private lateinit var tilbakekrevingDao: TilbakekrevingDao
private lateinit var opplysningDao: IOpplysningDao

private val tilbakestiltPayload =
BrevPayload(
Slate(
listOf(
Slate.Element(
Slate.ElementType.HEADING_TWO,
listOf(Slate.InnerElement(text = "Tilbakestilt!")),
),
Slate.Element(Slate.ElementType.HEADING_TWO, listOf(Slate.InnerElement(text = "Tilbakestilt!"))),
),
),
emptyList(),
Expand All @@ -112,6 +113,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {
}
}
private val vedtakKlient: VedtakKlient = mockk()
private val grunnlagServiceMock: GrunnlagService = mockk()
private val brevKlientMock: BrevKlient =
mockk {
coEvery { opprettVedtaksbrev(any(), any(), any()) } answers {
Expand All @@ -127,6 +129,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {
sakSkrivDao = applicationContext.sakSkrivDao
behandlingDao = applicationContext.behandlingDao
tilbakekrevingDao = applicationContext.tilbakekrevingDao
opplysningDao = applicationContext.opplysningDao
}

@BeforeAll
Expand All @@ -135,6 +138,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {
brevApiKlient = brevApiKlientMock,
brevKlient = brevKlientMock,
vedtakKlient = vedtakKlient,
grunnlagService = grunnlagServiceMock,
)
val user = mockk<SaksbehandlerMedEnheterOgRoller>(relaxed = true)
val saksbehandlerMedRoller =
Expand Down Expand Up @@ -163,7 +167,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {
inner class GammelPullModell {
@Test
fun `skal opprette vedtaksbrev for behandling`() {
val sak = opprettSak()
val sak = opprettSakMedGrunnlag()
val behandling: no.nav.etterlatte.behandling.domain.Behandling = opprettBehandling(sak)
coEvery { vedtakKlient.hentVedtak(any(), any()) } returns
vedtak(sak, behandling.id, vedtakBehandlingDto(behandling))
Expand All @@ -182,7 +186,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {

@Test
fun `skal tilbakestille vedtaksbrev`() {
val sak = opprettSak()
val sak = opprettSakMedGrunnlag()
val behandling = opprettBehandling(sak)
coEvery { vedtakKlient.hentVedtak(any(), any()) } returns vedtak(sak, behandling.id, vedtakBehandlingDto(behandling))

Expand Down Expand Up @@ -212,7 +216,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {

@Test
fun `skal generere pdf`() {
val sak = opprettSak()
val sak = opprettSakMedGrunnlag()
val behandling = opprettBehandling(sak)
coEvery { vedtakKlient.hentVedtak(any(), any()) } returns vedtak(sak, behandling.id, vedtakBehandlingDto(behandling))

Expand All @@ -232,7 +236,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {

@Test
fun `skal ferdigstille vedtaksbrev`() {
val sak = opprettSak()
val sak = opprettSakMedGrunnlag()
val behandling = opprettBehandling(sak)
coEvery { vedtakKlient.hentVedtak(any(), any()) } returns vedtak(sak, behandling.id, vedtakBehandlingDto(behandling))

Expand All @@ -252,7 +256,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {

@Test
fun `skal hente vedtaksbrev`() {
val sak = opprettSak()
val sak = opprettSakMedGrunnlag()
val behandling = opprettBehandling(sak)
coEvery { vedtakKlient.hentVedtak(any(), any()) } returns vedtak(sak, behandling.id, vedtakBehandlingDto(behandling))

Expand All @@ -277,7 +281,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {
inner class NyPushModell {
@Test
fun `skal opprette vedtaksbrev for tilbakekreving`() {
val sak = opprettSak()
val sak = opprettSakMedGrunnlag()
val tilbakekrevingBehandling = opprettTilbakekreving(sak)
val tilbakekrevingId = tilbakekrevingBehandling.id
val vedtakInnhold = vedtakTilbakekrevingBehandlingDto(tilbakekrevingBehandling.tilbakekreving)
Expand All @@ -299,7 +303,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {

@Test
fun `skal tilbakestille vedtaksbrev for tilbakekreving`() {
val sak = opprettSak()
val sak = opprettSakMedGrunnlag()
val tilbakekrevingBehandling = opprettTilbakekreving(sak)
val tilbakekrevingId = tilbakekrevingBehandling.id
val vedtakInnhold = vedtakTilbakekrevingBehandlingDto(tilbakekrevingBehandling.tilbakekreving)
Expand Down Expand Up @@ -330,7 +334,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {

@Test
fun `skal generere pdf for tilbakekreving`() {
val sak = opprettSak()
val sak = opprettSakMedGrunnlag()
val tilbakekrevingBehandling = opprettTilbakekreving(sak)
val tilbakekrevingId = tilbakekrevingBehandling.id
val vedtakInnhold = vedtakTilbakekrevingBehandlingDto(tilbakekrevingBehandling.tilbakekreving)
Expand All @@ -353,7 +357,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {

@Test
fun `skal ferdigstille vedtaksbrev for tilbakekreving`() {
val sak = opprettSak()
val sak = opprettSakMedGrunnlag()
val tilbakekrevingBehandling = opprettTilbakekreving(sak)
val tilbakekrevingId = tilbakekrevingBehandling.id
val vedtakInnhold = vedtakTilbakekrevingBehandlingDto(tilbakekrevingBehandling.tilbakekreving)
Expand All @@ -380,7 +384,7 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {

@Test
fun `skal hente vedtaksbrev for tilbakekreving`() {
val sak = opprettSak()
val sak = opprettSakMedGrunnlag()
val tilbakekrevingBehandling = opprettTilbakekreving(sak)
val tilbakekrevingId = tilbakekrevingBehandling.id
val vedtakInnhold = vedtakTilbakekrevingBehandlingDto(tilbakekrevingBehandling.tilbakekreving)
Expand Down Expand Up @@ -445,13 +449,17 @@ internal class BrevRouteIntegrationTest : BehandlingIntegrationTest() {
behandlingDao.hentBehandling(opprettBehandling.id) as Foerstegangsbehandling
}

private fun opprettSak() =
private fun opprettSakMedGrunnlag() =
inTransaction {
sakSkrivDao.opprettSak(
SOEKER_FOEDSELSNUMMER.value,
SakType.OMSTILLINGSSTOENAD,
Enheter.defaultEnhet.enhetNr,
)
val sak =
sakSkrivDao.opprettSak(
SOEKER_FOEDSELSNUMMER.value,
SakType.OMSTILLINGSSTOENAD,
Enheter.defaultEnhet.enhetNr,
)
coEvery { grunnlagServiceMock.hentOpplysningsgrunnlagForSak(sak.id) } returns
GrunnlagTestData().hentOpplysningsgrunnlag()
sak
}

private fun withTestApplication(block: suspend (client: HttpClient) -> Unit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import no.nav.etterlatte.common.klienter.SkjermingKlient
import no.nav.etterlatte.config.ApplicationContext
import no.nav.etterlatte.funksjonsbrytere.DummyFeatureToggleService
import no.nav.etterlatte.funksjonsbrytere.FeatureToggleService
import no.nav.etterlatte.grunnlag.GrunnlagService
import no.nav.etterlatte.grunnlag.IOpplysningDao
import no.nav.etterlatte.grunnlag.aldersovergang.IAldersovergangDao
import no.nav.etterlatte.kafka.KafkaKey
Expand Down Expand Up @@ -58,6 +59,7 @@ abstract class BehandlingIntegrationTest {
aldersovergangDao: IAldersovergangDao? = null,
opplysningDao: IOpplysningDao? = null,
vedtakKlient: VedtakKlient? = null,
grunnlagService: GrunnlagService? = null,
) {
mockOAuth2Server.start()
val props = dbExtension.properties()
Expand Down Expand Up @@ -125,6 +127,7 @@ abstract class BehandlingIntegrationTest {
aldersovergangDaoProxy = aldersovergangDao,
opplysningDaoProxy = opplysningDao,
inntektskomponentKlient = InntektskomponentKlientTest(),
grunnlagServiceOverride = grunnlagService,
)
}

Expand Down

0 comments on commit a5190be

Please sign in to comment.