Skip to content

Commit

Permalink
* ktlint v 50 og alt det medfører
Browse files Browse the repository at this point in the history
* Ryddet bort siste rest av Unleash
  • Loading branch information
geiralund committed Sep 12, 2023
1 parent 4b52a72 commit 039c86d
Show file tree
Hide file tree
Showing 103 changed files with 586 additions and 588 deletions.
11 changes: 11 additions & 0 deletions docs/arkitektur/tilstander/Ukjent bruker ab0438.approved.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@startuml
title
Innløpet – flyt for brevkode Ukjent bruker ab0438
end title
[*]-->MottattType
MottattType --> AvventerJournalpostType
AvventerJournalpostType --> AvventerPersondataType
AvventerPersondataType --> UkjentBrukerType
UkjentBrukerType --> InnsendingFerdigstiltType
InnsendingFerdigstiltType--> [*]
@enduml
11 changes: 11 additions & 0 deletions docs/arkitektur/tilstander/Ukjent bruker ab0451.approved.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@startuml
title
Innløpet – flyt for brevkode Ukjent bruker ab0451
end title
[*]-->MottattType
MottattType --> AvventerJournalpostType
AvventerJournalpostType --> AvventerPersondataType
AvventerPersondataType --> UkjentBrukerType
UkjentBrukerType --> InnsendingFerdigstiltType
InnsendingFerdigstiltType--> [*]
@enduml
11 changes: 11 additions & 0 deletions docs/arkitektur/tilstander/Ukjent bruker ab0452.approved.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@startuml
title
Innløpet – flyt for brevkode Ukjent bruker ab0452
end title
[*]-->MottattType
MottattType --> AvventerJournalpostType
AvventerJournalpostType --> AvventerPersondataType
AvventerPersondataType --> UkjentBrukerType
UkjentBrukerType --> InnsendingFerdigstiltType
InnsendingFerdigstiltType--> [*]
@enduml
1 change: 0 additions & 1 deletion mediator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies {
implementation(Ktor2.Server.library("call-logging"))
implementation("de.slub-dresden:urnlib:2.0.1")


testImplementation(kotlin("test"))
testImplementation("no.nav.security:mock-oauth2-server:1.0.0")
testImplementation(Mockk.mockk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal class ApplicationBuilder(env: Map<String, String>) : RapidsConnection.S
private val ferdigstiltInnsendingObserver = FerdigstiltInnsendingObserver(Config.kafkaProducerProperties)

private val rapidsConnection = RapidApplication.Builder(
RapidApplication.RapidApplicationConfig.fromEnv(env)
RapidApplication.RapidApplicationConfig.fromEnv(env),
)
.also { builder ->
builder.withKtorModule {
Expand All @@ -63,8 +63,8 @@ internal class ApplicationBuilder(env: Map<String, String>) : RapidsConnection.S
observatører = listOf(
ferdigstiltInnsendingObserver,
MetrikkObserver(),
InnsendingProbe
)
InnsendingProbe,
),
)
// Behovmottakere
MottakMediator(mediator, this)
Expand All @@ -75,13 +75,13 @@ internal class ApplicationBuilder(env: Map<String, String>) : RapidsConnection.S
FerdigstillJournalpostBehovLøser(journalpostApiClient, this)
PersondataBehovLøser(
createPersonOppslag(PdlPersondataOppslag(Config.properties), SkjermingOppslag(Config.properties)),
this
this,
)
SøknadsdataBehovLøser(safClient, this)
MinsteinntektVurderingLøser(
regelApiClient = regelApiClient,
repository = minsteinntektVurderingRepository,
rapidsConnection = this
rapidsConnection = this,
)
ArenaBehovLøser(arenaApiClient, this)
OpprettGosysOppgaveLøser(gosysProxyClient, this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ private val logg = KotlinLogging.logger {}

class BehovMediator(
private val rapidsConnection: RapidsConnection,
private val sikkerLogg: KLogger
private val sikkerLogg: KLogger,
) {

internal fun håndter(hendelse: Hendelse) {
Expand All @@ -18,7 +18,7 @@ class BehovMediator(

private fun håndter(
hendelse: Hendelse,
behov: List<Aktivitetslogg.Aktivitet.Behov>
behov: List<Aktivitetslogg.Aktivitet.Behov>,
) {
behov.groupBy { it.kontekst() }.forEach { (kontekst, behov) ->
val behovsliste = mutableListOf<String>()
Expand All @@ -29,7 +29,7 @@ class BehovMediator(
require(behov.type.name !in behovsliste) { "Kan ikke produsere samme behov ${behov.type.name} på samme kontekst" }
require(
behov.detaljer().filterKeys { this.containsKey(it) && this[it] != behov.detaljer()[it] }
.isEmpty()
.isEmpty(),
) { "Kan ikke produsere behov med duplikate detaljer" }
behovsliste.add(behov.type.name)
putAll(behov.detaljer())
Expand Down
25 changes: 11 additions & 14 deletions mediator/src/main/kotlin/no/nav/dagpenger/mottak/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import com.natpryce.konfig.EnvironmentVariables
import com.natpryce.konfig.Key
import com.natpryce.konfig.overriding
import com.natpryce.konfig.stringType
import no.finn.unleash.DefaultUnleash
import no.finn.unleash.util.UnleashConfig
import no.nav.dagpenger.oauth2.CachedOauth2Client
import no.nav.dagpenger.oauth2.OAuth2Config
import org.apache.kafka.clients.CommonClientConfigs
Expand Down Expand Up @@ -41,14 +39,14 @@ internal object Config {
"AZURE_APP_CLIENT_ID" to "azureClientId",
"AZURE_OPENID_CONFIG_JWKS_URI" to "http://localhost:4443",

)
),
)
private val prodProperties = ConfigurationMap(
mapOf(
"DP_PROXY_SCOPE" to "api://prod-fss.teamdagpenger.dp-proxy/.default",
"PDL_API_SCOPE" to "api://prod-fss.pdl.pdl-api/.default",
"SKJERMING_API_SCOPE" to "api://prod-gcp.nom.skjermede-personer-pip/.default",
)
),
)

val properties: Configuration by lazy {
Expand All @@ -70,14 +68,20 @@ internal object Config {
private fun String.addHttprotocoll(): String = "https://$this"

val Configuration.dpProxyTokenProvider: () -> String by lazy {
{ cachedTokenProvider.clientCredentials(properties[Key("DP_PROXY_SCOPE", stringType)]).accessToken }
{
cachedTokenProvider.clientCredentials(properties[Key("DP_PROXY_SCOPE", stringType)]).accessToken
}
}

val Configuration.pdlApiTokenProvider: () -> String by lazy {
{ cachedTokenProvider.clientCredentials(properties[Key("PDL_API_SCOPE", stringType)]).accessToken }
{
cachedTokenProvider.clientCredentials(properties[Key("PDL_API_SCOPE", stringType)]).accessToken
}
}
val Configuration.skjermingApiTokenProvider: () -> String by lazy {
{ cachedTokenProvider.clientCredentials(properties[Key("SKJERMING_API_SCOPE", stringType)]).accessToken }
{
cachedTokenProvider.clientCredentials(properties[Key("SKJERMING_API_SCOPE", stringType)]).accessToken
}
}

val kafkaProducerProperties: Properties by lazy {
Expand All @@ -104,13 +108,6 @@ internal object Config {
fun Configuration.skjermingApiUrl() = this[Key("SKJERMING_API_URL", stringType)]
fun Configuration.dpProxyUrl() = this[Key("DP_PROXY_HOST", stringType)].addHttprotocoll()
fun Configuration.pdlApiUrl() = this[Key("PDL_API_HOST", stringType)].addHttprotocoll()
fun unleash() = DefaultUnleash(unleashConfig(), ByClusterStrategy(ByClusterStrategy.Cluster.current))
private fun unleashConfig(): UnleashConfig =
UnleashConfig.builder()
.appName("dp-mottak")
.instanceId(getHostname())
.unleashAPI(properties[Key("UNLEASH_URL", stringType)])
.build()

fun asMap(): Map<String, String> = properties.list().reversed().fold(emptyMap()) { map, pair ->
map + pair.second
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ private val sikkerlogg = KotlinLogging.logger("tjenestekall")
internal class InnsendingMediator(
private val innsendingRepository: InnsendingRepository,
private val observatører: List<InnsendingObserver> = emptyList(),
rapidsConnection: RapidsConnection
rapidsConnection: RapidsConnection,
) {

private val behovMediator: BehovMediator = BehovMediator(
rapidsConnection = rapidsConnection,
sikkerLogg = sikkerlogg
sikkerLogg = sikkerlogg,
)

fun håndter(joarkHendelse: JoarkHendelse) {
Expand Down
7 changes: 3 additions & 4 deletions mediator/src/main/kotlin/no/nav/dagpenger/mottak/api/Auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ internal fun AuthenticationContext.fnr(): String =

internal fun AuthenticationConfig.jwt(
name: String,
configure: JWTConfigureFunction = {}
configure: JWTConfigureFunction = {},
) {

jwt(name) {
verifier(
jwkProvider = cachedJwkProvider(Config.AzureAd.jwksURI),
issuer = Config.AzureAd.issuer,
configure
configure,
)
validate {
JWTPrincipal(it.payload)
Expand All @@ -42,7 +41,7 @@ private fun cachedJwkProvider(jwksUri: String): JwkProvider {
.rateLimited(
10,
1,
TimeUnit.MINUTES
TimeUnit.MINUTES,
) // if not cached, only allow max 10 different keys per minute to be fetched from external provider
.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ private val logger = KotlinLogging.logger { }

internal fun Application.innsendingApi(
innsendingRepository: InnsendingRepository,
observer: InnsendingObserver
observer: InnsendingObserver,
) {

install(StatusPages) {
exception<Throwable> { call, cause ->
when (cause) {
Expand Down Expand Up @@ -58,7 +57,7 @@ internal fun Application.innsendingApi(
!setOf(
"isalive",
"isready",
"metrics"
"metrics",
).contains(call.request.document())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.time.format.DateTimeParseException

internal class SøknadFaktaQuizLøser(
private valknadQuizOppslag: SøknadQuizOppslag,
rapidsConnection: RapidsConnection
rapidsConnection: RapidsConnection,
) : River.PacketListener {

private companion object {
Expand All @@ -32,7 +32,7 @@ internal class SøknadFaktaQuizLøser(
"HelseTilAlleTyperJobb",
"VilligTilÅBytteYrke",
"FortsattRettKorona",
"JobbetUtenforNorge"
"JobbetUtenforNorge",
)

init {
Expand All @@ -46,12 +46,11 @@ internal class SøknadFaktaQuizLøser(
}

override fun onPacket(packet: JsonMessage, context: MessageContext) {

withMDC(
mapOf(
"søknadId" to packet["søknad_uuid"].asText(),
"behovId" to packet["@behovId"].asText()
)
"behovId" to packet["@behovId"].asText(),
),
) {
try {
val innsendtSøknadsId = packet.getInnsendtSøknadsId()
Expand Down Expand Up @@ -102,7 +101,7 @@ internal fun rettighetstypeUtregning(avsluttedeArbeidsforhold: List<AvsluttetArb
it.sluttårsak != AvsluttetArbeidsforhold.Sluttårsak.PERMITTERT &&
it.sluttårsak != AvsluttetArbeidsforhold.Sluttårsak.ARBEIDSGIVER_KONKURS &&
!it.fiskeforedling
)
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class PostgresSøknadQuizOppslag(private val dataSource: DataSource) :
val query = queryOf(
//language=PostgreSQL
"""SELECT * FROM soknad_v1 WHERE :jsonFragment::jsonb <@ data""",
mapOf("jsonFragment" to """{ "søknad_uuid": "$innsendtSøknadsId" }""")
mapOf("jsonFragment" to """{ "søknad_uuid": "$innsendtSøknadsId" }"""),
)

return using(sessionOf(dataSource)) { session ->
Expand All @@ -27,7 +27,7 @@ internal class PostgresSøknadQuizOppslag(private val dataSource: DataSource) :
row.binaryStreamOrNull("data")?.use {
QuizSøknadFormat(JsonMapper.jacksonJsonAdapter.readTree(it))
}
}.asSingle
}.asSingle,
) ?: throw IllegalArgumentException("Fant ikke søknad med innsendtId $innsendtSøknadsId")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ internal class FerdigstillJournalpostBehovLøser(
}

override fun onPacket(packet: JsonMessage, context: MessageContext) {

val journalpostId = packet["journalpostId"].asText()
val behovId = packet["@behovId"].asText()

withMDC(
mapOf(
"behovId" to behovId,
"journalpostId" to journalpostId
)
"journalpostId" to journalpostId,
),
) {
try {
runBlocking {
Expand All @@ -47,8 +46,8 @@ internal class FerdigstillJournalpostBehovLøser(

packet["@løsning"] = mapOf(
"FerdigstillJournalpost" to mapOf(
"journalpostId" to journalpostId
)
"journalpostId" to journalpostId,
),
)
context.publish(packet.toJson())
logger.info("løste behov FerdigstillJournalpost for journalpost med id $journalpostId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal interface JournalpostFeil {
private val whitelistFeilmeldinger = setOf(
"Bruker kan ikke oppdateres for journalpost med journalpostStatus=J og journalpostType=I.",
"er ikke midlertidig journalført",
"er ikke midlertidig journalf&oslash;rt"
"er ikke midlertidig journalf&oslash;rt",
)
}

Expand Down Expand Up @@ -69,7 +69,7 @@ internal class JournalpostApi {
val dokumenter: List<Dokument>,
val behandlingstema: String = "ab0001",
val tema: String = "DAG",
val journalfoerendeEnhet: String = "9999"
val journalfoerendeEnhet: String = "9999",
)

internal data class Sak(val fagsakId: String?) {
Expand All @@ -93,7 +93,7 @@ internal class JournalpostApi {
internal data class Dokument(val dokumentInfoId: String, val tittel: String)
internal enum class SaksType {
GENERELL_SAK,
FAGSAK
FAGSAK,
}
}

Expand All @@ -116,7 +116,7 @@ internal class JournalpostApiClient(config: Configuration) : JournalpostDokarkiv

override suspend fun oppdaterJournalpost(
journalpostId: String,
journalpost: JournalpostApi.OppdaterJournalpostRequest
journalpost: JournalpostApi.OppdaterJournalpostRequest,
) {
val feilmelding = "Kunne ikke oppdatere journalpost"
try {
Expand All @@ -131,7 +131,7 @@ internal class JournalpostApiClient(config: Configuration) : JournalpostDokarkiv
logger.error(e) { feilmelding }
throw JournalpostFeil.JournalpostException(
e.response.status.value,
e.response.bodyAsText()
e.response.bodyAsText(),
)
} catch (e: Throwable) {
logger.error(e) { feilmelding }
Expand All @@ -152,7 +152,7 @@ internal class JournalpostApiClient(config: Configuration) : JournalpostDokarkiv
logger.error(e) { feilmelding }
throw JournalpostFeil.JournalpostException(
e.response.status.value,
e.response.bodyAsText()
e.response.bodyAsText(),
)
} catch (e: Throwable) {
logger.error(e) { feilmelding }
Expand Down
Loading

0 comments on commit 039c86d

Please sign in to comment.