Skip to content

Commit

Permalink
overvåking - pågående implementering
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Kroken committed Sep 25, 2023
1 parent 3a62d37 commit f27958c
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ val hibernateValidatorVersion = "8.0.0.Final"
val logbackEncoderVersion = "7.2"
val postgresqlVersion = "42.5.1"
val flywayCoreVersion = "9.11.0"
val testcontainersVersion = "1.17.6"
val testcontainersVersion = "1.19.0"
val jacksonVersion = "2.14.1"
val springKafkaTestVersion = "3.0.5"
val azureAdClient = "0.0.7"
val assertjVersion = "3.24.2"

plugins {
kotlin("jvm") version "1.8.0"
Expand Down Expand Up @@ -68,6 +69,7 @@ dependencies {
testImplementation("org.testcontainers:postgresql:$testcontainersVersion")
testImplementation("org.springframework.kafka:spring-kafka-test:$springKafkaTestVersion")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0")
testImplementation("org.assertj:assertj-core:$assertjVersion")
}

tasks.test {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain

import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.repository.BarnetrygdInnlesingRepository
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
import org.springframework.transaction.support.TransactionTemplate

@Service
class StatusService(
private val repo: BarnetrygdInnlesingRepository,
private val transactionTemplate: TransactionTemplate,
) {
companion object {
private val log = LoggerFactory.getLogger(this::class.java)
}

fun checkStatus(): ApplicationStatus {
if (repo.finnSisteInnlesing() == null) return ApplicationStatus.IkkeKjort
return ApplicationStatus.Feil(listOf("a", "b"))
}
}

sealed class ApplicationStatus {
object OK : ApplicationStatus()
object IkkeKjort : ApplicationStatus()
class Feil(val feil: List<String>) : ApplicationStatus()
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ class BarnetrygdInnlesingRepository(
).singleOrNull()
}

fun finnSisteInnlesing(): BarnetrygdInnlesing? {
return jdbcTemplate.query(
"""select * from innlesing order by forespurt_tidspunkt desc limit 1""",
InnlesingRowMapper()
).singleOrNull()
}

fun invalider(id: UUID) {
jdbcTemplate.update(
"""delete from innlesing where id = :id""",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain

import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.SpringContextTest
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.repository.BarnetrygdInnlesingRepository
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.repository.BarnetrygdmottakerRepository
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired

class StatusServiceTest: SpringContextTest.NoKafka() {

@Autowired
private lateinit var innlesingRepository: BarnetrygdInnlesingRepository

@Autowired
private lateinit var barnetrygdmottakerRepository: BarnetrygdmottakerRepository

@Autowired
private lateinit var statusService: StatusService

@Test
fun testFantIngenInnlesninger() {
val status = statusService.checkStatus()
assertThat(status).isEqualTo(ApplicationStatus.IkkeKjort)
}
}

0 comments on commit f27958c

Please sign in to comment.