-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/main/kotlin/no/nav/eessi/pensjon/api/gjenny/GjennyController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/test/kotlin/no/nav/eessi/pensjon/api/gjenny/GjennyControllerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
} | ||
} |