Skip to content

Commit

Permalink
litt refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jankroken-nav committed Nov 8, 2024
1 parent db58886 commit e9875c6
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,6 @@ class BarnetrygdinformasjonRepository(
)
}

fun finnAntallMedStatus(status: Barnetrygdinformasjon.Status): Long {
return jdbcTemplate.queryForObject(
"""select count(*)
|from barnetrygdinnlesing
|and status = :status""".trimMargin(),
mapOf(
"status" to when (status) {
Barnetrygdinformasjon.Status.KLAR -> "Klar"
Barnetrygdinformasjon.Status.SENDT -> "Sendt"
}
),
Long::class.java,
)!!
}

fun frigiGamleLåser(): Int {
val oneHourAgo = Instant.now(clock).minus(1.hours.toJavaDuration()).toString()
return jdbcTemplate.update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,7 @@ class BarnetrygdmottakerRepository(
Long::class.java,
)!!
}

fun harBarnetrygdmottakereKlareTilBehandling(): Boolean {
return jdbcTemplate.queryForObject(
"""select 1
|from barnetrygdmottaker
|and status_type = 'Klar'
|or (status_type = 'Retry' and karanteneTil < :now)
|fetch first row only
|""".trimMargin(),
mapOf(
"now" to Instant.now(clock).toString(),
),
Long::class.java,
) != null
}


fun oppdaterFeiledeRaderTilKlar(innlesingId: UUID): Int {
val nyStatus = serialize(Barnetrygdmottaker.Status.Klar())
return jdbcTemplate.update(
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/static/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<html>
<html lang="nb-NO">
<head>
<meta charset="utf8">
<style>
Expand Down Expand Up @@ -109,6 +109,7 @@
localStorage.setItem("hjelpetekst", hjelpetekst.hidden ? "hidden" : "shown")
}
</script>
<title>Administrasjon omsorgsopptjening-start-innlesning</title>
</head>
<body onload="init()">
<h1>Omsorgsopptjening - Administrasjon av meldinger</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,6 @@ class BarnetrygdmottakerRepositoryTest : SpringContextTest.NoKafka() {
assertThat(barnetrygdmottakerRepository.finnAlle(innlesingUberørt.id).single().statushistorikk).hasSize(1)
}

@Test
fun `harBarnetrygdmottakereKlareTilBehandling svarer riktig når ingen barnetrygdmottakere`() {

}

private fun lagreBestiltInnlesing(
innlesing: BarnetrygdInnlesing.Bestilt = BarnetrygdInnlesing.Bestilt(
id = InnlesingId.generate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import com.github.tomakehurst.wiremock.junit5.WireMockExtension
import com.github.tomakehurst.wiremock.stubbing.StubMapping
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain.Ident

private fun WireMockExtension.pdlResponse(fileName: String): StubMapping {
fun WireMockExtension.`pdl error not_found`(): StubMapping {
synchronized(this) {
return this.stubFor(
WireMock.post(WireMock.urlPathEqualTo("/graphql"))
.willReturn(
aResponse()
.withHeader("Content-Type", "application/json")
.withStatus(202)
.withBodyFile("pdl/$fileName")
.withBodyFile("pdl/error_not_found.json")
)
)
}
}

private fun WireMockExtension.pdlResponse(fnr: String, fileName: String): StubMapping {
fun WireMockExtension.`pdl error not_found`(fnr: String): StubMapping {
synchronized(this) {
return this.stubFor(
WireMock.post(WireMock.urlPathEqualTo("/graphql"))
Expand All @@ -30,7 +30,7 @@ private fun WireMockExtension.pdlResponse(fnr: String, fileName: String): StubMa
aResponse()
.withHeader("Content-Type", "application/json")
.withStatus(202)
.withBodyFile("pdl/$fileName")
.withBodyFile("pdl/error_not_found.json")
)
)
}
Expand Down Expand Up @@ -76,12 +76,4 @@ fun WireMockExtension.`pdl fnr fra query`(): StubMapping {
)
)
)
}

fun WireMockExtension.`pdl error not_found`(): StubMapping {
return this.pdlResponse("error_not_found.json")
}

fun WireMockExtension.`pdl error not_found`(fnr: String): StubMapping {
return this.pdlResponse(fnr, "error_not_found.json")
}
21 changes: 0 additions & 21 deletions src/test/resources/__files/barnetrygd/fagsaker_2.json

This file was deleted.

0 comments on commit e9875c6

Please sign in to comment.