Skip to content

Commit

Permalink
Fix deserialization of BA-details.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-meidell committed Aug 30, 2023
1 parent 88c80f4 commit 1b58117
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ class BarnetrygdClient(
}

else -> {
deserialize<List<Barnetrygdmelding.Sak>>(it.body!!).let {
deserialize<FagsakWrapper>(it.body!!).let {
when {
it.isEmpty() -> {
it.fagsaker.isEmpty() -> {
HentBarnetrygdResponse.Feil(
status = status.value(),
body = "Liste med barnetrygdsaker er tom"
Expand All @@ -143,7 +143,7 @@ class BarnetrygdClient(

else -> {
HentBarnetrygdResponse.Ok(
barnetrygdsaker = it
barnetrygdsaker = it.fagsaker
)
}
}
Expand All @@ -167,6 +167,10 @@ sealed class HentBarnetygdmottakereResponse {
data class Feil(val status: Int?, val body: String?) : HentBarnetygdmottakereResponse()
}

data class FagsakWrapper(
val fagsaker: List<Barnetrygdmelding.Sak>
)

sealed class HentBarnetrygdResponse {
data class Ok(val barnetrygdsaker: List<Barnetrygdmelding.Sak>) : HentBarnetrygdResponse()
data class Feil(val status: Int?, val body: String?) : HentBarnetrygdResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,13 @@ class BarnetrygdClientTest : SpringContextTest.NoKafka() {
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.withBody(
serialize(
listOf(
Barnetrygdmelding.Sak(
fagsakId = "1",
fagsakEiersIdent = "11",
barnetrygdPerioder = emptyList()
FagsakWrapper(
listOf(
Barnetrygdmelding.Sak(
fagsakId = "1",
fagsakEiersIdent = "11",
barnetrygdPerioder = emptyList()
)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ class KafkaIntegrationTest : SpringContextTest.WithKafka() {
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.withBody(
serialize(
listOf(
Barnetrygdmelding.Sak(
fagsakId = "1",
fagsakEiersIdent = "12345678910",
barnetrygdPerioder = emptyList()
FagsakWrapper(
listOf(
Barnetrygdmelding.Sak(
fagsakId = "1",
fagsakEiersIdent = "12345678910",
barnetrygdPerioder = emptyList()
)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd

import com.fasterxml.jackson.databind.exc.MismatchedInputException
import com.fasterxml.jackson.core.JsonParseException
import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.core.WireMockConfiguration
import com.github.tomakehurst.wiremock.junit5.WireMockExtension
Expand Down Expand Up @@ -124,11 +124,13 @@ class RetryTest : SpringContextTest.NoKafka() {
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.withBody(
serialize(
listOf(
Barnetrygdmelding.Sak(
fagsakId = "1",
fagsakEiersIdent = "12345678910",
barnetrygdPerioder = emptyList()
FagsakWrapper(
listOf(
Barnetrygdmelding.Sak(
fagsakId = "1",
fagsakEiersIdent = "12345678910",
barnetrygdPerioder = emptyList()
)
)
)
)
Expand Down Expand Up @@ -201,7 +203,7 @@ class RetryTest : SpringContextTest.NoKafka() {
barnetrygdmottakerRepository.find(barnetrygdmottaker.id!!)!!.status
)

assertThrows<MismatchedInputException> {
assertThrows<JsonParseException> {
barnetrygdService.process()
}

Expand Down

0 comments on commit 1b58117

Please sign in to comment.