Skip to content

Commit

Permalink
WIP: Test oppdater oppfolgingsbruker
Browse files Browse the repository at this point in the history
  • Loading branch information
johatr committed Feb 14, 2025
1 parent d7774ae commit 3aeb7ec
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package no.nav.veilarbvedtaksstotte.client.arena
import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo
import com.github.tomakehurst.wiremock.junit5.WireMockTest
import no.nav.veilarbvedtaksstotte.utils.TestData.TEST_FNR
import no.nav.veilarbvedtaksstotte.utils.TestData.TEST_OPPFOLGINGSSAK
import no.nav.veilarbvedtaksstotte.client.arena.dto.VeilarbArenaOppfolging
import no.nav.veilarbvedtaksstotte.utils.TestData.*
import no.nav.veilarbvedtaksstotte.utils.toJson
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Assertions.assertTrue
Expand Down Expand Up @@ -50,6 +51,56 @@ class VeilarbarenaClientImplTest {
assertEquals(oppfolgingssak, TEST_OPPFOLGINGSSAK)
}

@Test
fun `hent oppfolgingsbruker gir forventet respons`() {
val response =
"""
{
"navKontor": "$TEST_NAVKONTOR"
}
"""

WireMock.givenThat(
WireMock.post(WireMock.urlEqualTo("/api/v3/hent-oppfolgingsbruker"))
.withRequestBody(WireMock.equalToJson("{\"fnr\":\"$TEST_FNR\"}"))
.willReturn(
WireMock.aResponse()
.withStatus(200)
.withBody(response)
)
)

val oppfolgingsbruker = veilarbarenaClient.hentOppfolgingsbruker(TEST_FNR).get()
assertEquals(oppfolgingsbruker.navKontor, TEST_NAVKONTOR)
}

@Test
fun `hent oppdatert oppfolgingsbruker gir forventet respons`() {
val response =
"""
{
"navKontor": "$TEST_NAVKONTOR"
}
"""
val stubMapping = WireMock.stubFor(
WireMock.post(WireMock.urlEqualTo("/api/v3/hent-oppfolgingsbruker"))
.withRequestBody(WireMock.equalToJson("{\"fnr\":\"$TEST_FNR\"}"))
.willReturn(
WireMock.aResponse()
.withStatus(200)
.withBody(response)
)
)

veilarbarenaClient.hentOppfolgingsbruker(TEST_FNR)
veilarbarenaClient.oppdaterOppfolgingsbruker(TEST_FNR, TEST_OPPDATERT_NAVKONTOR)
WireMock.removeStub(stubMapping)

val oppdatertOppfolgingsbruker = veilarbarenaClient.hentOppfolgingsbruker(TEST_FNR)
assertEquals(TEST_OPPDATERT_NAVKONTOR, oppdatertOppfolgingsbruker.get().navKontor)

}

@Test
fun `hent oppfoglingssak feiler dersom respons er 204`() {

Expand Down
2 changes: 2 additions & 0 deletions src/test/java/no/nav/veilarbvedtaksstotte/utils/TestData.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class TestData {
public final static String TEST_VEILEDER_NAVN = "Veileder Veilederen";
public final static String TEST_OPPFOLGINGSENHET_ID = "1234";
public final static String TEST_OPPFOLGINGSSAK = "SAK_1234";
public final static String TEST_NAVKONTOR = "1234";
public final static String TEST_OPPDATERT_NAVKONTOR = "4321";
public final static String TEST_OPPFOLGINGSENHET_NAVN = "NAV Testheim";
public final static String TEST_DIALOG_MELDING = "Dette er en melding";

Expand Down

0 comments on commit 3aeb7ec

Please sign in to comment.