Skip to content

Commit

Permalink
Fjern utdaterte hjelpemetoder
Browse files Browse the repository at this point in the history
  • Loading branch information
bjerga committed Oct 24, 2024
1 parent 6ac0f5f commit b3d2b8d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import no.nav.helsearbeidsgiver.felles.json.toJson
import no.nav.helsearbeidsgiver.felles.json.toMap
import no.nav.helsearbeidsgiver.felles.rapidsrivers.model.Fail
import no.nav.helsearbeidsgiver.felles.rapidsrivers.model.ModelUtils.toFailOrNull
import no.nav.helsearbeidsgiver.felles.rapidsrivers.toPretty
import no.nav.helsearbeidsgiver.inntektsmelding.feilbehandler.prosessor.FeilProsessor
import no.nav.helsearbeidsgiver.utils.json.fromJson
import no.nav.helsearbeidsgiver.utils.json.parseJson
import no.nav.helsearbeidsgiver.utils.json.serializer.UuidSerializer
import no.nav.helsearbeidsgiver.utils.json.toJson
import no.nav.helsearbeidsgiver.utils.json.toPretty
import no.nav.helsearbeidsgiver.utils.log.sikkerLogger
import java.sql.SQLException
import java.util.UUID
Expand Down Expand Up @@ -59,7 +59,7 @@ class FeilLytter(
packet: JsonMessage,
context: MessageContext,
) {
sikkerLogger.info("Mottok feil: ${packet.toPretty()}")
sikkerLogger.info("Mottok feil: ${packet.toJson().parseJson().toPretty()}")
val fail = toFailOrNull(packet.toJson().parseJson().toMap())
if (fail == null) {
sikkerLogger.warn("Kunne ikke parse feil-objekt, ignorerer...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,9 @@ import io.micrometer.prometheusmetrics.PrometheusConfig
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonNull
import no.nav.helsearbeidsgiver.felles.IKey
import no.nav.helsearbeidsgiver.felles.Key
import no.nav.helsearbeidsgiver.utils.json.parseJson
import no.nav.helsearbeidsgiver.utils.json.toJson
import no.nav.helsearbeidsgiver.utils.json.toPretty

fun JsonMessage.toPretty(): String = toJson().parseJson().toPretty()

fun JsonMessage.demandValues(vararg keyAndValuePairs: Pair<IKey, String>) {
keyAndValuePairs.forEach { (key, value) ->
demandValue(key.str, value)
}
}

fun JsonMessage.requireKeys(vararg keys: IKey) {
val keysAsStr = keys.map(IKey::str).toTypedArray()
requireKey(*keysAsStr)
}

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

Expand Down

0 comments on commit b3d2b8d

Please sign in to comment.