Skip to content

Commit

Permalink
♻️ Kaizen - diverse småendringer anbefalt av IntelliJ inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
chsko committed Aug 20, 2024
1 parent f341e53 commit 09eb8f9
Show file tree
Hide file tree
Showing 44 changed files with 146 additions and 733 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,6 @@ abstract class Modellfeil protected constructor() : RuntimeException() {
override val message: String get() = feilkode
}

class OppgaveAlleredeTildelt(val tildeling: TildelingApiDto) : Modellfeil() {
override val eksternKontekst: Map<String, Any> =
mapOf(
"tildeling" to tildeling,
)
override val httpkode = HttpStatusCode.Conflict
override val feilkode: String = "oppgave_er_allerede_tildelt"

override fun logger() {
logg.info(
"Returnerer {} for {}",
keyValue("httpkode", "${httpkode.value}"),
keyValue("feilkode", feilkode),
)
sikkerLogg.info(
"Returnerer {} for {}, tildelingsinfo=$eksternKontekst",
keyValue("httpkode", "${httpkode.value}"),
keyValue("feilkode", feilkode),
)
}
}

class OppgaveIkkeTildelt(private val oppgaveId: Long) : Modellfeil() {
override val eksternKontekst: Map<String, Any> = mapOf("oppgaveId" to oppgaveId.toString())
override val httpkode = HttpStatusCode.FailedDependency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import no.nav.helse.spesialist.api.graphql.schema.ArbeidsforholdOverstyringHandl
import no.nav.helse.spesialist.api.graphql.schema.InntektOgRefusjonOverstyring
import no.nav.helse.spesialist.api.graphql.schema.TidslinjeOverstyring

internal abstract class AbstractOverstyringApiTest() : AbstractGraphQLApiTest() {
internal abstract class AbstractOverstyringApiTest : AbstractGraphQLApiTest() {
fun overstyrTidslinje(overstyring: TidslinjeOverstyring): JsonNode =
runQuery(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import no.nav.helse.spesialist.api.db.AbstractDatabaseTest
import no.nav.helse.spesialist.api.egenAnsatt.EgenAnsattApiDao
import no.nav.helse.spesialist.api.graphql.schema.NotatType
import no.nav.helse.spesialist.api.notat.NotatDao
import no.nav.helse.spesialist.api.notat.NotatRepository
import no.nav.helse.spesialist.api.oppgave.OppgaveApiDao
import no.nav.helse.spesialist.api.oppgave.Oppgavehåndterer
import no.nav.helse.spesialist.api.oppgave.Oppgavestatus
Expand Down Expand Up @@ -72,7 +71,6 @@ import org.junit.jupiter.api.Assertions.assertEquals
import java.time.LocalDate
import java.time.LocalDateTime
import java.util.UUID
import kotlin.properties.Delegates

internal abstract class DatabaseIntegrationTest : AbstractDatabaseTest() {
private val NAVN = Navn(lagFornavn(), lagFornavn(), lagEtternavn())
Expand Down Expand Up @@ -111,11 +109,7 @@ internal abstract class DatabaseIntegrationTest : AbstractDatabaseTest() {
protected val egenAnsattApiDao = mockk<EgenAnsattApiDao>(relaxed = true)
protected val snapshotClient = mockk<SnapshotClient>(relaxed = true)

protected var sisteOppgaveId by Delegates.notNull<Long>()
protected var sisteCommandContextId by Delegates.notNull<UUID>()

protected val snapshotService = SnapshotService(snapshotApiDao, snapshotClient)
protected val notatRepository = mockk<NotatRepository>(relaxed = true)
protected val oppgavehåndterer = mockk<Oppgavehåndterer>(relaxed = true)
protected val totrinnsvurderinghåndterer = mockk<Totrinnsvurderinghåndterer>(relaxed = true)

Expand Down Expand Up @@ -374,15 +368,6 @@ internal abstract class DatabaseIntegrationTest : AbstractDatabaseTest() {
)
}

protected fun vedtakId(vedtaksperiodeId: UUID = PERIODE.id) =
sessionOf(dataSource).use { session ->
@Language("PostgreSQL")
val statement = "SELECT id FROM vedtak WHERE vedtaksperiode_id = ?"
requireNotNull(session.run(queryOf(statement, vedtaksperiodeId).map { it.long("id") }.asSingle)) {
"Finner ikke vedtak i db for vedtaksperiodeId=$vedtaksperiodeId"
}
}

protected fun opprettPerson(
dselsnummer: String = FØDSELSNUMMER,
aktørId: String = AKTØRID,
Expand Down Expand Up @@ -560,21 +545,6 @@ internal abstract class DatabaseIntegrationTest : AbstractDatabaseTest() {
requireNotNull(session.run(queryOf(statement).asUpdateAndReturnGeneratedKey))
}

private fun opprettSnapshot() =
sessionOf(dataSource, returnGeneratedKey = true).use { session ->
@Language("PostgreSQL")
val statement = "INSERT INTO snapshot(data, versjon) VALUES(?::json, ?)"
requireNotNull(
session.run(
queryOf(
statement,
objectMapper.writeValueAsString(snapshot()),
1,
).asUpdateAndReturnGeneratedKey,
),
)
}

private fun opprettOppgave(
status: Oppgavestatus = Oppgavestatus.AvventerSaksbehandler,
vedtakRef: Long,
Expand All @@ -600,10 +570,7 @@ internal abstract class DatabaseIntegrationTest : AbstractDatabaseTest() {
).asUpdateAndReturnGeneratedKey,
)
},
).also {
sisteOppgaveId = it
sisteCommandContextId = commandContextId
}
)
}

private fun opprettHendelse(
Expand Down Expand Up @@ -876,20 +843,6 @@ internal abstract class DatabaseIntegrationTest : AbstractDatabaseTest() {
assertEquals(forventetAntall, antall)
}

protected fun assertAvvisteVarsler(
generasjonRef: Long,
forventetAntall: Int,
) {
@Language("PostgreSQL")
val query =
"SELECT COUNT(1) FROM selve_varsel sv WHERE sv.generasjon_ref = ? AND status = 'AVVIST'"
val antall =
sessionOf(dataSource).use { session ->
session.run(queryOf(query, generasjonRef).map { it.int(1) }.asSingle)
}
assertEquals(forventetAntall, antall)
}

protected fun finnOppgaveIdFor(vedtaksperiodeId: UUID): Long =
sessionOf(dataSource).use { session ->
@Language("PostgreSQL")
Expand Down

This file was deleted.

Loading

0 comments on commit 09eb8f9

Please sign in to comment.