-
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.
- Loading branch information
1 parent
2ad4a28
commit ecd5a95
Showing
9 changed files
with
123 additions
and
8 deletions.
There are no files selected for viewing
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
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
19 changes: 19 additions & 0 deletions
19
...orgsopptjening/start/innlesning/barnetrygd/external/pdl/RestTemplateLoggingInterceptor.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,19 @@ | ||
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.external.pdl | ||
import org.springframework.http.HttpRequest | ||
import org.springframework.http.client.ClientHttpRequestExecution | ||
import org.springframework.http.client.ClientHttpRequestInterceptor | ||
import org.springframework.http.client.ClientHttpResponse | ||
import org.springframework.util.StreamUtils | ||
import java.nio.charset.StandardCharsets | ||
|
||
class RestTemplateLoggingInterceptor : ClientHttpRequestInterceptor { | ||
override fun intercept( | ||
request: HttpRequest, | ||
body: ByteArray, | ||
execution: ClientHttpRequestExecution | ||
): ClientHttpResponse { | ||
val response = execution.execute(request, body) | ||
println("Response Body: " + StreamUtils.copyToString(response.body, StandardCharsets.UTF_8)) | ||
return response | ||
} | ||
} |
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
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
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
41 changes: 41 additions & 0 deletions
41
...ensjon/opptjening/omsorgsopptjening/start/innlesning/external/pdl/WiremockScenarioTest.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,41 @@ | ||
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.external.pdl | ||
|
||
import com.github.tomakehurst.wiremock.core.WireMockConfiguration | ||
import com.github.tomakehurst.wiremock.junit5.WireMockExtension | ||
import no.nav.pensjon.opptjening.omsorgsopptjening.felles.CorrelationId | ||
import no.nav.pensjon.opptjening.omsorgsopptjening.felles.InnlesingId | ||
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.Mdc | ||
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.SpringContextTest | ||
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.external.pdl.PdlService | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.RegisterExtension | ||
import org.springframework.beans.factory.annotation.Autowired | ||
|
||
class WiremockScenarioTest : SpringContextTest.NoKafka() { | ||
|
||
companion object { | ||
@JvmField | ||
@RegisterExtension | ||
val wiremock = WireMockExtension.newInstance() | ||
.options(WireMockConfiguration.wireMockConfig().port(WIREMOCK_PORT)) | ||
.build()!! | ||
} | ||
|
||
@Autowired | ||
lateinit var pdlService: PdlService | ||
|
||
@Test | ||
fun `wiremock fnr fra query returnerer riktig fnr`() { | ||
val fnr = "91929394959" | ||
wiremock.`pdl fnr fra query`() | ||
|
||
val person = | ||
Mdc.scopedMdc(CorrelationId.generate()) { | ||
Mdc.scopedMdc(InnlesingId.generate()) { | ||
pdlService.hentPerson(fnr) | ||
} | ||
} | ||
assertThat(person.fnr).isEqualTo(fnr) | ||
} | ||
} |
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,18 @@ | ||
{{#assign fnr}}{{regexExtract request.body '"(variables)"\:\{"ident"\:"([^"]+)"' 'parts'}}{{/assign}} | ||
{ | ||
"data": { | ||
"hentPerson": { | ||
"folkeregisteridentifikator": [ | ||
{ | ||
"identifikasjonsnummer": "{{parts.1}}", | ||
"status": "I_BRUK", | ||
"type": "FNR", | ||
"metadata": { | ||
"historisk": false, | ||
"master": "FREG" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
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,19 @@ | ||
"variables":{"ident":"91929394959"}} | ||
{{#assign fnr}}{{regexExtract request.body '(pdlPerson)\(([^)]+)' 'parts'}}{{/assign}} | ||
{ | ||
"data": { | ||
"hentPerson": { | ||
"folkeregisteridentifikator": [ | ||
{ | ||
"identifikasjonsnummer": "{{request.body}}", | ||
"status": "I_BRUK", | ||
"type": "FNR", | ||
"metadata": { | ||
"historisk": false, | ||
"master": "FREG" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |