Skip to content

Commit

Permalink
f - Lager GjennyController
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel.skarpas@nav.no
  • Loading branch information
MariamPervez committed Nov 7, 2023
1 parent bee9e24 commit 2d2fdfd
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package no.nav.eessi.pensjon.api.gjenny

import no.nav.eessi.pensjon.eux.klient.Rinasak
import no.nav.eessi.pensjon.fagmodul.eux.EuxInnhentingService
import no.nav.eessi.pensjon.fagmodul.prefill.InnhentingService
import org.slf4j.LoggerFactory
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

//@Unprotected
@RestController
@RequestMapping("/gjenny")
class GjennyController (
private val innhentingService: InnhentingService,
private val euxInnhentingService: EuxInnhentingService
) {

private val logger = LoggerFactory.getLogger(GjennyController::class.java)
// private lateinit var bucerForGjennyBrukere: MetricsHelper.Metric

@GetMapping("/index")
fun get(): String {
return "index"
}

/**
* Returnerer liste med buc'er fra Rina for gjenlevende og avdød
*/
@GetMapping("/bucer/fnrlev/{fnrlev}/fnravdod/{fnrdod}")
fun hentBucerMedJournalforteSeder(
@PathVariable(value = "fnrlev", required = true) fnrlev: String,
@PathVariable(value = "fnrdod", required = true) fnrdod: String,
): List<Rinasak> {
logger.info("Henter bucer fra Rina for fnr")

val gjenlevendeSaker = euxInnhentingService.hentBucerGjenny(fnrlev)
val avdodSaker = euxInnhentingService.hentBucerGjenny(fnrdod)
return gjenlevendeSaker + avdodSaker
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ class EuxInnhentingService (@Value("\${ENV}") private val environment: String,
}
}

fun hentBucerGjenny(fnr: String): List<Rinasak> {
return euxKlient.getRinasaker(fnr)
}

fun lagBucViews(aktoerId: String, pesysSaksnr: String, rinaSakIder: List<String>, rinaSakIdKilde: BucViewKilde): List<BucView> {
val start = System.currentTimeMillis()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package no.nav.eessi.pensjon.api.gjenny

import com.ninjasquad.springmockk.MockkBean
import io.mockk.every
import no.nav.eessi.pensjon.eux.klient.Rinasak
import no.nav.eessi.pensjon.fagmodul.eux.EuxInnhentingService
import no.nav.eessi.pensjon.fagmodul.prefill.InnhentingService
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
import org.springframework.context.annotation.ComponentScan
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.get

@ActiveProfiles(profiles = ["unsecured-webmvctest"])
@ComponentScan(basePackages = ["no.nav.eessi.pensjon.api.gjenny"])
@WebMvcTest(GjennyController::class)
@MockkBean(InnhentingService::class)
class GjennyControllerTest {

@MockkBean
private lateinit var euxInnhentingService: EuxInnhentingService

@Autowired
private lateinit var mockMvc: MockMvc

@Test
fun get() {

mockMvc.get("/gjenny/index").andExpect {
status { isOk() }
content {
string("index")
}
}
}

@Test
fun `hentBucerMedJournalforteSeder skal returnere en liste over bucer paa aktoerId`() {
val fnrlev = "12345678901"
val fnrdod = "12345678900"
val endpointUrl = "/gjenny/bucer/fnrlev/$fnrlev/fnravdod/$fnrdod"

every { euxInnhentingService.hentBucerGjenny(any()) } returns emptyList() andThen listOf(Rinasak("3216546987"))

val result = mockMvc.get(endpointUrl).andReturn()
val response = result.response.getContentAsString(charset("UTF-8"))
Assertions.assertEquals("[{\"id\":\"3216546987\",\"processDefinitionId\":null,\"traits\":null,\"applicationRoleId\":null,\"properties\":null,\"status\":null}]", response)

}
}

0 comments on commit 2d2fdfd

Please sign in to comment.