Skip to content

Commit

Permalink
Slettet midlertidlig JOURNALPOST_ID key (#770)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikael Bjerga <[email protected]>
  • Loading branch information
Jesper-Hustad and bjerga committed Nov 13, 2024
1 parent 15fb217 commit db1526b
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class LagreJournalpostIdRiverTest :
Key.INNTEKTSMELDING to innkommendeMelding.inntektsmelding.toJson(Inntektsmelding.serializer()),
Key.BESTEMMENDE_FRAVAERSDAG to Mock.bestemmendeFravaersdag.toJson(),
Key.JOURNALPOST_ID to innkommendeMelding.journalpostId.toJson(),
Key.JOURNALPOST_ID_V2 to innkommendeMelding.journalpostId.toJson(),
)

verifySequence {
Expand Down Expand Up @@ -106,7 +105,6 @@ class LagreJournalpostIdRiverTest :
Key.UUID to innkommendeMelding.transaksjonId.toJson(),
Key.INNTEKTSMELDING to innkommendeMelding.inntektsmelding.toJson(Inntektsmelding.serializer()),
Key.JOURNALPOST_ID to innkommendeMelding.journalpostId.toJson(),
Key.JOURNALPOST_ID_V2 to innkommendeMelding.journalpostId.toJson(),
)

verifySequence {
Expand Down Expand Up @@ -247,7 +245,6 @@ private object Mock {
Key.EVENT_NAME to eventName.toJson(),
Key.UUID to transaksjonId.toJson(),
Key.JOURNALPOST_ID to journalpostId.toJson(),
Key.JOURNALPOST_ID_V2 to journalpostId.toJson(),
Key.INNTEKTSMELDING to inntektsmelding.toJson(Inntektsmelding.serializer()),
Key.BESTEMMENDE_FRAVAERSDAG to bestemmendeFravaersdag.toJson(),
Key.INNSENDING_ID to INNSENDING_ID.toJson(Long.serializer()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class DistribusjonRiverTest :
Key.EVENT_NAME to EventName.INNTEKTSMELDING_DISTRIBUERT.toJson(),
Key.UUID to innkommendeMelding.transaksjonId.toJson(),
Key.JOURNALPOST_ID to innkommendeMelding.journalpostId.toJson(),
Key.JOURNALPOST_ID_V2 to innkommendeMelding.journalpostId.toJson(),
Key.INNTEKTSMELDING to innkommendeMelding.inntektsmelding.toJson(Inntektsmelding.serializer()),
Key.BESTEMMENDE_FRAVAERSDAG to innkommendeMelding.bestemmendeFravaersdag?.toJson(),
).mapValuesNotNull { it }
Expand Down Expand Up @@ -110,7 +109,6 @@ class DistribusjonRiverTest :
Key.EVENT_NAME to EventName.INNTEKTSMELDING_DISTRIBUERT.toJson(),
Key.UUID to innkommendeMelding.transaksjonId.toJson(),
Key.JOURNALPOST_ID to innkommendeMelding.journalpostId.toJson(),
Key.JOURNALPOST_ID_V2 to innkommendeMelding.journalpostId.toJson(),
Key.INNTEKTSMELDING to selvbestemtInntektsmelding.toJson(Inntektsmelding.serializer()),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ enum class Key(
VIRKSOMHET("virksomhet"),
VIRKSOMHETER("virksomheter"),
FORESPOERSEL_SVAR("forespoersel_svar"),
JOURNALPOST_ID("journalpost_id"),

// ulik formattering
FORESPOERSEL_ID("forespoerselId"),
JOURNALPOST_ID("journalpostId"),
JOURNALPOST_ID_V2("journalpost_id"),
ORGNRUNDERENHET("orgnrUnderenhet"),
SPINN_INNTEKTSMELDING_ID("spinnInntektsmeldingId"),
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonNull
import no.nav.helsearbeidsgiver.felles.Key
import no.nav.helsearbeidsgiver.utils.collection.mapValuesNotNull
import no.nav.helsearbeidsgiver.utils.json.parseJson
import no.nav.helsearbeidsgiver.utils.json.toJson

fun MessageContext.publish(vararg messageFields: Pair<Key, JsonElement>): JsonElement = publish(messageFields.toMap())

fun MessageContext.publish(messageFields: Map<Key, JsonElement>): JsonElement =
messageFields
.mapAddTemporaryJournalpostKey()
.mapKeys { (key, _) -> key.toString() }
.filterValues { it !is JsonNull }
.toJson()
Expand All @@ -31,12 +29,3 @@ fun MessageContext.publish(messageFields: Map<Key, JsonElement>): JsonElement =
}.toJson()
.also(::publish)
.parseJson()

private fun Map<Key, JsonElement>.mapAddTemporaryJournalpostKey(): Map<Key, JsonElement> {
// forsikre at this inneholder journalpost
if (!this.containsKey(Key.JOURNALPOST_ID)) {
return this
}

return this.plus(Key.JOURNALPOST_ID_V2 to this[Key.JOURNALPOST_ID]).mapValuesNotNull { it }
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class JournalfoerImRiverTest :
Key.EVENT_NAME to EventName.INNTEKTSMELDING_JOURNALFOERT.toJson(),
Key.UUID to innkommendeMelding.transaksjonId.toJson(),
Key.JOURNALPOST_ID to journalpostId.toJson(),
Key.JOURNALPOST_ID_V2 to journalpostId.toJson(),
Key.INNTEKTSMELDING to Mock.inntektsmelding.toJson(Inntektsmelding.serializer()),
Key.BESTEMMENDE_FRAVAERSDAG to Mock.bestemmendeFravaersdag.toJson(),
Key.INNSENDING_ID to innsendingId.toJson(Long.serializer()),
Expand Down Expand Up @@ -125,7 +124,6 @@ class JournalfoerImRiverTest :
Key.EVENT_NAME to EventName.INNTEKTSMELDING_JOURNALFOERT.toJson(),
Key.UUID to innkommendeMelding.transaksjonId.toJson(),
Key.JOURNALPOST_ID to journalpostId.toJson(),
Key.JOURNALPOST_ID_V2 to journalpostId.toJson(),
Key.INNTEKTSMELDING to Mock.inntektsmelding.toJson(Inntektsmelding.serializer()),
)

Expand Down

0 comments on commit db1526b

Please sign in to comment.