Skip to content

Commit

Permalink
F - Legger til post kall for sendSed
Browse files Browse the repository at this point in the history
  • Loading branch information
dskarpas committed Sep 27, 2024
1 parent 6435d96 commit d8756d1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/kotlin/no/nav/eessi/pensjon/eux/klient/EuxKlientLib.kt
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,19 @@ open class EuxKlientLib(private val euxRestTemplate: RestTemplate, override var
return result.statusCode == HttpStatus.OK
}

fun sendSed(euxCaseId: String, dokumentId : String): Boolean {
val path = "/buc/{$euxCaseId}/sed/{$dokumentId}/send?ventePaAksjon=false"
val result =
euxRestTemplate.exchange(
path,
HttpMethod.POST,
HttpEntity("", HttpHeaders().apply { contentType = MediaType.APPLICATION_JSON }),
String::class.java
)

return result.statusCode == HttpStatus.OK
}

fun updateSedOnBuc(euxCaseId: String, dokumentId: String, sedPayload: String): Boolean {
val path = "/buc/$euxCaseId/sed/$dokumentId?ventePaAksjon=false"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package no.nav.eessi.pensjon.eux.klient

import com.tngtech.archunit.thirdparty.com.google.common.base.CharMatcher.any
import com.tngtech.archunit.thirdparty.com.google.common.base.Verify.verify
import io.mockk.every
import io.mockk.justRun
import io.mockk.mockk
import io.mockk.verify
import no.nav.eessi.pensjon.eux.model.SedType
import no.nav.eessi.pensjon.eux.model.sed.P2000
import no.nav.eessi.pensjon.eux.model.sed.SED
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.springframework.http.HttpEntity
import org.springframework.http.HttpMethod
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.client.RestTemplate

class EuxKlientLibTest {
Expand Down Expand Up @@ -34,4 +43,26 @@ class EuxKlientLibTest {
val resultAsP2000 = euxKlientLib.hentSed<P2000>("111", "222")!!
assertEquals(SedType.P2000, resultAsP2000.type)
}

@Test
fun `sendSed skal sende korrekt id for buc og sed`() {
val euxCaseId = "1111"
val dokumentId = "2222"
val path = "/buc/{$euxCaseId}/sed/{$dokumentId}/send?ventePaAksjon=false"

val mockResponse = ResponseEntity<String>("", HttpStatus.OK)
every {
mockTemplate.exchange(
path,
HttpMethod.POST,
any<HttpEntity<String>>(),
String::class.java
)
} returns mockResponse

val result = euxKlientLib.sendSed(euxCaseId, dokumentId)

assertTrue(result)
verify { mockTemplate.exchange(path, HttpMethod.POST, any<HttpEntity<String>>(), String::class.java) }
}
}

0 comments on commit d8756d1

Please sign in to comment.