Skip to content

Commit

Permalink
Endret key format for ekstern inntektsmelding
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesper-Hustad committed Nov 11, 2024
1 parent 7a58f14 commit 53e40b6
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ class HentEksternImRiver(
Key.DATA to
data
.plus(
Key.EKSTERN_INNTEKTSMELDING to eksternInntektsmelding.toJson(EksternInntektsmelding.serializer()),
mapOf(
Key.EKSTERN_INNTEKTSMELDING to eksternInntektsmelding.toJson(EksternInntektsmelding.serializer()),
Key.EKSTERN_INNTEKTSMELDING_V2 to eksternInntektsmelding.toJson(EksternInntektsmelding.serializer()),
),
).toJson(),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import no.nav.helsearbeidsgiver.felles.EventName
import no.nav.helsearbeidsgiver.felles.Key
import no.nav.helsearbeidsgiver.felles.domene.EksternInntektsmelding
import no.nav.helsearbeidsgiver.felles.json.les
import no.nav.helsearbeidsgiver.felles.json.lesOrNull
import no.nav.helsearbeidsgiver.felles.json.toJson
import no.nav.helsearbeidsgiver.felles.rapidsrivers.model.Fail
import no.nav.helsearbeidsgiver.felles.rapidsrivers.publish
Expand Down Expand Up @@ -50,7 +51,9 @@ class SpinnService(

override fun lesSteg1(melding: Map<Key, JsonElement>): Steg1 =
Steg1(
eksternInntektsmelding = Key.EKSTERN_INNTEKTSMELDING.les(EksternInntektsmelding.serializer(), melding),
eksternInntektsmelding =
Key.EKSTERN_INNTEKTSMELDING_V2.lesOrNull(EksternInntektsmelding.serializer(), melding)
?: Key.EKSTERN_INNTEKTSMELDING.les(EksternInntektsmelding.serializer(), melding),
)

override fun utfoerSteg0(
Expand Down Expand Up @@ -94,6 +97,7 @@ class SpinnService(
mapOf(
Key.FORESPOERSEL_ID to steg0.forespoerselId.toJson(),
Key.EKSTERN_INNTEKTSMELDING to steg1.eksternInntektsmelding.toJson(EksternInntektsmelding.serializer()),
Key.EKSTERN_INNTEKTSMELDING_V2 to steg1.eksternInntektsmelding.toJson(EksternInntektsmelding.serializer()),
).toJson(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ class HentEksternImRiverTest :
Key.DATA to
innkommendeMelding.data
.plus(
Key.EKSTERN_INNTEKTSMELDING to
mockEksternInntektsmelding().toJson(
EksternInntektsmelding.serializer(),
),
mapOf(
Key.EKSTERN_INNTEKTSMELDING to mockEksternInntektsmelding().toJson(EksternInntektsmelding.serializer()),
Key.EKSTERN_INNTEKTSMELDING_V2 to mockEksternInntektsmelding().toJson(EksternInntektsmelding.serializer()),
),
).toJson(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class SpinnServiceTest :
mapOf(
Key.FORESPOERSEL_ID to Mock.forespoerselId.toJson(),
Key.EKSTERN_INNTEKTSMELDING to Mock.eksternIm.toJson(EksternInntektsmelding.serializer()),
Key.EKSTERN_INNTEKTSMELDING_V2 to Mock.eksternIm.toJson(EksternInntektsmelding.serializer()),
).toJson(),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class HentLagretImRiver(
mapOf(
Key.LAGRET_INNTEKTSMELDING to inntektsmelding.toJson(ResultJson.serializer()),
Key.EKSTERN_INNTEKTSMELDING to eksternInntektsmelding.toJson(ResultJson.serializer()),
Key.EKSTERN_INNTEKTSMELDING_V2 to eksternInntektsmelding.toJson(ResultJson.serializer()),
),
).toJson(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import no.nav.helsearbeidsgiver.felles.Key
import no.nav.helsearbeidsgiver.felles.domene.EksternInntektsmelding
import no.nav.helsearbeidsgiver.felles.json.krev
import no.nav.helsearbeidsgiver.felles.json.les
import no.nav.helsearbeidsgiver.felles.json.lesOrNull
import no.nav.helsearbeidsgiver.felles.json.toJson
import no.nav.helsearbeidsgiver.felles.json.toMap
import no.nav.helsearbeidsgiver.felles.rapidsrivers.model.Fail
Expand Down Expand Up @@ -41,7 +42,9 @@ class LagreEksternImRiver(
eventName = Key.EVENT_NAME.krev(EventName.EKSTERN_INNTEKTSMELDING_MOTTATT, EventName.serializer(), json),
transaksjonId = Key.UUID.les(UuidSerializer, json),
forespoerselId = Key.FORESPOERSEL_ID.les(UuidSerializer, data),
eksternInntektsmelding = Key.EKSTERN_INNTEKTSMELDING.les(EksternInntektsmelding.serializer(), data),
eksternInntektsmelding =
Key.EKSTERN_INNTEKTSMELDING_V2.lesOrNull(EksternInntektsmelding.serializer(), data)
?: Key.EKSTERN_INNTEKTSMELDING.les(EksternInntektsmelding.serializer(), data),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class HentLagretImRiverTest :
?.toJson(EksternInntektsmelding.serializer())
?.toSuccessJson()
.orDefault(MockHentIm.tomResultJson()),
Key.EKSTERN_INNTEKTSMELDING_V2 to
lagret.second
?.toJson(EksternInntektsmelding.serializer())
?.toSuccessJson()
.orDefault(MockHentIm.tomResultJson()),
),
).toJson(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum class Key(

// ulik formattering
EKSTERN_INNTEKTSMELDING("eksternInntektsmelding"),
EKSTERN_INNTEKTSMELDING_V2("ekstern_inntektsmelding"),
FORESPOERSEL_ID("forespoerselId"),
FORESPOERSEL_SVAR("forespoersel-svar"),
JOURNALPOST_ID("journalpostId"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import no.nav.helsearbeidsgiver.felles.domene.EksternInntektsmelding
import no.nav.helsearbeidsgiver.felles.domene.InnsendtInntektsmelding
import no.nav.helsearbeidsgiver.felles.domene.ResultJson
import no.nav.helsearbeidsgiver.felles.json.les
import no.nav.helsearbeidsgiver.felles.json.lesOrNull
import no.nav.helsearbeidsgiver.felles.json.toJson
import no.nav.helsearbeidsgiver.felles.rapidsrivers.model.Fail
import no.nav.helsearbeidsgiver.felles.rapidsrivers.publish
Expand All @@ -23,6 +24,7 @@ import no.nav.helsearbeidsgiver.utils.json.toPretty
import no.nav.helsearbeidsgiver.utils.log.MdcUtils
import no.nav.helsearbeidsgiver.utils.log.logger
import no.nav.helsearbeidsgiver.utils.log.sikkerLogger
import no.nav.helsearbeidsgiver.utils.pipe.orDefault
import java.util.UUID

class KvitteringService(
Expand Down Expand Up @@ -58,8 +60,9 @@ class KvitteringService(
.success
?.fromJson(Inntektsmelding.serializer()),
eksternInntektsmelding =
Key.EKSTERN_INNTEKTSMELDING
.les(ResultJson.serializer(), melding)
Key.EKSTERN_INNTEKTSMELDING_V2
.lesOrNull(ResultJson.serializer(), melding)
.orDefault(Key.EKSTERN_INNTEKTSMELDING.les(ResultJson.serializer(), melding))
.success
?.fromJson(EksternInntektsmelding.serializer()),
)
Expand Down

0 comments on commit 53e40b6

Please sign in to comment.