Skip to content

Commit

Permalink
♻️ Bruk asSQL i en testfunksjon
Browse files Browse the repository at this point in the history
  • Loading branch information
havstein committed Nov 20, 2024
1 parent 5affca9 commit 1ef9831
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions spesialist-selve/src/test/kotlin/AbstractE2ETest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import kotliquery.sessionOf
import no.nav.helse.AbstractDatabaseTest
import no.nav.helse.AvviksvurderingTestdata
import no.nav.helse.GodkjenningsbehovTestdata
import no.nav.helse.HelseDao.Companion.asSQL
import no.nav.helse.HelseDao.Companion.single
import no.nav.helse.Meldingssender
import no.nav.helse.TestRapidHelpers.behov
import no.nav.helse.TestRapidHelpers.hendelser
Expand Down Expand Up @@ -1326,20 +1328,15 @@ internal abstract class AbstractE2ETest : AbstractDatabaseTest() {
}

private fun hentOppgaveegenskaper(oppgaveId: Long): Set<Egenskap> {
@Language("PostgreSQL")
val query = "select egenskaper from oppgave o where id = :oppgaveId"
val egenskaper =
requireNotNull(
sessionOf(dataSource).use { session ->
session.run(
queryOf(query, mapOf("oppgaveId" to oppgaveId)).map { row ->
row.array<String>("egenskaper").map<String, Egenskap>(::enumValueOf).toSet()
}.asSingle,
)
},
) { "Forventer å finne en oppgave for id=$oppgaveId" }

return egenskaper
val egenskaper = sessionOf(dataSource).use { session ->
asSQL(
"select egenskaper from oppgave o where id = :oppgaveId",
"oppgaveId" to oppgaveId,
).single(session) { row ->
row.array<String>("egenskaper").map<String, Egenskap>(::enumValueOf).toSet()
}
}
return requireNotNull(egenskaper) { "Forventer å finne en oppgave for id=$oppgaveId" }
}

protected fun assertSaksbehandleroppgaveBleIkkeOpprettet(vedtaksperiodeId: UUID = testperson.vedtaksperiodeId1) {
Expand Down

0 comments on commit 1ef9831

Please sign in to comment.